/** * Checks if {@link ClassRef} is buildable. * @param ref The reference. * @return True if buildable repository contains the ref or builder for the reference is present. */ public static boolean isBuildable(ClassRef ref) { if (BuilderContextManager.getContext().getBuildableRepository().isBuildable(ref)) { return true; } String builderFQCN = ref.getDefinition().getFullyQualifiedName() + "Builder"; TypeDef builder = BuilderContextManager.getContext().getDefinitionRepository().getDefinition(builderFQCN); if (builder == null) { return false; } return builder.getMethods() .stream() .filter(m -> "build".equals(m.getName())) .filter(m -> m.getReturnType().isAssignableFrom(ref)) .count() > 0; }
if (!method.getReturnType().isAssignableFrom(property.getTypeRef())) { return false;
/** * Returns the string representation of the code that given a reference of the specified type, reads the specified property. * @param ref The reference. * @param source The type of the reference. * @param property The property to read. * @return The code. */ private static String readProperty(String ref, TypeDef source, Property property) { TypeRef propertyTypeRef = property.getTypeRef(); Method getter = getterOf(source, property); if (getter == null) { return "null"; } TypeRef getterTypeRef = getter.getReturnType(); if (propertyTypeRef.getDimensions() == getterTypeRef.getDimensions() && propertyTypeRef.isAssignableFrom(getterTypeRef)) { return readObjectProperty(ref, source, property); } if (property.getTypeRef().getDimensions() > 0) { return readArrayProperty(ref, source, property); } if (property.getTypeRef() instanceof ClassRef && ((ClassRef)getterTypeRef).getDefinition().isAnnotation()) { return readAnnotationProperty(ref + "."+getter.getName()+"()", ((ClassRef) getterTypeRef).getDefinition(), property); } return readObjectProperty(ref, source, property); }