All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.eventsourcing.layout.comparable.ComparableSerialization Maven / Gradle / Ivy

There is a newer version: 0.4.6
Show newest version
/**
 * Copyright (c) 2016, All Contributors (see CONTRIBUTORS file)
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package com.eventsourcing.layout.comparable;

import com.eventsourcing.layout.*;
import com.eventsourcing.layout.binary.BinarySerialization;
import com.eventsourcing.layout.binary.MapBinaryDeserializer;
import com.eventsourcing.layout.binary.MapBinarySerializer;
import lombok.SneakyThrows;

import static com.eventsourcing.layout.TypeHandler.*;

public class ComparableSerialization extends Serialization {
    private static final ComparableSerialization COMPARABLE_SERIALIZATION = new ComparableSerialization();

    private ComparableSerialization() {
        addSerializer(BIG_DECIMAL_TYPE_HANDLER, new BigDecimalComparableSerializer());
        addSerializer(BYTE_ARRAY_TYPE_HANDLER, new ByteArrayComparableSerializer());
        addSerializer(LIST_TYPE_HANDLER, new ListComparableSerializer());
        addSerializer(MAP_TYPE_HANDLER, new MapComparableSerializer());
        addSerializer(OPTIONAL_TYPE_HANDLER, new OptionalComparableSerializer());
        addSerializer(STRING_TYPE_HANDLER, new StringComparableSerializer());
    }

    public static ComparableSerialization getInstance() {
        return COMPARABLE_SERIALIZATION;
    }

    @Override public  Deserializer getDeserializer(H typeHandler) {
        throw new UnsupportedOperationException();
    }

    @Override public  Serializer getSerializer(H typeHandler) {
        Serializer serializer = super.getSerializer(typeHandler);
        if (serializer == null) {
            return BinarySerialization.getInstance().getSerializer(typeHandler);
        } else {
            return serializer;
        }
    }

    @SneakyThrows
    @Override public  ObjectSerializer getSerializer(Class klass) {
        throw new UnsupportedOperationException();
    }

    @Override public  ObjectDeserializer getDeserializer(Class klass, boolean allowReadonly) {
        throw new UnsupportedOperationException();
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy