Search in sources :

Example 1 with Representable

use of com.liferay.apio.architect.representor.Representable in project com-liferay-apio-architect by liferay.

the class RepresentableManagerImpl method emit.

@Override
protected void emit(ServiceReference<Representable> serviceReference, Emitter<Class<Identifier>> emitter) {
    Representable representable = bundleContext.getService(serviceReference);
    Class<Identifier> genericClass = getGenericClassFromPropertyOrElse(serviceReference, KEY_PRINCIPAL_TYPE_ARGUMENT, () -> getTypeParamOrFail(representable, Representable.class, 2));
    emitter.emit(genericClass);
}
Also used : Representable(com.liferay.apio.architect.representor.Representable) Identifier(com.liferay.apio.architect.identifier.Identifier)

Example 2 with Representable

use of com.liferay.apio.architect.representor.Representable in project com-liferay-apio-architect by liferay.

the class RepresentableManagerImpl method _computeRepresentables.

private void _computeRepresentables() {
    Map<String, List<RelatedCollection<?>>> relatedCollections = new HashMap<>();
    Stream<Class<Identifier>> keyStream = getKeyStream();
    keyStream.forEach(clazz -> {
        Representable representable = serviceTrackerMap.getService(clazz);
        String name = representable.getName();
        Optional<Map<String, String>> optional = INSTANCE.getNamesOptional();
        Optional<String> classNameOptional = optional.map(Map::entrySet).map(Collection::stream).orElseGet(Stream::empty).filter(entry -> Objects.equals(entry.getValue(), name)).map(Entry::getKey).findFirst();
        if (classNameOptional.isPresent()) {
            if (_apioLogger != null) {
                _apioLogger.warning(_getDuplicateErrorMessage(clazz, name, classNameOptional.get()));
            }
            return;
        }
        INSTANCE.putName(clazz.getName(), name);
        INSTANCE.putIdentifierClass(name, clazz);
        INSTANCE.putRepresentor(name, _getRepresentor(unsafeCast(representable), unsafeCast(clazz), relatedCollections));
    });
}
Also used : Representable(com.liferay.apio.architect.representor.Representable) HashMap(java.util.HashMap) RelatedCollection(com.liferay.apio.architect.related.RelatedCollection) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Representable (com.liferay.apio.architect.representor.Representable)2 Identifier (com.liferay.apio.architect.identifier.Identifier)1 RelatedCollection (com.liferay.apio.architect.related.RelatedCollection)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1