protected <T> T handleGetCapability(Class<T> capability) {
if (MultiComponent.class.isAssignableFrom(capability)) {
return capability.cast(this);
}
if (Evaluator.class.isAssignableFrom(capability)) {
Evaluator e = new Evaluator() {
@Override
public String getCode() {
return getData().getCode();
}
@Override
public String getDisplayName() {
return getDisplay();
}
@Override
public String getLanguage() {
return getData().getLanguage();
}
public boolean requiresMultipleInputs() {
return getExecutor() != null && getExecutor().requiresMultipleInputs();
}
private Executor getExecutor() {
Executor e = executor.get();
if (e == null) {
executor.set(e = MultiProviderRegistry.getExecutor(MultiComponent.this));
}
return e;
}
private final AtomicReference<Executor> executor = new AtomicReference<Executor>();
@Override
public FeedProvider.RenderingInfo evaluate(
Map<String, List<Map<String, String>>> data,
List<FeedProvider> providers) {
Executor e = getExecutor();
FeedProvider.RenderingInfo ri = null;
if (e != null) {
if (getData().isPassThrough()) {
for (FeedProvider fp : providers) {
if (fp.getSubscriptionId().equals(getData().getPassThroughParameterId())) {
List<Map<String,String>> values = data.get(getData().getPassThroughParameterId());
if (values != null && !values.isEmpty()) {
ri = fp.getRenderingInfo(values.get(values.size() - 1));
}
}
}
} else {
ri = e.evaluate(data, providers);
if (ri == null) {
ri = new FeedProvider.RenderingInfo(getData().getFallThroughDisplayValue(), Color.red, "", Color.red, false);
}
}
} else {