Package io.sundr.builder.internal.utils
Class BuilderUtils
java.lang.Object
io.sundr.builder.internal.utils.BuilderUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic Collection<String>allGenericsOf(io.sundr.model.Method method) allGenericsOf(io.sundr.model.TypeDef clazz) allGenericsOf(io.sundr.model.TypeRef type) static Collection<String>allGenericsOf(io.sundr.model.Variable<?> variable) static List<io.sundr.model.TypeRef>appendNewGenericArgument(io.sundr.model.ClassRef type, io.sundr.model.TypeParamRef... excluded) static List<io.sundr.model.TypeRef>appendNewWildcardArgument(io.sundr.model.ClassRef type) static io.sundr.model.FieldarrayAsList(io.sundr.model.Field field) static io.sundr.model.FieldbuildableField(io.sundr.model.Field field) static booleancanBeBuilt(io.sundr.model.TypeDef typeDef) static booleancanBeBuilt(io.sundr.model.TypeRef typeRef) enclosedBuildables(io.sundr.model.TypeDef typeDef) Get all the enclosingTypes.static io.sundr.model.MethodfindBuildableConstructor(io.sundr.model.TypeDef clazz) static List<io.sundr.model.ClassRef>findBuildableReferences(io.sundr.model.ClassRef ref) Returns all references of aClassRefthat are considered buildable.static io.sundr.model.TypeDeffindBuildableSuperClass(io.sundr.model.TypeDef clazz) static io.sundr.model.ClassReffindBuildableSuperClassRef(io.sundr.model.TypeDef clazz) static StringfullyQualifiedNameDiff(io.sundr.model.TypeRef typeRef, io.sundr.model.TypeDef originType) static Set<TypeElement>getBuildableReferences(BuilderContext context, Buildable buildable) static Set<TypeElement>getBuildableReferences(BuilderContext context, ExternalBuildables buildable) static Set<io.sundr.model.Method>getInlineableConstructors(io.sundr.model.Field field) static io.sundr.model.TypeDefgetInlineReturnType(BuilderContext context, Inline inline, io.sundr.model.TypeDef fallback) static io.sundr.model.TypeDefgetInlineType(BuilderContext context, Inline inline) static io.sundr.model.TypeParamRefgetNextGeneric(io.sundr.model.ClassRef type, io.sundr.model.TypeParamRef... excluded) static io.sundr.model.TypeParamRefgetNextGeneric(io.sundr.model.ClassRef classRef, Collection<io.sundr.model.TypeParamRef> excluded) static io.sundr.model.TypeParamDefgetNextGeneric(io.sundr.model.TypeDef type, io.sundr.model.TypeParamDef... excluded) static io.sundr.model.TypeParamDefgetNextGeneric(io.sundr.model.TypeDef type, Collection excluded) static booleanhasBuildableConstructorWithArgument(io.sundr.model.TypeDef clazz, io.sundr.model.Variable<?> variable) static booleanhasBuilder(io.sundr.model.ClassRef ref) Checks if a sundrio-generated Builder class exists for the givenClassRef.static booleanhasDefaultConstructor(io.sundr.model.TypeDef item) Checks if there is a default constructor available.static booleanhasDefaultConstructor(io.sundr.model.TypeRef item) Checks if there is a default constructor available.static StringifNotNullToString(io.sundr.model.Property property, boolean hasNext) Deprecated.static List<io.sundr.model.Statement>ifNotNullToStringStatements(io.sundr.model.Field field, boolean hasNext) static booleanisBuildable(io.sundr.model.ClassRef ref) Checks ifClassRefis buildable.static booleanisBuildable(io.sundr.model.TypeDef typeDef) static booleanisBuildable(io.sundr.model.TypeRef typeRef) static booleanisInlineable(io.sundr.model.Method method) static booleanisOrHasBuildableDescendants(io.sundr.model.Field field) static booleanisRegisteredAsBuildable(io.sundr.model.TypeDef typeDef) static booleanisRegisteredAsBuildable(io.sundr.model.TypeRef typeRef) static booleanmethodHasArgument(io.sundr.model.Method method, io.sundr.model.Variable<?> variable) Checks if method has a specific argument.static voidpopulateEnclosedBuildables(io.sundr.model.TypeDef typeDef, Map<String, io.sundr.model.ClassRef> result) static StringqualifyPropertyName(io.sundr.model.Field field, io.sundr.model.TypeRef typeRef, io.sundr.model.TypeDef originType) Create a qualified name for the given property - if it is not a descendant, then just the capitalized name will be used.static StringqualifyPropertyName(io.sundr.model.Field field, io.sundr.model.TypeRef typeRef, io.sundr.model.TypeDef originType, boolean useSingular) Create a qualified name for the given property.static List<io.sundr.model.Statement>toEquals(io.sundr.model.WithFullyQualifiedName WithFullyQualifiedName, Collection<io.sundr.model.Field> fields) static List<io.sundr.model.Statement>toHashCode(Collection<io.sundr.model.Field> fields) static List<io.sundr.model.Statement>toString(String name, Collection<io.sundr.model.Field> fields)
-
Method Details
-
canBeBuilt
public static boolean canBeBuilt(io.sundr.model.TypeRef typeRef) -
canBeBuilt
public static boolean canBeBuilt(io.sundr.model.TypeDef typeDef) -
isRegisteredAsBuildable
public static boolean isRegisteredAsBuildable(io.sundr.model.TypeRef typeRef) -
isBuildable
public static boolean isBuildable(io.sundr.model.TypeRef typeRef) -
isRegisteredAsBuildable
public static boolean isRegisteredAsBuildable(io.sundr.model.TypeDef typeDef) -
isBuildable
public static boolean isBuildable(io.sundr.model.TypeDef typeDef) -
isBuildable
public static boolean isBuildable(io.sundr.model.ClassRef ref) Checks ifClassRefis buildable.- Parameters:
ref- The reference.- Returns:
- True if buildable repository contains the ref or builder for the reference is present.
-
hasBuilder
public static boolean hasBuilder(io.sundr.model.ClassRef ref) Checks if a sundrio-generated Builder class exists for the givenClassRef. Looks first in the definition repository (same-module types), then falls back to the APTElementsAPI for cross-module types whose@Buildableannotation is not visible at compile time (SOURCE retention). A class is considered to have a builder if a type named<FQCN>Builderexists and declares abuild()method.- Parameters:
ref- The class reference to check.- Returns:
- True if a matching builder is found.
-
isOrHasBuildableDescendants
public static boolean isOrHasBuildableDescendants(io.sundr.model.Field field) -
findBuildableReferences
Returns all references of aClassRefthat are considered buildable.- Parameters:
ref- The reference.- Returns:
- The list with all detected references.
-
findBuildableSuperClassRef
public static io.sundr.model.ClassRef findBuildableSuperClassRef(io.sundr.model.TypeDef clazz) -
findBuildableSuperClass
public static io.sundr.model.TypeDef findBuildableSuperClass(io.sundr.model.TypeDef clazz) -
findBuildableConstructor
public static io.sundr.model.Method findBuildableConstructor(io.sundr.model.TypeDef clazz) -
methodHasArgument
public static boolean methodHasArgument(io.sundr.model.Method method, io.sundr.model.Variable<?> variable) Checks if method has a specific argument.- Parameters:
method- The method.variable- The argument.- Returns:
- True if matching argument if found.
-
hasBuildableConstructorWithArgument
public static boolean hasBuildableConstructorWithArgument(io.sundr.model.TypeDef clazz, io.sundr.model.Variable<?> variable) -
hasDefaultConstructor
public static boolean hasDefaultConstructor(io.sundr.model.TypeRef item) Checks if there is a default constructor available.- Parameters:
item- The clazz to check.- Returns:
- True if default constructor is found, false otherwise.
-
hasDefaultConstructor
public static boolean hasDefaultConstructor(io.sundr.model.TypeDef item) Checks if there is a default constructor available.- Parameters:
item- The clazz to check.- Returns:
- True if default constructor is found, false otherwise.
-
getInlineableConstructors
-
isInlineable
public static boolean isInlineable(io.sundr.model.Method method) -
getInlineType
-
getInlineReturnType
public static io.sundr.model.TypeDef getInlineReturnType(BuilderContext context, Inline inline, io.sundr.model.TypeDef fallback) -
getBuildableReferences
-
getBuildableReferences
public static Set<TypeElement> getBuildableReferences(BuilderContext context, ExternalBuildables buildable) -
getNextGeneric
public static io.sundr.model.TypeParamDef getNextGeneric(io.sundr.model.TypeDef type, io.sundr.model.TypeParamDef... excluded) -
getNextGeneric
public static io.sundr.model.TypeParamRef getNextGeneric(io.sundr.model.ClassRef type, io.sundr.model.TypeParamRef... excluded) -
appendNewGenericArgument
public static List<io.sundr.model.TypeRef> appendNewGenericArgument(io.sundr.model.ClassRef type, io.sundr.model.TypeParamRef... excluded) -
appendNewWildcardArgument
-
getNextGeneric
public static io.sundr.model.TypeParamDef getNextGeneric(io.sundr.model.TypeDef type, Collection excluded) -
getNextGeneric
public static io.sundr.model.TypeParamRef getNextGeneric(io.sundr.model.ClassRef classRef, Collection<io.sundr.model.TypeParamRef> excluded) -
allGenericsOf
-
allGenericsOf
-
allGenericsOf
-
allGenericsOf
-
qualifyPropertyName
public static String qualifyPropertyName(io.sundr.model.Field field, io.sundr.model.TypeRef typeRef, io.sundr.model.TypeDef originType) Create a qualified name for the given property - if it is not a descendant, then just the capitalized name will be used.- Parameters:
field- The property.typeRef- The type reference.originType- The origin type.- Returns:
- The qualified property name.
-
qualifyPropertyName
public static String qualifyPropertyName(io.sundr.model.Field field, io.sundr.model.TypeRef typeRef, io.sundr.model.TypeDef originType, boolean useSingular) Create a qualified name for the given property. If useSingular is true the root property name will be changed to the singular form.- Parameters:
field- The property.typeRef- The type reference.originType- The origin type.useSingular- Flag to use singular form.- Returns:
- The qualified property name.
-
fullyQualifiedNameDiff
public static String fullyQualifiedNameDiff(io.sundr.model.TypeRef typeRef, io.sundr.model.TypeDef originType) -
arrayAsList
public static io.sundr.model.Field arrayAsList(io.sundr.model.Field field) -
buildableField
public static io.sundr.model.Field buildableField(io.sundr.model.Field field) -
populateEnclosedBuildables
-
enclosedBuildables
public static Map<String,io.sundr.model.ClassRef> enclosedBuildables(io.sundr.model.TypeDef typeDef) Get all the enclosingTypes.- Parameters:
typeDef- the typeDef that we check for enclosed buildables.- Returns:
- all the enclosingTypes.
-
toString
public static List<io.sundr.model.Statement> toString(String name, Collection<io.sundr.model.Field> fields) -
ifNotNullToStringStatements
public static List<io.sundr.model.Statement> ifNotNullToStringStatements(io.sundr.model.Field field, boolean hasNext) -
ifNotNullToString
@Deprecated public static String ifNotNullToString(io.sundr.model.Property property, boolean hasNext) Deprecated. -
toHashCode
-
toEquals
public static List<io.sundr.model.Statement> toEquals(io.sundr.model.WithFullyQualifiedName WithFullyQualifiedName, Collection<io.sundr.model.Field> fields)
-