com.envimate.mapmate.serialization.builder.DataTransferObjectSerializationMethodBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mapmate Show documentation
Show all versions of mapmate Show documentation
MapMate is a modern mapping framework in the scope of mapping data in
Json, XML, or YAML format into DTOs composed and vice versa.
/*
* 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");
}
}
}