/** * Locates the accessor methods. * <p> * If {@link #getFieldBuilders()} returns fields created by this ITD, public * accessors will automatically be produced in the declaring class. * * @param fields * @return the accessors (never returns null) */ private List<MethodMetadataBuilder> getAccessors(final List<FieldMetadataBuilder> fields) { final List<MethodMetadataBuilder> accessors = new ArrayList<MethodMetadataBuilder>(); // Compute the names of the accessors that will be produced for (final FieldMetadataBuilder field : fields) { final JavaSymbolName requiredAccessorName = BeanInfoUtils.getAccessorMethodName(field.getFieldName(), field.getFieldType()); final MethodMetadata accessor = getGovernorMethod(requiredAccessorName); if (accessor == null) { accessors.add(getAccessorMethod(field.getFieldName(), field.getFieldType())); } else { Validate.isTrue(Modifier.isPublic(accessor.getModifier()), "User provided field but failed to provide a public '%s()' method in '%s'", requiredAccessorName.getSymbolName(), destination.getFullyQualifiedTypeName()); accessors.add(new MethodMetadataBuilder(accessor)); } } return accessors; }
/** * Locates the mutator methods. * <p> * If {@link #getFieldBuilders()} returns fields created by this ITD, public * mutators will automatically be produced in the declaring class. * * @param fields * @return the mutators (never returns null) */ private List<MethodMetadataBuilder> getMutators(final List<FieldMetadataBuilder> fields) { final List<MethodMetadataBuilder> mutators = new ArrayList<MethodMetadataBuilder>(); // Compute the names of the mutators that will be produced for (final FieldMetadataBuilder field : fields) { final JavaSymbolName requiredMutatorName = BeanInfoUtils.getMutatorMethodName(field.getFieldName()); final JavaType parameterType = field.getFieldType(); final MethodMetadata mutator = getGovernorMethod(requiredMutatorName, parameterType); if (mutator == null) { mutators.add(getMutatorMethod(field.getFieldName(), field.getFieldType())); } else { Validate.isTrue(Modifier.isPublic(mutator.getModifier()), "User provided field but failed to provide a public '%s(%s)' method in '%s'", requiredMutatorName.getSymbolName(), field.getFieldName().getSymbolName(), destination.getFullyQualifiedTypeName()); mutators.add(new MethodMetadataBuilder(mutator)); } } return mutators; }
parameterTypes.add(field.getFieldType());
public FieldMetadata build() { DefaultFieldMetadata md = new DefaultFieldMetadata(getCustomData().build(), getDeclaredByMetadataId(), getModifier(), buildAnnotations(), getFieldName(), getFieldType(), getFieldInitializer()); md.setCommentStructure(getCommentStructure()); return md; }
if (targetField.getFieldType().equals(field.getFieldType()) && targetField.getFieldName().equals(field.getFieldName())) {
/** * Locates the accessor methods. * <p> * If {@link #getFieldBuilders()} returns fields created by this ITD, public * accessors will automatically be produced in the declaring class. * * @param fields * @return the accessors (never returns null) */ private List<MethodMetadataBuilder> getAccessors(final List<FieldMetadataBuilder> fields) { final List<MethodMetadataBuilder> accessors = new ArrayList<MethodMetadataBuilder>(); // Compute the names of the accessors that will be produced for (final FieldMetadataBuilder field : fields) { final JavaSymbolName requiredAccessorName = BeanInfoUtils.getAccessorMethodName(field.getFieldName(), field.getFieldType()); final MethodMetadata accessor = getGovernorMethod(requiredAccessorName); if (accessor == null) { accessors.add(getAccessorMethod(field.getFieldName(), field.getFieldType())); } else { Validate.isTrue(Modifier.isPublic(accessor.getModifier()), "User provided field but failed to provide a public '%s()' method in '%s'", requiredAccessorName.getSymbolName(), destination.getFullyQualifiedTypeName()); accessors.add(new MethodMetadataBuilder(accessor)); } } return accessors; }
/** * Locates the mutator methods. * <p> * If {@link #getFieldBuilders()} returns fields created by this ITD, public * mutators will automatically be produced in the declaring class. * * @param fields * @return the mutators (never returns null) */ private List<MethodMetadataBuilder> getMutators(final List<FieldMetadataBuilder> fields) { final List<MethodMetadataBuilder> mutators = new ArrayList<MethodMetadataBuilder>(); // Compute the names of the mutators that will be produced for (final FieldMetadataBuilder field : fields) { final JavaSymbolName requiredMutatorName = BeanInfoUtils.getMutatorMethodName(field.getFieldName()); final JavaType parameterType = field.getFieldType(); final MethodMetadata mutator = getGovernorMethod(requiredMutatorName, parameterType); if (mutator == null) { mutators.add(getMutatorMethod(field.getFieldName(), field.getFieldType())); } else { Validate.isTrue(Modifier.isPublic(mutator.getModifier()), "User provided field but failed to provide a public '%s(%s)' method in '%s'", requiredMutatorName.getSymbolName(), field.getFieldName().getSymbolName(), destination.getFullyQualifiedTypeName()); mutators.add(new MethodMetadataBuilder(mutator)); } } return mutators; }
parameterTypes.add(field.getFieldType());
public FieldMetadata build() { DefaultFieldMetadata md = new DefaultFieldMetadata(getCustomData().build(), getDeclaredByMetadataId(), getModifier(), buildAnnotations(), getFieldName(), getFieldType(), getFieldInitializer()); md.setCommentStructure(getCommentStructure()); return md; }
private void addToBuilder(final FieldMetadataBuilder fieldBuilder) { final JavaSymbolName fieldName = fieldBuilder.getFieldName(); if (hasField(fieldName, fieldBuilder.buildAnnotations()) || hasFieldInItd(fieldName)) { return; } builder.addField(fieldBuilder); // Check for an existing accessor in the governor final JavaType fieldType = fieldBuilder.getFieldType(); builder.addMethod(getAccessorMethod(fieldName, fieldType)); // Check for an existing mutator in the governor builder.addMethod(getMutatorMethod(fieldName, fieldType)); }
column, table.getName(), table.isIncludeNonPortableAttributes()); if (fieldBuilder.getFieldType().equals(DATE) && fieldName.getSymbolName().equals(CREATED)) { fieldBuilder.setFieldInitializer("new Date()");
for (FieldMetadataBuilder fieldBuilder : mutableTypeDetails .getDeclaredFields()) { if (!fieldBuilder.getFieldType().equals(field.getFieldType())) { continue;
if (targetField.getFieldType().equals(field.getFieldType()) && targetField.getFieldName().equals(field.getFieldName())) {