use of com.devonfw.cobigen.api.annotation.Cached in project cobigen by devonfw.
the class InputResolverImpl method resolveContainerElements.
@Cached
@Override
public List<Object> resolveContainerElements(Object input, Trigger trigger) {
List<Object> inputObjects = new ArrayList<>();
if (this.inputInterpreter.combinesMultipleInputs(input)) {
TriggerInterpreter triggerInterpreter = PluginRegistry.getTriggerInterpreter(trigger.getType());
InputReader inputReader = triggerInterpreter.getInputReader();
// check whether the inputs should be retrieved recursively
boolean retrieveInputsRecursively = false;
for (ContainerMatcher containerMatcher : trigger.getContainerMatchers()) {
MatcherTo matcherTo = new MatcherTo(containerMatcher.getType(), containerMatcher.getValue(), input);
if (triggerInterpreter.getMatcher().matches(matcherTo)) {
if (!retrieveInputsRecursively) {
retrieveInputsRecursively = containerMatcher.isRetrieveObjectsRecursively();
} else {
break;
}
}
}
if (retrieveInputsRecursively) {
inputObjects = inputReader.getInputObjectsRecursively(input, trigger.getInputCharset());
} else {
inputObjects = inputReader.getInputObjects(input, trigger.getInputCharset());
}
// Remove non matching inputs
Iterator<Object> it = inputObjects.iterator();
while (it.hasNext()) {
Object next = it.next();
if (!this.matcherEvaluator.matches(next, trigger.getMatcher(), triggerInterpreter)) {
it.remove();
}
}
} else {
inputObjects.add(input);
}
return inputObjects;
}
use of com.devonfw.cobigen.api.annotation.Cached in project cobigen by devonfw.
the class ConfigurationInterpreterImpl method getMatchingIncrements.
@Cached
@Override
public List<IncrementTo> getMatchingIncrements(Object matcherInput) throws InvalidConfigurationException {
LOG.debug("Matching increments requested.");
List<IncrementTo> increments = Lists.newLinkedList();
List<String> matchingTriggerIds = getMatchingTriggerIds(matcherInput);
for (TemplatesConfiguration templatesConfiguration : getMatchingTemplatesConfigurations(matcherInput)) {
increments.addAll(convertIncrements(templatesConfiguration.getAllGenerationPackages(), templatesConfiguration.getTrigger(), matchingTriggerIds));
}
LOG.debug("{} matching increments found.", increments.size());
return increments;
}
use of com.devonfw.cobigen.api.annotation.Cached in project cobigen by devonfw.
the class ConfigurationInterpreterImpl method getMatchingTriggerIds.
@Cached
@Override
public List<String> getMatchingTriggerIds(Object matcherInput) {
LOG.debug("Matching trigger IDs requested.");
List<String> matchingTriggerIds = Lists.newLinkedList();
for (Trigger trigger : this.triggerMatchingEvaluator.getMatchingTriggers(matcherInput)) {
matchingTriggerIds.add(trigger.getId());
}
LOG.debug("{} matching trigger IDs found.", matchingTriggerIds.size());
return matchingTriggerIds;
}
use of com.devonfw.cobigen.api.annotation.Cached in project cobigen by devonfw.
the class ConfigurationInterpreterImpl method getMatchingTemplates.
@Cached
@Override
public List<TemplateTo> getMatchingTemplates(Object matcherInput) throws InvalidConfigurationException {
LOG.debug("Matching templates requested.");
List<TemplateTo> templates = Lists.newLinkedList();
for (TemplatesConfiguration templatesConfiguration : getMatchingTemplatesConfigurations(matcherInput)) {
for (Template template : templatesConfiguration.getAllTemplates()) {
templates.add(new TemplateTo(template.getName(), template.getMergeStrategy(), templatesConfiguration.getTrigger().getId()));
}
}
LOG.debug("{} matching templates found.", templates.size());
return templates;
}
use of com.devonfw.cobigen.api.annotation.Cached in project cobigen by devonfw.
the class InputInterpreterImpl method resolveContainers.
@Cached
@Override
public List<Object> resolveContainers(Object input) {
List<Trigger> matchingTriggers = this.configurationInterpreter.getMatchingTriggers(input);
List<Object> inputs = new ArrayList<>();
for (Trigger t : matchingTriggers) {
inputs.addAll(this.inputResolver.resolveContainerElements(input, t));
}
return inputs;
}
Aggregations