erconnect-maven-plugin.1.6.source-code.ivotemplate.vm Maven / Gradle / Ivy
package $ivod.pkgName;
#foreach ( $imp in $mmh.getImports() )
import $imp;
#end
#if ($ivod.identity)
#end
/**
* $ivod.comment
*
* @author $ivod.author
*/
@SuppressWarnings("all")
#if ($mmh.isDeprecated())
@Deprecated
@ToBeRemoved(date="$ivod.removalDate")
#end
@JsonDeserialize(builder = ${mmh.getIVOClazzName()}.${mmh.getIVOClazzName()}Builder.class)
public class $mmh.getIVOClazzName() extends $mmh.getParent() implements I$mmh.getIVOClazzName()#if ($ivod.identity)#end {
private static final long serialVersionUID = ${ivod.version}L;
/**
* Builder for the read-only ivo
*
*/
#if ($mmh.isDeprecated())
@Deprecated
@ToBeRemoved(date="$ivod.removalDate")
#end
@JsonPOJOBuilder()
public static class ${mmh.getIVOClazzName()}Builder extends Abstract${mmh.getIVOClazzName()}Builder<${mmh.getIVOClazzName()}Builder> implements IVOBuilder {
// nothing to do here, really
}
/**
* Abstract Builder for the read-only ivo
*
* @param type of builder
*/
public abstract static class Abstract${mmh.getIVOClazzName()}Builder> $mmh.getParentBuilder() $mmh.getBuilderImplements() {
#foreach ( $att in $mmh.allMemberDefs )
private $mmh.getType( $att, false ) $att.name;
#end
#if ( $ivod.auditing )
private Integer version;
private DateTime lastChange;
private Long lastChangeUserId;
#end
#if ( $ivod.identity && !$ivod.parentName )
private String id;
/**
* the id
*
* @param pid the value to set
* @return the builder
*
**/
@SuppressWarnings("unchecked")
public E withId(String pid) {
this.id = pid;
return (E) this;
}
#end
#if ( $ivod.auditing )
/**
* This field is optional, thus may be null.
* The version
*
* @param pversion the value to set
* @return the builder
*
**/
@Nullable
@SuppressWarnings("unchecked")
public E withVersion(Integer pversion) {
this.version = pversion;
return (E) this;
}
/**
* This field is optional, thus may be null.
* The last change date
*
* @param plastChange the value to set
* @return the builder
*
**/
@Nullable
@SuppressWarnings("unchecked")
public E withLastChange(DateTime plastChange) {
this.lastChange = plastChange;
return (E) this;
}
/**
* This field is optional, thus may be null.
* The last change user id
*
* @param plastChangeUserId the value to set
* @return the builder
*
**/
@Nullable
@SuppressWarnings("unchecked")
public E withLastChangeUserId(Long plastChangeUserId) {
this.lastChangeUserId = plastChangeUserId;
return (E) this;
}
#end
#foreach ( $att in $mmh.allMemberDefs )
/**
#if ( $att.required )
* This field is required.
#else
* This field is optional, thus may be null.
#end
* $att.comment
*
* @param p$att.name the value to set
* @return the builder
*
**/
#if ( $att.required )
@Nonnull
#else
@Nullable
#end
@SuppressWarnings("unchecked")
public E with$mmh.upperCaseFirst( $att.name )($mmh.getType( $att, false ) p$att.name) {
this.$att.name = p$att.name;
return (E) this;
}
#end
protected void internalFillFromIVO($mmh.getIVOClazzName() ivo) {
#if ( $ivod.parentName )
super.internalFillFromIVO(ivo);
#end
#foreach ( $att in $mmh.allMemberDefs )
this.with$mmh.upperCaseFirst( $att.name )(ivo.$att.name);
#end
#if ( $ivod.identity && !$ivod.parentName )
this.withId(ivo.id);
#end
#if ( $ivod.auditing )
this.withVersion(ivo.version);
this.withLastChange(ivo.lastChange);
this.withLastChangeUserId(ivo.lastChangeUserId);
#end
}
/**
* @return the entry
**/
#if ( $ivod.parentName )
@Override
#end
public $mmh.getIVOClazzName() build() {
#foreach ( $att in $mmh.allMemberDefs )
#if ( $att.required )
if (this.$att.name == null) {
throw new IllegalStateException("The attribute $att.name must not be null!");
}
#end
#end
$mmh.getIVOClazzName() result = new $mmh.getIVOClazzName()(this);
return result;
}
}
#foreach ( $att in $mmh.allMemberDefs )
private final #if ( $att.javaTransientFlag ) transient #end $mmh.getType( $att, false ) $att.name;
#end
#if ( $ivod.identity && !$ivod.parentName )
private final String id;
#end
#if ( $ivod.auditing )
private final Integer version;
private final DateTime lastChange;
private final Long lastChangeUserId;
#end
protected $mmh.getIVOClazzName()(Abstract${mmh.getIVOClazzName()}Builder> builder) {
#if ( $ivod.parentName )
super(builder);
#end
#foreach ( $att in $mmh.allMemberDefs )
this.$att.name = builder.$att.name;
#end
#if ( $ivod.identity && !$ivod.parentName )
this.id = builder.id;
#end
#if ( $ivod.auditing )
this.version = builder.version;
this.lastChange = builder.lastChange;
this.lastChangeUserId = builder.lastChangeUserId;
#end
}
#if ( $ivod.identity && !$ivod.parentName )
@Override
public String getId() {
return this.id;
}
@Override
public long getIdAsLong() {
try {
return Long.parseLong(this.id);
} catch (NumberFormatException e) {
// string not parsable
return -1;
}
}
#end
#if ( $ivod.auditing )
@Override
public Integer getVersion() {
return this.version;
}
@Override
public DateTime getLastChange() {
return this.lastChange;
}
@Override
public Long getLastChangeUserId() {
return this.lastChangeUserId;
}
#end
#foreach ( $att in $mmh.noCollectionMemberDefs )
#if ( $att.jsonTransientFlag )
@JsonIgnore
#end
@Override
public $mmh.getType( $att, false ) get$mmh.upperCaseFirst( $att.name )() {
return this.$att.name;
}
#end
#foreach ( $att in $mmh.collectionMemberDefs )
#if ( $att.jsonTransientFlag )
@JsonIgnore
#end
@Override
public $mmh.getType( $att, false ) get$mmh.upperCaseFirst( $att.name )() {
#if( $att.collectionType == "List" )
return this.$att.name == null ? null : Collections.unmodifiableList(this.$att.name);
#else
return this.$att.name == null ? null : Collections.unmodifiableSet(this.$att.name);
#end
}
#end
#foreach ( $att in $mmh.mapMemberDefs )
#if ( $att.jsonTransientFlag )
@JsonIgnore
#end
@Override
public $mmh.getType( $att, false ) get$mmh.upperCaseFirst( $att.name )() {
#if( $att.mapType == "Map" )
return this.$att.name == null ? null : Collections.unmodifiableMap(this.$att.name);
#else
return this.$att.name == null ? null : Multimaps.unmodifiableMultimap(this.$att.name);
#end
}
#end
@SuppressWarnings("unchecked")
@Override
public T createBuilder() {
${mmh.getIVOClazzName()}Builder builder = new ${mmh.getIVOClazzName()}Builder();
builder.internalFillFromIVO(this);
return (T) builder;
}
#if( $ivod.pageable )
@SuppressWarnings("unchecked")
@Override
public IPageableBuilder createPageableBuilder() {
return (IPageableBuilder) createBuilder();
}
#end
#if ( $ivod.identity && !$ivod.parentName )
@Override
public String toString() {
return this.getClass().getName() + " " + this.id;
}
#end
@Override
public $mmh.getIVOClazzName() clone() {
return ($mmh.getIVOClazzName()) super.clone();
}
#if ( $ivod.identity && !$ivod.parentName )
@Override
public boolean equals(Object obj) {
if(obj instanceof $mmh.getIVOClazzName()) {
return this.id.equals((($mmh.getIVOClazzName())obj).id);
}
return false;
}
@Override
public int hashCode() {
return this.id.hashCode();
}
#end
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy