List of usage examples for com.google.common.collect Maps asMap
@GwtIncompatible("NavigableMap") public static <K, V> NavigableMap<K, V> asMap(NavigableSet<K> set, Function<? super K, V> function)
From source file:com.palantir.atlasdb.transaction.impl.SweepStrategyManagers.java
private static RecomputingSupplier<Map<String, SweepStrategy>> getConservativeManager( final KeyValueService kvs) { return RecomputingSupplier.create(new Supplier<Map<String, SweepStrategy>>() { @Override/*from w w w. j a v a 2 s.co m*/ public Map<String, SweepStrategy> get() { Set<String> tables = kvs.getAllTableNames(); return Maps.asMap(tables, Functions.constant(SweepStrategy.CONSERVATIVE)); } }); }
From source file:de.bund.bfr.knime.gis.BackwardUtils.java
public static Map<String, Map<String, Point2D>> toOldCollapseFormat(Map<String, Set<String>> map) { Map<String, Map<String, Point2D>> result = new LinkedHashMap<>(); map.forEach((key, value) -> result.put(key, new LinkedHashMap<>(Maps.asMap(value, Functions.constant((Point2D) null))))); return result; }
From source file:com.googlecode.blaisemath.graph.GraphMetrics.java
/** * Returns metric values associated with ndoes in the graph. * @param <N> node type/*from w w w .j a v a 2 s . co m*/ * @param <T> value type * @param graph the graph * @param metric metric used to generate values * @return distribution of values */ public static <N, T> Map<N, T> computeValues(Graph<N> graph, GraphNodeMetric<T> metric) { return Maps.asMap(graph.nodes(), asFunction(graph, metric)); }
From source file:com.palantir.atlasdb.transaction.impl.ConflictDetectionManagers.java
private static RecomputingSupplier<Map<String, ConflictHandler>> getNoConflictDetectSupplier( final KeyValueService kvs) { return RecomputingSupplier.create(new Supplier<Map<String, ConflictHandler>>() { @Override//from w w w . j av a2s.c o m public Map<String, ConflictHandler> get() { Set<String> tables = kvs.getAllTableNames(); return Maps.asMap(tables, Functions.constant(ConflictHandler.IGNORE_ALL)); } }); }
From source file:de.bund.bfr.knime.nls.NlsUtils.java
public static Map<String, Double> createZeroMap(Collection<String> keys) { return new LinkedHashMap<>(Maps.asMap(new LinkedHashSet<>(keys), Functions.constant(0.0))); }
From source file:com.android.builder.files.IncrementalRelativeFileSets.java
/** * Reads a directory and adds all files in the directory in a new incremental relative set. * The status of each file is set to {@link FileStatus#NEW}. This method is used to construct * an initial set of files and is, therefore, an incremental update from zero. * * @param directory the directory, must be an existing directory * @return the file set/* w w w . j av a 2s .com*/ */ @NonNull public static ImmutableMap<RelativeFile, FileStatus> fromDirectory(@NonNull File directory) { Preconditions.checkArgument(directory.isDirectory(), "!directory.isDirectory()"); Set<RelativeFile> files = RelativeFiles.fromDirectory(directory); files = Sets.filter(files, Predicates.compose(Files.isFile(), RelativeFile.EXTRACT_FILE)); Map<RelativeFile, FileStatus> map = Maps.asMap(files, Functions.constant(FileStatus.NEW)); return ImmutableMap.copyOf(map); }
From source file:com.google.cloud.bigtable.grpc.UnaryCallRetryInterceptor.java
public UnaryCallRetryInterceptor(Channel delegate, ScheduledExecutorService executorService, Set<MethodDescriptor<?, ?>> retriableMethods, int initialBackoffMillis, double backoffMultiplier, int maxElapsedBackoffMillis) { this(delegate, executorService, Maps.asMap(retriableMethods, new Function<MethodDescriptor<?, ?>, Predicate<?>>() { @Override/* w w w. jav a 2 s. com*/ public Predicate<Object> apply(MethodDescriptor<?, ?> methodDescriptor) { return Predicates.alwaysTrue(); } }), initialBackoffMillis, backoffMultiplier, maxElapsedBackoffMillis); }
From source file:edu.uci.ics.jung.visualization.layout.PersistentLayoutImpl.java
/** * create an instance with a passed layout * create containers for graph components * @param layout the layout whose positions are to be persisted */// w w w .j a v a2s . c om public PersistentLayoutImpl(Layout<V, E> layout) { super(layout); this.locations = Maps.asMap(ImmutableSet.copyOf(layout.getGraph().getVertices()), new RandomPointFactory<V>(getSize())); this.dontmove = new HashSet<V>(); }
From source file:com.stackframe.sarariman.projects.ProjectsImpl.java
public Map<? extends Number, Project> getMap() { Function<Number, Project> f = new Function<Number, Project>() { public Project apply(Number n) { return get(n.intValue()); }//from ww w . j a v a 2s . c o m }; return Maps.asMap(Numbers.positiveIntegers, f); }
From source file:com.stackframe.sarariman.taskassignments.TaskAssignmentsImpl.java
public Map<Employee, Map<Task, TaskAssignment>> getMap() { return Maps.asMap(directory.getEmployees(), new Function<Employee, Map<Task, TaskAssignment>>() { public Map<Task, TaskAssignment> apply(final Employee e) { return e.getTaskAssignments(); }/* w ww . j av a 2 s.co m*/ }); }