org.apache.edgent.function.Function.apply()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(146)

本文整理了Java中org.apache.edgent.function.Function.apply()方法的一些代码示例,展示了Function.apply()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Function.apply()方法的具体详情如下:
包路径:org.apache.edgent.function.Function
类名称:Function
方法名:apply

Function.apply介绍

[英]Apply a function to value.
[中]对值应用函数。

代码示例

代码示例来源:origin: org.apache.plc4x/apache-edgent

@Override
  public void accept(JsonObject jsonObject) {
    String fieldQuery = fieldQueryFn.apply(jsonObject);
    Object fieldValue = fieldValueFn.apply(jsonObject);
    write(clientDatatype, fieldQuery, fieldValue);
  }
}

代码示例来源:origin: org.apache.edgent/edgent-connectors-kafka

@Override
public void accept(T t) {
  String topic = topicFn.apply(t);
  Integer partition = partitionFn.apply(t);
  byte[] key = keyFn.apply(t);
  byte[] value = valueFn.apply(t);
  ProducerRecord<byte[],byte[]> rec = new ProducerRecord<>(
      topic, partition, key, value);
  trace.trace("{} sending rec to topic:{} partition:{}", id(), topic, partition);
  
  // TODO add callback for trace of actual completion?
  
  connector.client().send(rec);  // async; doesn't throw
}

代码示例来源:origin: apache/incubator-edgent

@Override
  public void accept(JsonObject event) {
    connector.publishDeviceEvent(fqDeviceId.apply(event), eventId.apply(event), payload.apply(event), qos.apply(event));
  }
}

代码示例来源:origin: apache/incubator-edgent

@Override
public void accept(T t) {
  String topic = topicFn.apply(t);
  Integer partition = partitionFn.apply(t);
  byte[] key = keyFn.apply(t);
  byte[] value = valueFn.apply(t);
  ProducerRecord<byte[],byte[]> rec = new ProducerRecord<>(
      topic, partition, key, value);
  trace.trace("{} sending rec to topic:{} partition:{}", id(), topic, partition);
  
  // TODO add callback for trace of actual completion?
  
  connector.client().send(rec);  // async; doesn't throw
}

代码示例来源:origin: org.apache.edgent/edgent-api-oplet

@Override
public void accept(I tuple) {
  O output = function.apply(tuple);
  if (output != null)
    submit(output);
}

代码示例来源:origin: apache/incubator-edgent

@Override
public void accept(I tuple) {
  O output = function.apply(tuple);
  if (output != null)
    submit(output);
}

代码示例来源:origin: apache/incubator-edgent

@Override
  public void accept(JsonObject event) {
    connector.publishEvent(eventId.apply(event), payload.apply(event), qos.apply(event));
  }
}

代码示例来源:origin: apache/incubator-edgent

private void pre(String pathname, Consumer<String> dst) {
  String preStr = preFn.apply(pathname);
  if (preStr != null)
    dst.accept(preStr);
}

代码示例来源:origin: org.apache.edgent/edgent-api-function

@Override
  public R apply(T value) {
    final Function<T,R> function = f();
    synchronized (function) {
      return function.apply(value);
    }
  }
}

代码示例来源:origin: apache/incubator-edgent

@Override
public void accept(I tuple) {
  Iterable<O> outputs = function.apply(tuple);
  if (outputs != null) {
    for (O output : outputs) {
      if (output != null)
        submit(output);
    }
  }
}

代码示例来源:origin: org.apache.edgent/edgent-api-oplet

@Override
public void accept(I tuple) {
  Iterable<O> outputs = function.apply(tuple);
  if (outputs != null) {
    for (O output : outputs) {
      if (output != null)
        submit(output);
    }
  }
}

代码示例来源:origin: apache/incubator-edgent

@Override
  public R apply(T value) {
    final Function<T,R> function = f();
    synchronized (function) {
      return function.apply(value);
    }
  }
}

代码示例来源:origin: apache/incubator-edgent

@Override
public void accept(T value) {
  byte[] msg = msgFn.apply(value);
  try {
    connector.channel().basicPublish("", queue, null, msg);
  } catch (IOException e) {
    logger.error("publish exception : {}", e);
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: apache/incubator-edgent

@Override
  public void accept(JsonObject event) {
    connector.publishHttpEvent(eventId.apply(event), payload.apply(event));
  }
}

代码示例来源:origin: apache/incubator-edgent

@Test
public void testValueOfBoolean() {
 JsonObject joTrue = JsonFunctions.valueOfBoolean("propName").apply(true);
 assertEquals(true, joTrue.get("propName").getAsBoolean());
 JsonObject joFalse = JsonFunctions.valueOfBoolean("propName").apply(false);
 assertEquals(false, joFalse.get("propName").getAsBoolean());
}

代码示例来源:origin: apache/incubator-edgent

@Test
public void testZero() {
  String s = "hello";
  assertEquals(Integer.valueOf(0), zero().apply(s));
  
  Integer i = 42;
  assertEquals(Integer.valueOf(0), zero().apply(i));
  
  Object o = new Object();
  assertEquals(Integer.valueOf(0), zero().apply(o));
}
@Test

代码示例来源:origin: apache/incubator-edgent

@Test
public void testValueOfString() {
 JsonObject jo = JsonFunctions.valueOfString("propName").apply("str1");
 assertEquals("str1", jo.get("propName").getAsString());
}

代码示例来源:origin: apache/incubator-edgent

@Test
public void testUnpartitioned() {
  Function<JsonObject,JsonElement> unpartitionedFn = JsonFunctions.unpartitioned();
  assertEquals(0, unpartitionedFn.apply(new JsonObject()).getAsInt());
}

代码示例来源:origin: apache/incubator-edgent

@Test
public void testStrings() {
  JsonObject jo1 = newTestObject();
  Function<JsonObject,String> asString = JsonFunctions.asString();
  Function<String,JsonObject> fromString = JsonFunctions.fromString();
  
  String s1 = asString.apply(jo1);
  JsonObject jo2 = fromString.apply(s1);
  
  assertEquals(jo2, jo1);
}

代码示例来源:origin: apache/incubator-edgent

@Test
  public void testValueOfCharacter() {
   JsonObject jo = JsonFunctions.valueOfCharacter("propName").apply('c');
   assertEquals('c', jo.get("propName").getAsCharacter());
  }
}

相关文章