本文整理汇总了Java中com.google.common.base.Functions.constant方法的典型用法代码示例。如果您正苦于以下问题:Java Functions.constant方法的具体用法?Java Functions.constant怎么用?Java Functions.constant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.base.Functions
的用法示例。
在下文中一共展示了Functions.constant方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connectionsOf
import com.google.common.base.Functions; //导入方法依赖的package包/类
private static <N> GraphConnections<N, Presence> connectionsOf(Graph<N> graph, N node) {
Function<Object, Presence> edgeValueFn = Functions.constant(Presence.EDGE_EXISTS);
return graph.isDirected()
? DirectedGraphConnections.ofImmutable(
graph.predecessors(node), Maps.asMap(graph.successors(node), edgeValueFn))
: UndirectedGraphConnections.ofImmutable(
Maps.asMap(graph.adjacentNodes(node), edgeValueFn));
}
示例2: DaemonIdleTimeoutExpirationStrategy
import com.google.common.base.Functions; //导入方法依赖的package包/类
public DaemonIdleTimeoutExpirationStrategy(Daemon daemon, int idleTimeout, TimeUnit timeUnit) {
this(daemon, Functions.constant(timeUnit.toMillis(idleTimeout)));
}
示例3: good
import com.google.common.base.Functions; //导入方法依赖的package包/类
public static Object good(AnInterface s) {
return Functions.constant(s);
}
示例4: getZeroPayment
import com.google.common.base.Functions; //导入方法依赖的package包/类
public static <T extends Good> Payment<T> getZeroPayment(Set<Bidder<T>> bidders) {
BidderPayment zeroBidderPayment = new BidderPayment(0);
Function<Object, BidderPayment> zeroPaymentFunction = Functions.constant(zeroBidderPayment);
Map<Bidder<T>, BidderPayment> emptyPaymentMap = Maps.asMap(bidders, zeroPaymentFunction);
return new Payment<T>(emptyPaymentMap);
}
示例5: constant
import com.google.common.base.Functions; //导入方法依赖的package包/类
private static <T> Function<T, Object> constant(Object value) {
//noinspection unchecked
return (Function<T, Object>) Functions.constant(value);
}
示例6: MySpringLayout
import com.google.common.base.Functions; //导入方法依赖的package包/类
/**
* Constructor for a SpringLayout for a raw graph with associated
* dimension--the input knows how big the graph is. Defaults to the unit
* length function.
* @param g the graph on which the layout algorithm is to operate
*/
@SuppressWarnings("unchecked")
public MySpringLayout(Graph<V,E> g) {
this(g, (Function<E,Integer>) Functions.<Integer>constant(30));
}