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

com.envimate.mapmate.serialization.builder.DataTransferObjectSerializationMethodBuilder Maven / Gradle / Ivy

Go to download

MapMate is a modern mapping framework in the scope of mapping data in Json, XML, or YAML format into DTOs composed and vice versa.

There is a newer version: 1.6.8
Show newest version
/*
 * Copyright (C) 2017 [Richard Hauswald, Nune Isabekyan] (envimate GmbH - https://envimate.com/)
 */

package com.envimate.mapmate.serialization.builder;

@SuppressWarnings("unused")
public class DataTransferObjectSerializationMethodBuilder {

    private final DataTransferObjectFilterBuilder parent;
    private boolean serializeByPublicFields;
    private SerializationMethod serializationMethod;

    public DataTransferObjectSerializationMethodBuilder(
            final DataTransferObjectFilterBuilder dataTransferObjectFilterBuilder) {
        this.serializeByPublicFields = false;
        this.parent = dataTransferObjectFilterBuilder;
    }

    public SerializerBuilder bySerializingItsPublicFields() {
        this.serializeByPublicFields = true;
        return this.parent.serialized(build());
    }

    public SerializerBuilder using(final SerializationMethod method) {
        this.serializationMethod = method;
        return this.parent.serialized(build());
    }

    private DataTransferObjectSerializationMethod build() {
        if(this.serializeByPublicFields) {
            return new DataTransferObjectSerializationMethod();
        } else if(this.serializationMethod != null) {
            return new DataTransferObjectSerializationMethod(this.serializationMethod);
        } else {
            throw new IllegalStateException("serialization method builder not configured");
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy