本文整理匯總了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));
}