- return new GeneratedTransferObjectImpl(packageName, name, comment,
- annotationBuilders, extendsType, implementsTypes,
- constantDefintions, enumerations, methodDefinitions,
- properties, equalsProperties, hashProperties,
- toStringProperties);
- }
-
- @Override
- public GeneratedTransferObject toIdentityInstance() {
- return new GeneratedTransferIdentityObjectImpl(packageName, name, comment,
- annotationBuilders, extendsType, implementsTypes,
- constantDefintions, enumerations, methodDefinitions,
- properties, equalsProperties, hashProperties,
- toStringProperties);
- }
-
- private static final class GeneratedPropertyBuilderImpl implements
- GeneratedPropertyBuilder {
-
- private final String name;
- private final List<AnnotationTypeBuilder> annotationBuilders = new ArrayList<AnnotationTypeBuilder>();
- private Type returnType;
- private final List<MethodSignature.Parameter> parameters;
- private String comment = "";
- private AccessModifier accessModifier;
- private boolean isFinal;
- private boolean isReadOnly;
-
- public GeneratedPropertyBuilderImpl(final String name) {
- super();
- this.name = name;
- parameters = new ArrayList<MethodSignature.Parameter>();
- isFinal = true;
- this.isReadOnly = true;
- accessModifier = AccessModifier.PUBLIC;
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public AnnotationTypeBuilder addAnnotation(String packageName,
- String name) {
- if (packageName != null && name != null) {
- final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(
- packageName, name);
- if (annotationBuilders.add(builder)) {
- return builder;
- }
- }
- return null;
- }
-
- @Override
- public boolean addReturnType(Type returnType) {
- if (returnType != null) {
- this.returnType = returnType;
- this.parameters.add(new MethodParameterImpl(name, returnType));
- return true;
- }
- return false;
- }
-
- @Override
- public void accessorModifier(final AccessModifier modifier) {
- accessModifier = modifier;
- }
-
- @Override
- public void addComment(String comment) {
- if (comment != null) {
- this.comment = comment;
- }
- }
-
- @Override
- public void setFinal(boolean isFinal) {
- this.isFinal = isFinal;
- }
-
- @Override
- public void setReadOnly(boolean isReadOnly) {
- this.isReadOnly = isReadOnly;
- }
-
- @Override
- public GeneratedProperty toInstance(final Type definingType) {
- return new GeneratedPropertyImpl(name, comment, annotationBuilders,
- definingType, returnType, isFinal, isReadOnly, parameters,
- accessModifier);
- }
- }
-
- private static final class GeneratedPropertyImpl implements
- GeneratedProperty {
-
- private final String name;
- private List<AnnotationType> annotations;
- private final String comment;
- private final Type parent;
- private final Type returnType;
- private final boolean isFinal;
- private final boolean isReadOnly;
- private final List<MethodSignature.Parameter> parameters;
- private final AccessModifier modifier;
-
- public GeneratedPropertyImpl(final String name, final String comment,
- final List<AnnotationTypeBuilder> annotationBuilders,
- final Type parent, final Type returnType,
- final boolean isFinal, final boolean isReadOnly,
- final List<Parameter> parameters, final AccessModifier modifier) {
- super();
- this.name = name;
- this.annotations = new ArrayList<AnnotationType>();
- for (final AnnotationTypeBuilder builder : annotationBuilders) {
- this.annotations.add(builder.toInstance());
- }
- this.annotations = Collections.unmodifiableList(this.annotations);
- this.comment = comment;
- this.parent = parent;
- this.returnType = returnType;
- this.isFinal = isFinal;
- this.isReadOnly = isReadOnly;
- this.parameters = Collections.unmodifiableList(parameters);
- this.modifier = modifier;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public String getComment() {
- return comment;
- }
-
- @Override
- public Type getDefiningType() {
- return parent;
- }
-
- @Override
- public List<AnnotationType> getAnnotations() {
- return annotations;
- }
-
- @Override
- public Type getReturnType() {
- return returnType;
- }
-
- @Override
- public List<Parameter> getParameters() {
- return parameters;
- }
-
- @Override
- public AccessModifier getAccessModifier() {
- return modifier;
- }
-
- @Override
- public boolean isReadOnly() {
- return isReadOnly;
- }
-
- @Override
- public boolean isFinal() {
- return isFinal;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result
- + ((parameters == null) ? 0 : parameters.hashCode());
- result = prime * result
- + ((returnType == null) ? 0 : returnType.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- GeneratedPropertyImpl other = (GeneratedPropertyImpl) obj;
- if (name == null) {
- if (other.name != null) {
- return false;
- }
- } else if (!name.equals(other.name)) {
- return false;
- }
- if (parameters == null) {
- if (other.parameters != null) {
- return false;
- }
- } else if (!parameters.equals(other.parameters)) {
- return false;
- }
- if (returnType == null) {
- if (other.returnType != null) {
- return false;
- }
- } else if (!returnType.getPackageName().equals(
- other.returnType.getPackageName())) {
- return false;
- } else if (!returnType.getName().equals(other.returnType.getName())) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("GeneratedPropertyImpl [name=");
- builder.append(name);
- builder.append(", annotations=");
- builder.append(annotations);
- builder.append(", comment=");
- builder.append(comment);
- if (parent != null) {
- builder.append(", parent=");
- builder.append(parent.getPackageName());
- builder.append(".");
- builder.append(parent.getName());
- } else {
- builder.append(", parent=null");
- }
- builder.append(", returnType=");
- builder.append(returnType);
- builder.append(", isFinal=");
- builder.append(isFinal);
- builder.append(", isReadOnly=");
- builder.append(isReadOnly);
- builder.append(", parameters=");
- builder.append(parameters);
- builder.append(", modifier=");
- builder.append(modifier);
- builder.append("]");
- return builder.toString();
- }
- }
-
- private static class GeneratedTransferObjectImpl implements
+ return new GeneratedTransferObjectImpl(null, getPackageName(), getName(), getComment(),
+ getAnnotations(), isAbstract(), extendsType, getImplementsTypes(), getEnclosedTypes(),
+ getEnclosedTransferObjects(), getConstants(), getEnumerations(), getMethodDefinitions(), properties,
+ equalsProperties, hashProperties, toStringProperties);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("GeneratedTransferObject [packageName=");
+ builder.append(getPackageName());
+ builder.append(", name=");
+ builder.append(getName());
+ builder.append(", comment=");
+ builder.append(getComment());
+ builder.append(", constants=");
+ builder.append(getConstants());
+ builder.append(", enumerations=");
+ builder.append(getEnumerations());
+ builder.append(", properties=");
+ builder.append(properties);
+ builder.append(", equalsProperties=");
+ builder.append(equalsProperties);
+ builder.append(", hashCodeProperties=");
+ builder.append(hashProperties);
+ builder.append(", stringProperties=");
+ builder.append(toStringProperties);
+ builder.append(", annotations=");
+ builder.append(getAnnotations());
+ builder.append(", methods=");
+ builder.append(getMethodDefinitions());
+ builder.append("]");
+ return builder.toString();
+ }
+
+ private static final class GeneratedTransferObjectImpl extends AbstractGeneratedType implements