本文整理了Java中com.google.common.base.Function
类的一些代码示例,展示了Function
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Function
类的具体详情如下:
包路径:com.google.common.base.Function
类名称:Function
[英]Legacy version of java.util.function.Function.
The Functions class provides common functions and related utilities.
As this interface extends java.util.function.Function, an instance of this type can be used as a java.util.function.Function directly. To use a java.util.function.Function in a context where a com.google.common.base.Function is needed, use function::apply.
This interface is now a legacy type. Use java.util.function.Function (or the appropriate primitive specialization such as ToIntFunction) instead whenever possible. Otherwise, at least reduce explicit dependencies on this type by using lambda expressions or method references instead of classes, leaving your code easier to migrate in the future.
See the Guava User Guide article on the use of Function.
[中]java的遗留版本。util。作用作用
Functions类提供常用函数和相关实用程序。
因为这个接口扩展了java。util。作用函数,此类型的实例可以用作java。util。作用直接起作用。使用java。util。作用函数在com。谷歌。常见的基础如果需要函数,请使用Function::apply。
此接口现在是一种遗留类型。使用java。util。作用函数(或适当的原语专门化,如ToIntFunction),只要有可能。否则,至少可以通过使用lambda表达式或方法引用而不是类来减少对该类型的显式依赖,从而使代码在将来更易于迁移。
请参阅关于the use of Function的Guava用户指南文章。
代码示例来源:origin: apache/incubator-druid
@Override
@Nullable
public String apply(@Nullable String value)
{
return extractionFunction.apply(value);
}
代码示例来源:origin: google/guava
@Override
public boolean equals(@Nullable Object obj) {
if (obj instanceof FunctionComposition) {
FunctionComposition<?, ?, ?> that = (FunctionComposition<?, ?, ?>) obj;
return f.equals(that.f) && g.equals(that.g);
}
return false;
}
代码示例来源:origin: google/guava
@Override
public Iterable<T> children(T root) {
return nodeToChildrenFunction.apply(root);
}
};
代码示例来源:origin: google/guava
@Override
public V2 transformEntry(K key, V1 value) {
return function.apply(value);
}
};
代码示例来源:origin: apache/incubator-druid
@Nullable
@Override
public String apply(@Nullable String dimValue)
{
final String retval = NullHandling.emptyToNullIfNeeded(extractionFunction.apply(dimValue));
return retval == null
? FunctionalExtraction.this.replaceMissingValueWith
: retval;
}
};
代码示例来源:origin: google/guava
@Override
T transform(F from) {
return function.apply(from);
}
};
代码示例来源:origin: google/guava
@Override
public boolean equals(@Nullable Object object) {
if (object instanceof FunctionBasedConverter) {
FunctionBasedConverter<?, ?> that = (FunctionBasedConverter<?, ?>) object;
return this.forwardFunction.equals(that.forwardFunction)
&& this.backwardFunction.equals(that.backwardFunction);
}
return false;
}
代码示例来源:origin: thinkaurelius/titan
@Nullable
@Override
public Condition<E> apply(@Nullable Condition<E> cond) {
if (cond.getType()== Condition.Type.LITERAL) return transformation.apply(cond);
else return null;
}
});
代码示例来源:origin: google/guava
@Override
T transform(F from) {
return function.apply(from);
}
};
代码示例来源:origin: google/guava
@Override
public boolean equals(@Nullable Object object) {
if (object == this) {
return true;
}
if (object instanceof ByFunctionOrdering) {
ByFunctionOrdering<?, ?> that = (ByFunctionOrdering<?, ?>) object;
return this.function.equals(that.function) && this.ordering.equals(that.ordering);
}
return false;
}
代码示例来源:origin: apache/incubator-druid
@Override
@Nullable
public String apply(@Nullable Object value)
{
Function<Object, String> fn = getCompiledScript();
return NullHandling.emptyToNullIfNeeded(fn.apply(value));
}
代码示例来源:origin: google/guava
@Override
protected X mapException(Exception e) {
return mapper.apply(e);
}
}
代码示例来源:origin: google/guava
@Override
public boolean equals(@Nullable Object obj) {
if (obj instanceof SupplierComposition) {
SupplierComposition<?, ?> that = (SupplierComposition<?, ?>) obj;
return function.equals(that.function) && supplier.equals(that.supplier);
}
return false;
}
代码示例来源:origin: apache/incubator-druid
@Nullable
@Override
public String apply(@Nullable String dimValue)
{
final String retval = extractionFunction.apply(dimValue);
return NullHandling.isNullOrEquivalent(retval) ? NullHandling.emptyToNullIfNeeded(dimValue) : retval;
}
};
代码示例来源:origin: google/guava
@Override
T transform(F from) {
return function.apply(from);
}
};
代码示例来源:origin: google/guava
@Override
public boolean equals(@Nullable Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof FunctionalEquivalence) {
FunctionalEquivalence<?, ?> that = (FunctionalEquivalence<?, ?>) obj;
return function.equals(that.function) && resultEquivalence.equals(that.resultEquivalence);
}
return false;
}
代码示例来源:origin: apache/incubator-druid
@Nullable
@Override
public Row apply(Row input)
{
Row preRow = preCompute.apply(input);
if (preRow instanceof MapBasedRow) {
MapBasedRow preMapRow = (MapBasedRow) preRow;
Map<String, Object> event = new HashMap<>(preMapRow.getEvent());
for (String dim : optimizedDims) {
final Object eventVal = event.get(dim);
event.put(dim, extractionFnMap.get(dim).apply(eventVal));
}
return new MapBasedRow(preMapRow.getTimestamp(), event);
} else {
return preRow;
}
}
};
代码示例来源:origin: google/guava
@Override
protected B doForward(A a) {
return forwardFunction.apply(a);
}
代码示例来源:origin: google/j2objc
@Override
public boolean equals(@NullableDecl Object object) {
if (object instanceof FunctionBasedConverter) {
FunctionBasedConverter<?, ?> that = (FunctionBasedConverter<?, ?>) object;
return this.forwardFunction.equals(that.forwardFunction)
&& this.backwardFunction.equals(that.backwardFunction);
}
return false;
}
代码示例来源:origin: apache/incubator-druid
@Nullable
@Override
public Server pick()
{
final ServiceInstance instance;
try {
instance = serviceProvider.getInstance();
}
catch (Exception e) {
log.info(e, "Exception getting instance for [%s]", name);
return null;
}
if (instance == null) {
log.error("No server instance found for [%s]", name);
return null;
}
return TO_SERVER.apply(instance);
}
内容来源于网络,如有侵权,请联系作者删除!