List of usage examples for com.google.common.collect ImmutableList of
public static <E> ImmutableList<E> of(E element)
From source file:org.apache.beam.runners.spark.aggregators.SparkAggregators.java
private static <T> AggregatorValues<T> valueOf(final Accumulator<NamedAggregators> accum, final Aggregator<?, T> aggregator) { @SuppressWarnings("unchecked") Class<T> valueType = (Class<T>) aggregator.getCombineFn().getOutputType().getRawType(); final T value = valueOf(accum, aggregator.getName(), valueType); return new AggregatorValues<T>() { @Override//from w w w . jav a 2 s .c o m public Collection<T> getValues() { return ImmutableList.of(value); } @Override public Map<String, T> getValuesAtSteps() { throw new UnsupportedOperationException("getValuesAtSteps is not supported."); } }; }
From source file:com.android.tools.idea.uibuilder.handlers.ImageSwitcherHandler.java
@Override @NotNull public List<String> getInspectorProperties() { return ImmutableList.of(ATTR_STYLE); }
From source file:de.rdk.addressbook.Car.java
public Validator<String> licensePlateValidator() { return new Validator<String>() { @Override/*ww w .j a v a2 s. c o m*/ public ImmutableList<Validator.Violation> validate(String value) { boolean valid = LICENSE_PLATE_PATTERN.matcher(value).matches(); if (!valid) { return ImmutableList.of(new Validator.Violation("License plate invalid")); } else { return ImmutableList.of(); } } }; }
From source file:com.facebook.buck.apple.xcode.xcconfig.TokenValue.java
public static TokenValue interpolation(String name) { return interpolation(ImmutableList.of(TokenValue.literal(name))); }
From source file:org.thelq.pircbotx.commands.ListenerUtils.java
public static void addHistory(Event event, Stats.HistoryType type, Channel channel, User user, String message) { addHistory(event, type, channel != null ? ImmutableList.of(channel) : ImmutableList.<Channel>of(), user != null ? ImmutableList.of(user) : ImmutableList.<User>of(), message); }
From source file:com.facebook.presto.execution.scheduler.FlatNetworkTopology.java
@Override public List<String> getLocationSegmentNames() { return ImmutableList.of("machine"); }
From source file:com.google.idea.blaze.base.wizard2.BazelWizardOptionProvider.java
@Override public Collection<BlazeSelectWorkspaceOption> getSelectWorkspaceOptions(BlazeNewProjectBuilder builder) { return ImmutableList.of(new UseExistingBazelWorkspaceOption(builder)); }
From source file:com.facebook.presto.hdfs.HDFSPlugin.java
@Override public Iterable<ConnectorFactory> getConnectorFactories() { return ImmutableList.of(new HDFSConnectorFactory()); }
From source file:com.google.devtools.build.lib.util.FileType.java
public static FileType of(final String ext) { return new FileType() { @Override/*from w ww.ja va 2s .co m*/ public boolean apply(String filename) { return filename.endsWith(ext); } @Override public List<String> getExtensions() { return ImmutableList.of(ext); } }; }
From source file:dagger.internal.codegen.DaggerGraphs.java
/** * Returns a shortest path from {@code nodeU} to {@code nodeV} in {@code graph} as a list of the * nodes visited in sequence, including both {@code nodeU} and {@code nodeV}. (Note that there may * be many possible shortest paths.)/*from www . ja v a 2s. c om*/ * * <p>If {@code nodeV} is not {@link * com.google.common.graph.Graphs#reachableNodes(com.google.common.graph.Graph, Object) reachable} * from {@code nodeU}, the list returned is empty. * * @throws IllegalArgumentException if {@code nodeU} or {@code nodeV} is not present in {@code * graph} */ public static <N> ImmutableList<N> shortestPath(SuccessorsFunction<N> graph, N nodeU, N nodeV) { if (nodeU.equals(nodeV)) { return ImmutableList.of(nodeU); } Set<N> successors = ImmutableSet.copyOf(graph.successors(nodeU)); if (successors.contains(nodeV)) { return ImmutableList.of(nodeU, nodeV); } Map<N, N> visitedNodeToPathPredecessor = new HashMap<>(); // encodes shortest path tree for (N node : successors) { visitedNodeToPathPredecessor.put(node, nodeU); } Queue<N> currentNodes = new ArrayDeque<N>(successors); Queue<N> nextNodes = new ArrayDeque<N>(); // Perform a breadth-first traversal starting with the successors of nodeU. while (!currentNodes.isEmpty()) { while (!currentNodes.isEmpty()) { N currentNode = currentNodes.remove(); for (N nextNode : graph.successors(currentNode)) { if (visitedNodeToPathPredecessor.containsKey(nextNode)) { continue; // we already have a shortest path to nextNode } visitedNodeToPathPredecessor.put(nextNode, currentNode); if (nextNode.equals(nodeV)) { ImmutableList.Builder<N> builder = ImmutableList.builder(); N node = nodeV; builder.add(node); while (!node.equals(nodeU)) { node = visitedNodeToPathPredecessor.get(node); builder.add(node); } return builder.build().reverse(); } nextNodes.add(nextNode); } } Queue<N> emptyQueue = currentNodes; currentNodes = nextNodes; nextNodes = emptyQueue; // reusing empty queue faster than allocating new one } return ImmutableList.of(); }