public TypeDef getApi(TypeRef type) { if (type instanceof ClassRef) { return apis.get(((ClassRef)type).getDefinition().getFullyQualifiedName()); } return null; }
public TypeDef getModel(TypeRef type) { if (type instanceof ClassRef) { return models.get(((ClassRef)type).getDefinition().getFullyQualifiedName()); } return null; }
public boolean isModel(TypeRef type) { if (type instanceof ClassRef) { return isModel(((ClassRef)type).getDefinition()); } return false; }
/** * Checks if a {@link TypeRef} is a {@link java.util.Optional}. * @param type The type to check. * @return True if its a {@link java.util.Optional}. */ public static boolean isOptional(TypeRef type) { if (!(type instanceof ClassRef)) { return false; } return JAVA_UTIL_OPTIONAL.equals(((ClassRef)type).getDefinition().getFullyQualifiedName()); }
/** * Checks if a {@link TypeRef} is a {@link java.util.OptionalDouble}. * @param type The type to check. * @return True if its a {@link java.util.OptionalDouble}. */ public static boolean isOptionalDouble(TypeRef type) { if (!(type instanceof ClassRef)) { return false; } return JAVA_UTIL_OPTIONAL_DOUBLE.equals(((ClassRef)type).getDefinition().getFullyQualifiedName()); }
public boolean isBuildable(TypeRef type) { if (type instanceof ClassRef) { return isBuildable(((ClassRef)type).getDefinition()); } return false; }
public TypeDef getBuildable(TypeRef type) { if (type instanceof ClassRef) { return buildables.get(((ClassRef)type).getDefinition().getFullyQualifiedName()); } return null; }
/** * Checks if a {@link TypeRef} is a {@link java.util.OptionalLong}. * @param type The type to check. * @return True if its a {@link java.util.OptionalLong}. */ public static boolean isOptionalLong(TypeRef type) { if (!(type instanceof ClassRef)) { return false; } return JAVA_UTIL_OPTIONAL_LONG.equals(((ClassRef)type).getDefinition().getFullyQualifiedName()); }
public boolean isApi(TypeRef type) { if (type instanceof ClassRef) { return isApi(((ClassRef)type).getDefinition()); } return false; }
/** * Checks if a {@link TypeRef} is a {@link java.util.OptionalInt}. * @param type The type to check. * @return True if its a {@link java.util.OptionalInt}. */ public static boolean isOptionalInt(TypeRef type) { if (!(type instanceof ClassRef)) { return false; } return JAVA_UTIL_OPTIONAL_INT.equals(((ClassRef)type).getDefinition().getFullyQualifiedName()); }
public String apply(List<ClassRef> types) { Iterator<ClassRef> iterator = types.iterator(); if (iterator.hasNext()) { return iterator.next().getDefinition().getPackageName(); } return ""; } };
private static String createKeyForClasses(Collection<ClassRef> alternatives) { List<TypeDef> typeDefs = new LinkedList<TypeDef>(); for (ClassRef classRef : alternatives) { typeDefs.add(classRef.getDefinition()); } return createKeyForTypes(typeDefs); }
private static boolean hasPojoAnnotation(TypeDef typeDef) { return typeDef.getAnnotations().stream() .filter(a -> a.getClassRef().getDefinition().getFullyQualifiedName().equals(Pojo.class.getTypeName())) .findAny().isPresent(); }
public String getName() { if (requiresFullyQualifiedName()) { return getDefinition().getFullyQualifiedName(); } return getDefinition().getName(); }
/** * Returns the string representation of the code that reads a primitive array property. * @param ref The reference. * @param source The type of the reference. * @param property The property to read. * @return The code. */ private static String readAnnotationProperty(String ref, TypeDef source, Property property) { return convertReference(ref, source, ((ClassRef)property.getTypeRef()).getDefinition()); }
/** * Checks a {@link TypeRef} is of an abstract type. * @param typeRef The type to check. * @return True if its an abstract type. */ public static boolean isAbstract(TypeRef typeRef) { DefinitionRepository repository = DefinitionRepository.getRepository(); TypeDef def = repository.getDefinition(typeRef); if (def == null && typeRef instanceof ClassRef) { def = ((ClassRef)typeRef).getDefinition(); } return def != null ? def.isAbstract() : false; }
public static ClassRef buildableRef(TypeRef typeRef) { ClassRef unwrapped = (ClassRef) TypeAs.combine(UNWRAP_COLLECTION_OF, UNWRAP_ARRAY_OF, UNWRAP_OPTIONAL_OF).apply(typeRef); return isAbstract(unwrapped) || unwrapped.getDefinition().getKind() == Kind.INTERFACE ? TypeAs.VISITABLE_BUILDER.apply(unwrapped) : TypeAs.BUILDER.apply(unwrapped.getDefinition()).toInternalReference(); }
public ClassRefFluentImpl(ClassRef instance){ this.withDefinition(instance.getDefinition()); this.withFullyQualifiedName(instance.getFullyQualifiedName()); this.withDimensions(instance.getDimensions()); this.withArguments(instance.getArguments()); this.withAttributes(instance.getAttributes()); }
public ClassRefBuilder(ClassRef instance, Boolean validationEnabled) { this.fluent = this; this.withDefinition(instance.getDefinition()); this.withFullyQualifiedName(instance.getFullyQualifiedName()); this.withDimensions(instance.getDimensions()); this.withArguments(instance.getArguments()); this.withAttributes(instance.getAttributes()); this.validationEnabled = validationEnabled; }
public ClassRefBuilder(ClassRefFluent<?> fluent, ClassRef instance, Boolean validationEnabled) { this.fluent = fluent; fluent.withDefinition(instance.getDefinition()); fluent.withFullyQualifiedName(instance.getFullyQualifiedName()); fluent.withDimensions(instance.getDimensions()); fluent.withArguments(instance.getArguments()); fluent.withAttributes(instance.getAttributes()); this.validationEnabled = validationEnabled; }