List of usage examples for com.google.common.collect ImmutableMap builder
public static <K, V> Builder<K, V> builder()
From source file:org.jetbrains.android.dom.lint.IssueIdConverter.java
@NotNull public static ImmutableMap<String, Issue> getIdSet() { if (ourIssues == null) { final ImmutableMap.Builder<String, Issue> builder = ImmutableMap.builder(); for (Issue issue : new BuiltinIssueRegistry().getIssues()) { builder.put(issue.getId(), issue); }/*from ww w . ja v a 2 s . co m*/ ourIssues = builder.build(); } return ourIssues; }
From source file:com.incapture.rapgen.index.IndexFieldMapper.java
private static Map<String, String> createTypeMap() { ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); builder.put("Long", "long"); builder.put("String", "string"); builder.put("boolean", "boolean"); builder.put("Integer", "integer"); builder.put("Double", "double"); builder.put("WorkerExecutionState", "string"); builder.put("ReplyProgress", "string"); return builder.build(); }
From source file:com.mingo.parser.xml.dom.DomUtil.java
/** * Transform node attributes to map./*from www .ja v a 2 s . c o m*/ * * @param node {@link Node} * @return map : key - attribute name; value - attribute value */ public static Map<String, String> getAttributes(Node node) { Map<String, String> attributes = ImmutableMap.of(); if (node.hasAttributes()) { ImmutableMap.Builder builder = ImmutableMap.builder(); // get attributes names and values NamedNodeMap nodeMap = node.getAttributes(); for (int i = 0; i < nodeMap.getLength(); i++) { Node currentNode = nodeMap.item(i); builder.put(currentNode.getNodeName(), currentNode.getNodeValue()); } attributes = builder.build(); } return attributes; }
From source file:com.spotify.missinglink.datamodel.PrimitiveTypeDescriptor.java
private static ImmutableMap<String, PrimitiveTypeDescriptor> createMapping() { ImmutableMap.Builder<String, PrimitiveTypeDescriptor> bob = ImmutableMap.builder(); for (PrimitiveTypeDescriptor type : PrimitiveTypeDescriptor.values()) { bob.put(Character.toString(type.raw), type); }//from ww w . j av a 2 s.c om return bob.build(); }
From source file:at.ac.univie.isc.asio.tool.Beans.java
/** * Create a copy of given input properties. * * @param input source properties/* w ww . ja va 2 s . c o m*/ * @param exclude keys of properties that should be omitted * @return map of copied properties */ public static Map<String, String> copyToMap(final Properties input, final String... exclude) { final ImmutableSet<String> excluded = ImmutableSet.copyOf(exclude); final ImmutableMap.Builder<String, String> clone = ImmutableMap.builder(); for (String key : input.stringPropertyNames()) { if (!excluded.contains(key)) { clone.put(key, input.getProperty(key)); } } return clone.build(); }
From source file:ext.deployit.community.cli.plainarchive.base.UriQueryStrings.java
public static @Nonnull Map<String, String> toMap(@Nonnull String queryString) { final Builder<String, String> inProgress = ImmutableMap.builder(); for (String keyValue : Splitter.on(ATTRIBUTES_SEPARATOR).split(queryString)) { String[] keyAndValue = keyValue.split(ATTRIBUTE_KEY_VALUE_SEPARATOR); checkArgument(keyAndValue.length == 2, "Invalid query string format. Expected 'key=value&key2=value&...' but found section '%s'", keyValue);//from w w w .java2 s. co m inProgress.put(keyAndValue[0], keyAndValue[1]); } return inProgress.build(); }
From source file:io.druid.server.http.ServersResource.java
private static Map<String, Object> makeSimpleServer(DruidServer input) { return new ImmutableMap.Builder<String, Object>().put("host", input.getHost()).put("tier", input.getTier()) .put("type", input.getType()).put("priority", input.getPriority()) .put("currSize", input.getCurrSize()).put("maxSize", input.getMaxSize()).build(); }
From source file:me.lucko.luckperms.common.utils.ImmutableCollectors.java
public static <T, K, V> Collector<T, ImmutableMap.Builder<K, V>, ImmutableMap<K, V>> toImmutableMap( Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper) { return Collector.of(ImmutableMap.Builder<K, V>::new, (r, t) -> r.put(keyMapper.apply(t), valueMapper.apply(t)), (l, r) -> l.putAll(r.build()), ImmutableMap.Builder::build, Collector.Characteristics.UNORDERED); }
From source file:edu.bsu.cybersec.core.EmployeePool.java
private static ImmutableMap<EmployeeProfile, Image> makeDeveloperMap(GameAssets assets) { ImmutableMap.Builder<EmployeeProfile, Image> builder = ImmutableMap.builder(); builder.put(EmployeeProfile.firstName("Esteban").lastName("Cortez") .withDegree("Bachelors in Computer Science").from("Ball State University") .bio("Esteban worked in a factory until he was 33, then he went to college and decided to get involved in software development."), assets.getImage(GameAssets.ImageKey.ESTEBAN)); builder.put(EmployeeProfile.firstName("Nancy").lastName("Stevens").withDegree("Bachelors in English") .from("Georgetown University").withDegree("Masters in Computer Security").from("Purdue University") .bio("Nancy has a popular podcast about being a woman in technology."), assets.getImage(GameAssets.ImageKey.NANCY)); builder.put(EmployeeProfile.firstName("Jerry").lastName("Chen").withDegree("Bachelors in Computer Science") .from("University of Hong Kong") .bio("Jerry interned at a local company in high school and has been working as a software developer ever since."), assets.getImage(GameAssets.ImageKey.JERRY)); builder.put(EmployeeProfile.firstName("Vani").lastName("Mishra") .withDegree("Bachelors in Computer Engineering").from("Indian Institute of Science") .withDegree("Masters in Software Engineering").from("Ball State University") .bio("Vani was born in India and came to the United States for graduate school. She loves music, dancing, and PHP."), assets.getImage(GameAssets.ImageKey.VANI)); builder.put(EmployeeProfile.firstName("Abdullah").lastName("Nasr") .withDegree("Bachelors in Electrical Engineering").from("Iowa State University") .bio("Abdullah used to work for a larger social media company, but he prefers the excitement of a small startup."), assets.getImage(GameAssets.ImageKey.ABDULLAH)); builder.put(EmployeeProfile.firstName("Janine").lastName("Palmer") .withDegree("Bachelors in Computer Science").from("Virginia Tech") .bio("Janine is especially talented at meeting with customers and understanding what they want from a product."), assets.getImage(GameAssets.ImageKey.JANINE)); builder.put(EmployeeProfile.firstName("Melissa").lastName("Bernard").withDegree("Bachelors in Mathematics") .from("Stanford University") .bio("Melissa has always loved games and puzzles, but she especially loves bicycling and walking her German Shepherd."), assets.getImage(GameAssets.ImageKey.MELISSA)); builder.put(// w w w . j ava2 s.c om EmployeeProfile.firstName("Ivar").lastName("Johansen").withDegree("Bachelors in Chemistry") .from("Stockholm University").withDegree("Masters in Electrical Engineering") .from("Uppsala University") .bio("Ivar teaches kids how to build simple robots as a volunteer in a local school."), assets.getImage(GameAssets.ImageKey.IVAR)); builder.put(EmployeeProfile.firstName("Bruce").lastName("Powers") .withDegree("Bachelors in Computer Science").from("Ball State University") .bio("Bruce was recently married and enjoys going to the gym and watching documentaries about history."), assets.getImage(GameAssets.ImageKey.BRUCE)); return builder.build(); }
From source file:com.google.gcloud.datastore.BatchOption.java
static Map<Class<? extends BatchOption>, BatchOption> asImmutableMap(BatchOption... options) { ImmutableMap.Builder<Class<? extends BatchOption>, BatchOption> builder = ImmutableMap.builder(); for (BatchOption option : options) { builder.put(option.getClass(), option); }//w w w . j a v a 2 s .c o m return builder.build(); }