Search in sources :

Example 1 with RelatedCollection

use of com.liferay.apio.architect.related.RelatedCollection 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

RelatedCollection (com.liferay.apio.architect.related.RelatedCollection)1 Representable (com.liferay.apio.architect.representor.Representable)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