List of usage examples for com.google.common.collect Maps newHashMap
public static <K, V> HashMap<K, V> newHashMap()
From source file:org.graylog2.rest.models.system.lookup.ErrorStates.java
public static Builder builder() { return new AutoValue_ErrorStates.Builder().caches(Maps.newHashMap()).tables(Maps.newHashMap()) .dataAdapters(Maps.newHashMap()); }
From source file:com.monpie.histogram.OneThreadHashMap.java
@Override public void run() { asciiMap = Maps.newHashMap(); String randomArray[][] = RandomizeArray.array; for (int i = 0; i < RandomizeArray.ROWS; i++) { for (int j = 0; j < RandomizeArray.COLUMNS; j++) { if (asciiMap.containsKey(randomArray[i][j])) { asciiMap.replace(randomArray[i][j], new AtomicInteger(asciiMap.get(randomArray[i][j]).incrementAndGet())); System.out.println("element: " + randomArray[i][j]); } else { asciiMap.put(randomArray[i][j], new AtomicInteger(1)); }/*from w w w. ja va2 s. c o m*/ } } int sum = 0; for (Map.Entry<String, AtomicInteger> entry : asciiMap.entrySet()) { System.out.println("Znak: " + entry.getKey() + " , ilosc powtorzen: " + entry.getValue()); sum = sum + entry.getValue().get(); } System.out.println("Sum of all elements: " + sum); }
From source file:org.apache.kylin.storage.hbase.util.HBaseUsage.java
private static void show() throws IOException { Map<String, List<String>> envs = Maps.newHashMap(); // get all kylin hbase tables Connection conn = HBaseConnection.get(KylinConfig.getInstanceFromEnv().getStorageUrl()); Admin hbaseAdmin = conn.getAdmin();//from w w w . j a va 2s . com String tableNamePrefix = IRealizationConstants.SharedHbaseStorageLocationPrefix; HTableDescriptor[] tableDescriptors = hbaseAdmin.listTables(tableNamePrefix + ".*"); for (HTableDescriptor desc : tableDescriptors) { String host = desc.getValue(IRealizationConstants.HTableTag); if (StringUtils.isEmpty(host)) { add("unknown", desc.getNameAsString(), envs); } else { add(host, desc.getNameAsString(), envs); } } for (Map.Entry<String, List<String>> entry : envs.entrySet()) { System.out.println(entry.getKey() + " has htable count: " + entry.getValue().size()); } hbaseAdmin.close(); }
From source file:org.sonatype.nexus.thread.internal.MDCUtils.java
public static Map<String, String> getCopyOfContextMap() { final boolean inheritable = MDC.get(CONTEXT_NON_INHERITABLE_KEY) == null; Map<String, String> result = null; if (inheritable) { //noinspection unchecked result = MDC.getCopyOfContextMap(); }/*from ww w . j av a 2 s .c o m*/ if (result == null) { result = Maps.newHashMap(); } result.remove(CONTEXT_NON_INHERITABLE_KEY); return result; }
From source file:com.cloudera.nav.sdk.model.MClassUtil.java
/** * @param mclass the metadata object class * @param annClass the annotation class// w w w . jav a2 s . com * @return annotated fields and corresponding getter */ public static Map<Field, Method> getAnnotatedProperties(Class<?> mclass, Class<? extends Annotation> annClass) { Map<String, Method> getters = Maps.newHashMap(); try { for (PropertyDescriptor pd : Introspector.getBeanInfo(mclass).getPropertyDescriptors()) { getters.put(pd.getName(), pd.getReadMethod()); } } catch (IntrospectionException e) { throw Throwables.propagate(e); } Map<Field, Method> properties = Maps.newHashMap(); for (Field field : getValidFields(mclass, annClass)) { Preconditions.checkArgument(getters.containsKey(field.getName()), "No getter method found for " + field.getName()); properties.put(field, getters.get(field.getName())); } return properties; }
From source file:au.com.scds.agric.integtests.bootstrap.DomainAppSystemInitializer.java
public static void initIsft() { IsisSystemForTest isft = IsisSystemForTest.getElseNull(); if (isft == null) { isft = new IsisSystemForTest.Builder().withLoggingAt(org.apache.log4j.Level.INFO) .with(new DomainAppAppManifest() { @Override/*from www . j av a 2 s. c om*/ public Map<String, String> getConfigurationProperties() { final Map<String, String> map = Maps.newHashMap(); Util.withJavaxJdoRunInMemoryProperties(map); Util.withDataNucleusProperties(map); Util.withIsisIntegTestProperties(map); return map; } }).build(); isft.setUpSystem(); IsisSystemForTest.set(isft); } }
From source file:npanday.plugin.libraryimporter.LibImporterPathUtils.java
public static Map<String, File> getLibDirectories(File packageDir) { File libDir = new File(packageDir, "lib"); Map<String, File> libDirs = Maps.newHashMap(); if (!libDir.exists()) { return libDirs; }//from w w w.j a va 2 s .c o m if (getLibraries(libDir).size() > 0) { libDirs.put("lib", libDir); } for (File framework : libDir.listFiles()) { if (!framework.isDirectory()) { continue; } if (getLibraries(framework).size() > 0) { libDirs.put(framework.getName(), framework); } for (File platform : framework.listFiles()) { if (!platform.isDirectory()) { continue; } if (getLibraries(platform).size() > 0) { libDirs.put(framework.getName() + "/" + platform.getName(), platform); } } } return libDirs; }
From source file:com.enonic.cms.core.portal.datasource.xml.DataSourceElement.java
public DataSourceElement(final String name) { this.name = name; this.parameters = Maps.newHashMap(); }
From source file:nl.knaw.huygens.timbuctoo.model.util.PersonNameBuilder.java
private static Map<MultiKey, String> createSeparatorMap() { Map<MultiKey, String> map = Maps.newHashMap(); map.put(new MultiKey(Type.SURNAME, Type.FORENAME), COMMA); map.put(new MultiKey(Type.SURNAME, Type.GEN_NAME), COMMA); map.put(new MultiKey(Type.SURNAME, Type.ADD_NAME), COMMA); map.put(new MultiKey(Type.SURNAME, Type.NAME_LINK), COMMA); map.put(new MultiKey(Type.FORENAME, Type.ADD_NAME), COMMA); map.put(new MultiKey(Type.GEN_NAME, Type.ADD_NAME), COMMA); return map;//from w w w .ja v a 2s . c o m }
From source file:org.napile.compiler.lang.types.DescriptorSubstitutor.java
@NotNull public static TypeSubstitutor substituteTypeParameters(@NotNull List<TypeParameterDescriptor> typeParameters, @NotNull final TypeSubstitutor originalSubstitutor, @NotNull DeclarationDescriptor newContainingDeclaration, @NotNull List<TypeParameterDescriptor> result) { final Map<TypeConstructor, NapileType> mutableSubstitution = Maps.newHashMap(); TypeSubstitutor substitutor = TypeSubstitutor.create(new TypeSubstitution() { @Override/*from ww w. ja v a 2 s . com*/ public NapileType get(TypeConstructor key) { if (originalSubstitutor.inRange(key)) { return originalSubstitutor.getSubstitution().get(key); } return mutableSubstitution.get(key); } @Override public boolean isEmpty() { return originalSubstitutor.isEmpty() && mutableSubstitution.isEmpty(); } @Override public String toString() { return "DescriptorSubstitutor.substituteTypeParameters(" + mutableSubstitution + " / " + originalSubstitutor.getSubstitution() + ")"; } }); for (TypeParameterDescriptor descriptor : typeParameters) { TypeParameterDescriptorImpl substituted = new TypeParameterDescriptorImpl(newContainingDeclaration, descriptor.getAnnotations(), descriptor.getName(), descriptor.getIndex()); substituted.setInitialized(); mutableSubstitution.put(descriptor.getTypeConstructor(), substituted.getDefaultType()); for (NapileType upperBound : descriptor.getUpperBounds()) { substituted.getUpperBounds().add(substitutor.substitute(upperBound, null)); } for (ConstructorDescriptor constructorDescriptor : descriptor.getConstructors()) { substituted.addConstructor((ConstructorDescriptor) constructorDescriptor.substitute(substitutor)); } result.add(substituted); } return substitutor; }