本文整理汇总了Java中uk.gov.gchq.koryphe.tuple.binaryoperator.TupleAdaptedBinaryOperator.getBinaryOperator方法的典型用法代码示例。如果您正苦于以下问题:Java TupleAdaptedBinaryOperator.getBinaryOperator方法的具体用法?Java TupleAdaptedBinaryOperator.getBinaryOperator怎么用?Java TupleAdaptedBinaryOperator.getBinaryOperator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uk.gov.gchq.koryphe.tuple.binaryoperator.TupleAdaptedBinaryOperator
的用法示例。
在下文中一共展示了TupleAdaptedBinaryOperator.getBinaryOperator方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldJsonSerialiseAndDeserialise
import uk.gov.gchq.koryphe.tuple.binaryoperator.TupleAdaptedBinaryOperator; //导入方法依赖的package包/类
@Test
public void shouldJsonSerialiseAndDeserialise() throws IOException {
TupleAdaptedBinaryOperator<String, Integer> binaryOperator = new TupleAdaptedBinaryOperator<>();
MockBinaryOperator function = new MockBinaryOperator();
TupleInputAdapter<String, Integer> inputAdapter = new TupleInputAdapter();
binaryOperator.setInputAdapter(inputAdapter);
binaryOperator.setBinaryOperator(function);
String json = JsonSerialiser.serialise(binaryOperator);
TupleAdaptedBinaryOperator<String, Integer> deserialisedBinaryOperator = JsonSerialiser.deserialise(json, TupleAdaptedBinaryOperator.class);
// check deserialisation
assertNotSame(binaryOperator, deserialisedBinaryOperator);
BinaryOperator<Integer> deserialisedFunction = deserialisedBinaryOperator.getBinaryOperator();
assertNotSame(function, deserialisedFunction);
assertTrue(deserialisedFunction instanceof MockBinaryOperator);
Function<Tuple<String>, Integer> deserialisedInputMask = deserialisedBinaryOperator.getInputAdapter();
assertNotSame(inputAdapter, deserialisedInputMask);
assertTrue(deserialisedInputMask instanceof Function);
}
示例2: validateFunctionArgumentTypes
import uk.gov.gchq.koryphe.tuple.binaryoperator.TupleAdaptedBinaryOperator; //导入方法依赖的package包/类
protected ValidationResult validateFunctionArgumentTypes(
final ElementAggregator aggregator,
final SchemaElementDefinition schemaElDef) {
final ValidationResult result = new ValidationResult();
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.");
} else {
final Signature inputSig = Signature.getInputSignature(adaptedFunction.getBinaryOperator());
result.add(inputSig.assignable(getTypeClasses(adaptedFunction.getSelection(), schemaElDef)));
final Signature outputSig = Signature.getOutputSignature(adaptedFunction.getBinaryOperator());
result.add(outputSig.assignable(getTypeClasses(adaptedFunction.getSelection(), schemaElDef)));
}
}
}
return result;
}
示例3: validateFunctionArgumentTypes
import uk.gov.gchq.koryphe.tuple.binaryoperator.TupleAdaptedBinaryOperator; //导入方法依赖的package包/类
private ValidationResult validateFunctionArgumentTypes(
final ElementAggregator aggregator,
final ViewElementDefinition viewElDef, final SchemaElementDefinition schemaElDef) {
final ValidationResult result = new ValidationResult();
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.");
} else {
final Class[] inputTypeClasses = getTypeClasses(adaptedFunction.getSelection(), viewElDef, schemaElDef);
if (!ArrayUtils.contains(inputTypeClasses, null)) {
final Signature inputSig = Signature.getInputSignature(adaptedFunction.getBinaryOperator());
result.add(inputSig.assignable(inputTypeClasses));
}
}
}
}
return result;
}
示例4: validateElementAggregator
import uk.gov.gchq.koryphe.tuple.binaryoperator.TupleAdaptedBinaryOperator; //导入方法依赖的package包/类
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;
}
示例5: validateAggregatePropertyClasses
import uk.gov.gchq.koryphe.tuple.binaryoperator.TupleAdaptedBinaryOperator; //导入方法依赖的package包/类
/**
* Validates that the binary operators to be executed are assignable to the corresponding non-transient properties
*
* @param elementDef The SchemaElementDefinition to validate against
* @param pair AggregatePair, containing a String array of groupBy properties, and an ElementAggregator
* @return ValidationResult of the validation
*/
private ValidationResult validateAggregatePropertyClasses(final SchemaElementDefinition elementDef, final AggregatePair pair) {
final ValidationResult result = new ValidationResult();
if (null != elementDef) {
final ElementAggregator aggregator = pair.getElementAggregator();
if (null != aggregator) {
final List<TupleAdaptedBinaryOperator<String, ?>> components = aggregator.getComponents();
for (final TupleAdaptedBinaryOperator<String, ?> component : components) {
final String[] selection = component.getSelection();
final Class[] selectionClasses = Arrays.stream(selection).map(elementDef::getPropertyClass).toArray(Class[]::new);
final Map<String, String> properties = elementDef.getPropertyMap();
if (!properties.isEmpty()) {
if (null == component.getBinaryOperator()) {
result.addError(aggregator.getClass().getSimpleName() + " contains a null function.");
}
for (int i = 0; i < selectionClasses.length; i++) {
if (properties.containsKey(selection[i])) {
final Signature inputSig = Signature.getInputSignature(component.getBinaryOperator());
result.add(inputSig.assignable(selectionClasses[i]));
}
}
}
}
}
}
return result;
}