@Override protected String createLocalIdentifier(final JavaType javaType, final LogicalPath path) { return EqualsMetadata.createIdentifier(javaType, path); }
final FieldMetadata identifierField, final boolean hasJavaBeanAnnotation) { super(identifier, aspectName, governorPhysicalTypeMetadata); Validate.isTrue(isValid(identifier), "Metadata id '%s' is invalid", identifier); Validate.notNull(annotationValues, "Annotation values required"); ensureGovernorHasMethod(new MethodMetadataBuilder(getEqualsMethod())); ensureGovernorHasMethod(new MethodMetadataBuilder(getHashCodeMethod()));
/** * Returns the `equals` method to be generated * * @return `null` if no generation is required */ private MethodMetadata getEqualsMethod() { MethodMetadata method = getGovernorMethod(EQUALS_METHOD_NAME, OBJECT); if (method != null) { return method; } return generateEqualsMethod(getId(), destination, annotationValues, identifierField == null ? null : getAccessorMethod(identifierField).getMethodName(), locatedFields, builder).build(); }
/** * Returns the `hashCode` method to be generated * * @return `null` if no generation is required */ private MethodMetadata getHashCodeMethod() { MethodMetadata method = getGovernorMethod(HASH_CODE_METHOD_NAME); if (method != null) { return method; } return generateHashCodeMethod(getId(), annotationValues, locatedFields, builder.getImportRegistrationResolver()).build(); }
builder = getJpaEntityHashCodeMethodReturnStatment(); } else { builder = getDefaultHashCodeMethodReturnStatment(annotationValues, locatedFields, importRegistrationResolver);
if (annotationValues.isJpaEntity()) { bodyBuilder = getJpaEntityEqualsMethodBody(target, identifierAccessor, builder.getImportRegistrationResolver()); } else { bodyBuilder = generateDefaultEqualsMethodBody(target, annotationValues.isAppendSuper(), locatedFields, builder.getImportRegistrationResolver());
idField = getAccesorMethod(identifierField).getMethodName(); ensureGovernorHasMethod(EqualsMetadata.generateEqualsMethod(identifier, target, equalsAnnotationValues, idField, equalsFields, builder)); ensureGovernorHasMethod(EqualsMetadata.generateHashCodeMethod(identifier, equalsAnnotationValues, equalsFields, builder.getImportRegistrationResolver()));
@Override protected ItdTypeDetailsProvidingMetadataItem getMetadata( final String metadataIdentificationString, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata, final String itdFilename) { final EqualsAnnotationValues annotationValues = new EqualsAnnotationValues(governorPhysicalTypeMetadata); if (!annotationValues.isAnnotationFound()) { return null; } final MemberDetails memberDetails = getMemberDetails(governorPhysicalTypeMetadata); if (memberDetails == null) { return null; } AnnotationMetadata javaBeanAnnotation = memberDetails.getAnnotation(ROO_JAVA_BEAN); if (javaBeanAnnotation != null) { // Return an empty metadata as @RooJavaBean do the work return new EqualsMetadata(metadataIdentificationString, aspectName, governorPhysicalTypeMetadata, annotationValues, new ArrayList<FieldMetadata>(), null, true); } final JavaType javaType = governorPhysicalTypeMetadata.getMemberHoldingTypeDetails().getName(); final List<FieldMetadata> equalityFields = locateFields(javaType, annotationValues.getExcludeFields(), memberDetails.getFields(), metadataIdentificationString); FieldMetadata identifierField = getIdentifier(governorPhysicalTypeMetadata); return new EqualsMetadata(metadataIdentificationString, aspectName, governorPhysicalTypeMetadata, annotationValues, equalityFields, identifierField, false); }
/** * Returns the `hashCode` method to be generated * * @return `null` if no generation is required */ private MethodMetadata getHashCodeMethod() { MethodMetadata method = getGovernorMethod(HASH_CODE_METHOD_NAME); if (method != null) { return method; } return generateHashCodeMethod(getId(), annotationValues, locatedFields, builder.getImportRegistrationResolver()).build(); }
builder = getJpaEntityHashCodeMethodReturnStatment(); } else { builder = getDefaultHashCodeMethodReturnStatment(annotationValues, locatedFields, importRegistrationResolver);
if (annotationValues.isJpaEntity()) { bodyBuilder = getJpaEntityEqualsMethodBody(target, identifierAccessor, builder.getImportRegistrationResolver()); } else { bodyBuilder = generateDefaultEqualsMethodBody(target, annotationValues.isAppendSuper(), locatedFields, builder.getImportRegistrationResolver());
idField = getAccesorMethod(identifierField).getMethodName(); ensureGovernorHasMethod(EqualsMetadata.generateEqualsMethod(identifier, target, equalsAnnotationValues, idField, equalsFields, builder)); ensureGovernorHasMethod(EqualsMetadata.generateHashCodeMethod(identifier, equalsAnnotationValues, equalsFields, builder.getImportRegistrationResolver()));
@Override protected ItdTypeDetailsProvidingMetadataItem getMetadata( final String metadataIdentificationString, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata, final String itdFilename) { final EqualsAnnotationValues annotationValues = new EqualsAnnotationValues(governorPhysicalTypeMetadata); if (!annotationValues.isAnnotationFound()) { return null; } final MemberDetails memberDetails = getMemberDetails(governorPhysicalTypeMetadata); if (memberDetails == null) { return null; } AnnotationMetadata javaBeanAnnotation = memberDetails.getAnnotation(ROO_JAVA_BEAN); if (javaBeanAnnotation != null) { // Return an empty metadata as @RooJavaBean do the work return new EqualsMetadata(metadataIdentificationString, aspectName, governorPhysicalTypeMetadata, annotationValues, new ArrayList<FieldMetadata>(), null, true); } final JavaType javaType = governorPhysicalTypeMetadata.getMemberHoldingTypeDetails().getName(); final List<FieldMetadata> equalityFields = locateFields(javaType, annotationValues.getExcludeFields(), memberDetails.getFields(), metadataIdentificationString); FieldMetadata identifierField = getIdentifier(governorPhysicalTypeMetadata); return new EqualsMetadata(metadataIdentificationString, aspectName, governorPhysicalTypeMetadata, annotationValues, equalityFields, identifierField, false); }
/** * Returns the `equals` method to be generated * * @return `null` if no generation is required */ private MethodMetadata getEqualsMethod() { MethodMetadata method = getGovernorMethod(EQUALS_METHOD_NAME, OBJECT); if (method != null) { return method; } return generateEqualsMethod(getId(), destination, annotationValues, identifierField == null ? null : getAccessorMethod(identifierField).getMethodName(), locatedFields, builder).build(); }
final FieldMetadata identifierField, final boolean hasJavaBeanAnnotation) { super(identifier, aspectName, governorPhysicalTypeMetadata); Validate.isTrue(isValid(identifier), "Metadata id '%s' is invalid", identifier); Validate.notNull(annotationValues, "Annotation values required"); ensureGovernorHasMethod(new MethodMetadataBuilder(getEqualsMethod())); ensureGovernorHasMethod(new MethodMetadataBuilder(getHashCodeMethod()));
@Override protected String createLocalIdentifier(final JavaType javaType, final LogicalPath path) { return EqualsMetadata.createIdentifier(javaType, path); }