org.apache.edgent.function.Function类的使用及代码示例

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

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

Function介绍

[英]Single argument function. For example:

  • A function that doubles a value v -> v * 2
  • A function that trims a String v -> v.trim() or v -> String::trim
    [中]

代码示例

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

private String toString(Function<T,String> toStringFn) {
  // N.B. See note in classdoc wrt Guava Range behavior.
  String[] parts = { "(", "*", "*", ")" };
  if (lowerEndpoint!=null) {
    parts[0] = lbt==BoundType.CLOSED ? "[" : "(";
    parts[1] = toStringFn.apply(lowerEndpoint);
  }
  if (upperEndpoint!=null) {
    parts[2] = toStringFn.apply(upperEndpoint);
    parts[3] = ubt==BoundType.CLOSED ? "]" : ")";
  }
    
  return parts[0]+parts[1]+".."+parts[2]+parts[3];
}

代码示例来源: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 void accept(JsonObject event) {
    connector.publishGWEvent(eventId.apply(event), payload.apply(event), qos.apply(event));
  }
}

代码示例来源: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) {
  connector.sendBinary(toPayload.apply(value));
}

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

void onBinaryMessage(byte[] message) {
  eventHandler.accept(toTuple.apply(message));
}

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

@Override
public <E extends Enum<E>> EnumMap<E,TStream<T>> split(Class<E> enumClass, Function<T, E> splitter) {
  E[] es = enumClass.getEnumConstants();
  List<TStream<T>> outputs = split(es.length, t -> {
    E split = splitter.apply(t);
    return split != null ? split.ordinal() : -1;
  });
  EnumMap<E,TStream<T>> returnMap = new EnumMap<>(enumClass);
  for (E e : es) {
    returnMap.put(e, outputs.get(e.ordinal()));
  }
  return returnMap;
}

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

void onTextMessage(String message) {
  eventHandler.accept(toTuple.apply(message));
}

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

private void acceptCallback(byte[] msg) {
  T tuple = toTupleFn.apply(msg);
  eventSubmitter.accept(tuple);
}

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

@Override
public void accept(T value) {
  connector.sendText(toPayload.apply(value));
}

相关文章