use of org.talend.daikon.i18n.tag.HasTags in project components by Talend.
the class DefinitionsControllerImpl method listDefinitions.
/**
* Return all known definitions that match the given type.
*
* @param type the wanted definition type.
* @return all known definitions that match the given type.
* @returnWrapped java.lang.Iterable<org.talend.components.service.rest.dto.DefinitionDTO>
*/
@Override
public List<DefinitionDTO> listDefinitions(DefinitionType type, String tag) {
logger.debug("listing definitions for {} ", type);
//
Iterable<? extends Definition> definitionsByType = definitionServiceDelegate.getDefinitionsMapByType(type.getTargetClass()).values();
Stream<? extends Definition> stream = stream(definitionsByType.spliterator(), false);
if (tag != null) {
stream = //
stream.filter(c -> HasTags.class.isAssignableFrom(c.getClass())).filter(c -> {
for (Tag defTag : ((HasTags) c).getTags()) {
if (TagUtils.hasTag(defTag, tag)) {
return true;
}
}
return false;
});
}
return stream.map(c -> {
if (type == DefinitionType.COMPONENT) {
return new DefinitionDTO((ComponentDefinition) c);
} else {
return new DefinitionDTO((DatastoreDefinition) c);
}
}).collect(Collectors.toList());
}
Aggregations