Search in sources :

Example 1 with MetaPrimitiveType

use of io.crnk.meta.model.MetaPrimitiveType in project crnk-framework by crnk-project.

the class BaseMetaPartition method doAllocateMetaElement.

protected Optional<MetaElement> doAllocateMetaElement(Type type) {
    if (type instanceof Class) {
        Class clazz = (Class) type;
        clazz = mapPrimitiveType(clazz);
        if (isPrimitiveType(clazz)) {
            String id = BASE_ID_PREFIX + firstToLower(clazz.getSimpleName());
            Optional<MetaElement> optPrimitiveType = context.getMetaElement(id);
            if (!optPrimitiveType.isPresent()) {
                MetaPrimitiveType primitiveType = new MetaPrimitiveType();
                primitiveType.setElementType(primitiveType);
                primitiveType.setImplementationType(clazz);
                primitiveType.setName(firstToLower(clazz.getSimpleName()));
                primitiveType.setId(id);
                return addElement(type, primitiveType);
            }
            return optPrimitiveType;
        }
    }
    return Optional.empty();
}
Also used : MetaElement(io.crnk.meta.model.MetaElement) MetaPrimitiveType(io.crnk.meta.model.MetaPrimitiveType)

Aggregations

MetaElement (io.crnk.meta.model.MetaElement)1 MetaPrimitiveType (io.crnk.meta.model.MetaPrimitiveType)1