@JsonCreator public AnnotationDescriptor( @JsonProperty("annotationType") String annotationType, @JsonProperty("attributes") List<AttributeDescriptor> attributes) { this.annotationType = annotationType; this.attributes = Collections.unmodifiableList(attributes); ImmutableMap.Builder<String, AttributeDescriptor> mapBuilder = ImmutableMap.builder(); for (AttributeDescriptor att : attributes) { mapBuilder.put(att.getName(), att); } this.attributeMap = mapBuilder.build(); }
/** * Returns a new instance of {@link ImmutableMap} with key case-insensitivity. This map is built from the given * map. See {@link ImmutableMap}. * * @param map map to copy from * @param <VALUE> type of values to be stored in the map * @return key case-insensitive immutable map */ public static <VALUE> CaseInsensitiveMap<VALUE> newImmutableMap(final Map<? extends String, ? extends VALUE> map) { final ImmutableMap.Builder<String, VALUE> builder = ImmutableMap.builder(); for (final Entry<? extends String, ? extends VALUE> entry : map.entrySet()) { builder.put(entry.getKey().toLowerCase(), entry.getValue()); } return new CaseInsensitiveMap<>(builder.build()); }
static Map<String, AnnotationDescriptor> buildAnnotationsMap(List<AnnotationDescriptor> annotations) { ImmutableMap.Builder<String, AnnotationDescriptor> annMapBuilder = ImmutableMap.builder(); for (AnnotationDescriptor ann : annotations) { annMapBuilder.put(ann.getAnnotationType(), ann); } return annMapBuilder.build(); }
public List<KafkaPartitionScanSpec> parseTree() { ImmutableMap.Builder<TopicPartition, KafkaPartitionScanSpec> builder = ImmutableMap.builder(); for(KafkaPartitionScanSpec scanSpec : groupScan.getPartitionScanSpecList()) { builder.put(new TopicPartition(scanSpec.getTopicName(), scanSpec.getPartitionId()), scanSpec); } fullScanSpec = builder.build(); List<KafkaPartitionScanSpec> pushdownSpec = le.accept(this, null); /* Non-existing / invalid partitions may result in empty scan spec. This results in a "ScanBatch" with no reader. DRILL currently requires at least one reader to be present in a scan batch. */ if(pushdownSpec != null && pushdownSpec.isEmpty()) { TopicPartition firstPartition = new TopicPartition(groupScan.getKafkaScanSpec().getTopicName(), 0); KafkaPartitionScanSpec emptySpec = new KafkaPartitionScanSpec(firstPartition.topic(),firstPartition.partition(), fullScanSpec.get(firstPartition).getEndOffset(), fullScanSpec.get(firstPartition).getEndOffset()); pushdownSpec.add(emptySpec); } return pushdownSpec; }
@JsonCreator public AnnotationDescriptor( @JsonProperty("annotationType") String annotationType, @JsonProperty("attributes") List<AttributeDescriptor> attributes) { this.annotationType = annotationType; this.attributes = Collections.unmodifiableList(attributes); ImmutableMap.Builder<String, AttributeDescriptor> mapBuilder = ImmutableMap.builder(); for (AttributeDescriptor att : attributes) { mapBuilder.put(att.getName(), att); } this.attributeMap = mapBuilder.build(); }
/** * Returns a new instance of {@link ImmutableMap} with key case-insensitivity. This map is built from the given * map. See {@link ImmutableMap}. * * @param map map to copy from * @param <VALUE> type of values to be stored in the map * @return key case-insensitive immutable map */ public static <VALUE> CaseInsensitiveMap<VALUE> newImmutableMap(final Map<? extends String, ? extends VALUE> map) { final ImmutableMap.Builder<String, VALUE> builder = ImmutableMap.builder(); for (final Entry<? extends String, ? extends VALUE> entry : map.entrySet()) { builder.put(entry.getKey().toLowerCase(), entry.getValue()); } return new CaseInsensitiveMap<>(builder.build()); }
/** * Parses a serialized trie representation of a map of reversed public suffixes into an immutable * map of public suffixes. */ static ImmutableMap<String, PublicSuffixType> parseTrie(CharSequence encoded) { ImmutableMap.Builder<String, PublicSuffixType> builder = ImmutableMap.builder(); int encodedLen = encoded.length(); int idx = 0; while (idx < encodedLen) { idx += doParseTrieToBuilder( Lists.<CharSequence>newLinkedList(), encoded.subSequence(idx, encodedLen), builder); } return builder.build(); }
/** * Creates an {@code ImmutableMap<String, String>} from a {@code Properties} * instance. Properties normally derive from {@code Map<Object, Object>}, but * they typically contain strings, which is awkward. This method lets you get * a plain-old-{@code Map} out of a {@code Properties}. * * @param properties a {@code Properties} object to be converted * @return an immutable map containing all the entries in {@code properties} * @throws ClassCastException if any key in {@code Properties} is not a {@code * String} * @throws NullPointerException if any key or value in {@code Properties} is * null */ @GwtIncompatible // java.util.Properties public static ImmutableMap<String, String> fromProperties(Properties properties) { ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); for (Enumeration<?> e = properties.propertyNames(); e.hasMoreElements(); ) { String key = (String) e.nextElement(); builder.put(key, properties.getProperty(key)); } return builder.build(); }
static Map<String, AnnotationDescriptor> buildAnnotationsMap(List<AnnotationDescriptor> annotations) { ImmutableMap.Builder<String, AnnotationDescriptor> annMapBuilder = ImmutableMap.builder(); for (AnnotationDescriptor ann : annotations) { annMapBuilder.put(ann.getAnnotationType(), ann); } return annMapBuilder.build(); }
/** Returns a new {@code TypeResolver} with {@code variable} mapping to {@code type}. */ final TypeTable where(Map<TypeVariableKey, ? extends Type> mappings) { ImmutableMap.Builder<TypeVariableKey, Type> builder = ImmutableMap.builder(); builder.putAll(map); for (Map.Entry<TypeVariableKey, ? extends Type> mapping : mappings.entrySet()) { TypeVariableKey variable = mapping.getKey(); Type type = mapping.getValue(); checkArgument(!variable.equalsType(type), "Type variable %s bound to itself", variable); builder.put(variable, type); } return new TypeTable(builder.build()); }
private static <N> ImmutableMap<N, GraphConnections<N, Presence>> getNodeConnections( Graph<N> graph) { // ImmutableMap.Builder maintains the order of the elements as inserted, so the map will have // whatever ordering the graph's nodes do, so ImmutableSortedMap is unnecessary even if the // input nodes are sorted. ImmutableMap.Builder<N, GraphConnections<N, Presence>> nodeConnections = ImmutableMap.builder(); for (N node : graph.nodes()) { nodeConnections.put(node, connectionsOf(graph, node)); } return nodeConnections.build(); }
throw new InvalidObjectException("Invalid key count " + keyCount); ImmutableMap.Builder<Object, ImmutableList<Object>> builder = ImmutableMap.builder(); int tmpSize = 0;
private static <N, E> Map<N, NetworkConnections<N, E>> getNodeConnections(Network<N, E> network) { // ImmutableMap.Builder maintains the order of the elements as inserted, so the map will have // whatever ordering the network's nodes do, so ImmutableSortedMap is unnecessary even if the // input nodes are sorted. ImmutableMap.Builder<N, NetworkConnections<N, E>> nodeConnections = ImmutableMap.builder(); for (N node : network.nodes()) { nodeConnections.put(node, connectionsOf(network, node)); } return nodeConnections.build(); }
private static <N, V> ImmutableMap<N, GraphConnections<N, V>> getNodeConnections( ValueGraph<N, V> graph) { // ImmutableMap.Builder maintains the order of the elements as inserted, so the map will have // whatever ordering the graph's nodes do, so ImmutableSortedMap is unnecessary even if the // input nodes are sorted. ImmutableMap.Builder<N, GraphConnections<N, V>> nodeConnections = ImmutableMap.builder(); for (N node : graph.nodes()) { nodeConnections.put(node, connectionsOf(graph, node)); } return nodeConnections.build(); }
Iterator<V> values, Function<? super V, K> keyFunction) { checkNotNull(keyFunction); ImmutableMap.Builder<K, V> builder = ImmutableMap.builder(); while (values.hasNext()) { V value = values.next();
throw new InvalidObjectException("Invalid key count " + keyCount); ImmutableMap.Builder<Object, ImmutableSet<Object>> builder = ImmutableMap.builder(); int tmpSize = 0;
private static <N, E> Map<E, N> getEdgeToReferenceNode(Network<N, E> network) { // ImmutableMap.Builder maintains the order of the elements as inserted, so the map will have // whatever ordering the network's edges do, so ImmutableSortedMap is unnecessary even if the // input edges are sorted. ImmutableMap.Builder<E, N> edgeToReferenceNode = ImmutableMap.builder(); for (E edge : network.edges()) { edgeToReferenceNode.put(edge, network.incidentNodes(edge).nodeU()); } return edgeToReferenceNode.build(); }
private static Map<String, Object> createModel(final boolean authEnabled, final SecurityContext sc, final boolean showControls, final Object pageModel) { final boolean isAdmin = !authEnabled /* when auth is disabled every user is an admin user */ || (showControls && sc.isUserInRole(DrillUserPrincipal.ADMIN_ROLE)); final boolean isUserLoggedIn = AuthDynamicFeature.isUserLoggedIn(sc); final ImmutableMap.Builder<String, Object> mapBuilder = ImmutableMap.<String, Object>builder() .put("showStorage", isAdmin) .put("showOptions", isAdmin) .put("showThreads", isAdmin) .put("showLogs", isAdmin) .put("showLogin", authEnabled && showControls && !isUserLoggedIn) .put("showLogout", authEnabled && showControls && isUserLoggedIn) .put("loggedInUserName", authEnabled && showControls && isUserLoggedIn ? sc.getUserPrincipal().getName() : DrillUserPrincipal.ANONYMOUS_USER).put("showControls", showControls); if (pageModel != null) { mapBuilder.put("model", pageModel); } return mapBuilder.build(); } }
.<VectorAccessible, BatchReference>builder() .put(left, new BatchReference("leftBatch", "leftIndex")) .put(rightContainer, new BatchReference("rightContainer", "rightBatchIndex", "rightRecordIndexWithinBatch"))