/*
 * Copyright 2018-present Open Networking Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.onosproject.store.atomix.primitives.impl;

import org.onosproject.store.service.Serializer;

/**
 * Atomix serializer.
 */
public class AtomixSerializerAdapter implements io.atomix.utils.serializer.Serializer {
    private final Serializer serializer;

    public AtomixSerializerAdapter(Serializer serializer) {
        this.serializer = serializer;
    }

    @Override
    public <T> byte[] encode(T object) {
        return serializer.encode(object);
    }

    @Override
    public <T> T decode(byte[] bytes) {
        return serializer.decode(bytes);
    }
}