本文整理汇总了Java中uk.gov.gchq.koryphe.binaryoperator.KorypheBinaryOperator类的典型用法代码示例。如果您正苦于以下问题:Java KorypheBinaryOperator类的具体用法?Java KorypheBinaryOperator怎么用?Java KorypheBinaryOperator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KorypheBinaryOperator类属于uk.gov.gchq.koryphe.binaryoperator包,在下文中一共展示了KorypheBinaryOperator类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldDeserialiseFromSimpleClassNameToBinaryOperator
import uk.gov.gchq.koryphe.binaryoperator.KorypheBinaryOperator; //导入依赖的package包/类
@Test
public void shouldDeserialiseFromSimpleClassNameToBinaryOperator() throws IOException {
// Given
final String json = "{\"class\":\"TestCustomClass\"}";
// When
final KorypheBinaryOperator binaryOperator = JsonSerialiser.deserialise(json, KorypheBinaryOperator.class);
// Then
assertNotNull(binaryOperator);
}
示例2: shouldAggregateElementUsingKorypheBinaryOperator
import uk.gov.gchq.koryphe.binaryoperator.KorypheBinaryOperator; //导入依赖的package包/类
@Test
public void shouldAggregateElementUsingKorypheBinaryOperator() {
// Given
final String reference = "reference1";
final BinaryOperator<Integer> function = new KorypheBinaryOperator<Integer>() {
@Override
public Integer _apply(final Integer a, final Integer b) {
return a + b;
}
};
final ElementAggregator aggregator = new ElementAggregator.Builder()
.select(reference)
.execute(function)
.build();
final Edge edge1 = new Edge.Builder()
.property(reference, 1)
.build();
final Edge edge2 = new Edge.Builder()
.property(reference, 2)
.build();
// When
final Element result = aggregator.apply(edge1, edge2);
// Then
assertEquals(3, result.getProperty(reference));
}