Search in sources :

Example 1 with DefinitionRepository

use of io.sundr.model.repo.DefinitionRepository in project sundrio by sundrio.

the class BuilderUtils method hasDefaultConstructor.

/**
 * Checks if there is a default constructor available.
 *
 * @param item The clazz to check.
 * @return True if default constructor is found, false otherwise.
 */
public static boolean hasDefaultConstructor(TypeRef item) {
    DefinitionRepository repository = DefinitionRepository.getRepository();
    TypeDef def = repository.getDefinition(item);
    if (def == null && item instanceof ClassRef) {
        def = GetDefinition.of((ClassRef) item);
    }
    return hasDefaultConstructor(def);
}
Also used : DefinitionRepository(io.sundr.model.repo.DefinitionRepository) TypeDef(io.sundr.model.TypeDef) ClassRef(io.sundr.model.ClassRef)

Example 2 with DefinitionRepository

use of io.sundr.model.repo.DefinitionRepository in project sundrio by sundrio.

the class Types method isAbstract.

/**
 * 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).map(GetDefinition.FUNCTION);
    }
    return def != null ? def.isAbstract() : false;
}
Also used : DefinitionRepository(io.sundr.model.repo.DefinitionRepository)

Example 3 with DefinitionRepository

use of io.sundr.model.repo.DefinitionRepository in project sundrio by sundrio.

the class Types method isConcrete.

/**
 * Checks if {@link TypeRef} is of an concrete
 *
 * @param typeRef The type to check.
 * @return True if its an concrete type.
 */
public static boolean isConcrete(TypeRef typeRef) {
    DefinitionRepository repository = DefinitionRepository.getRepository();
    TypeDef def = repository.getDefinition(typeRef);
    if (def == null && typeRef instanceof ClassRef) {
        def = ((ClassRef) typeRef).map(GetDefinition.FUNCTION);
    }
    return def != null ? !def.isAbstract() && !def.isInterface() : false;
}
Also used : DefinitionRepository(io.sundr.model.repo.DefinitionRepository)

Aggregations

DefinitionRepository (io.sundr.model.repo.DefinitionRepository)3 ClassRef (io.sundr.model.ClassRef)1 TypeDef (io.sundr.model.TypeDef)1