use of uk.gov.gchq.koryphe.binaryoperator.AdaptedBinaryOperator in project Gaffer by gchq.
the class AggregateValidator method validateElementAggregator.
private ValidationResult validateElementAggregator(final Map.Entry<String, ?> entry, final Schema schema) {
final ValidationResult result = new ValidationResult();
List<TupleAdaptedBinaryOperator<String, ?>> aggregateFunctions = new ArrayList<>();
final SchemaElementDefinition schemaElement = schema.getElement(entry.getKey());
if (null != schemaElement) {
aggregateFunctions = schemaElement.getOriginalAggregateFunctions();
}
List<BinaryOperator<?>> schemaOperators = new ArrayList<>();
if (null != aggregateFunctions) {
schemaOperators = Streams.toStream(aggregateFunctions).map(AdaptedBinaryOperator::getBinaryOperator).collect(Collectors.toList());
}
if (schemaOperators.contains(null)) {
result.addError("Schema contains an ElementAggregator with a null function.");
}
final AggregatePair pair = (AggregatePair) entry.getValue();
final ElementAggregator aggregator = pair.getElementAggregator();
if (null != aggregator && null != aggregator.getComponents()) {
for (final TupleAdaptedBinaryOperator<String, ?> adaptedFunction : aggregator.getComponents()) {
if (null == adaptedFunction.getBinaryOperator()) {
result.addError(aggregator.getClass().getSimpleName() + " contains a null function.");
}
}
}
return result;
}
Aggregations