com.google.common.collect.ImmutableBiMap.Builder的实例源码

项目:guava-mock    文件:ImmutableBiMapTest.java   
public void testBuilderPutAll() {
  Map<String,Integer> toPut = new LinkedHashMap<String,Integer>();
  toPut.put("one",1);
  toPut.put("two",2);
  toPut.put("three",3);
  Map<String,Integer> moreToPut = new LinkedHashMap<String,Integer>();
  moreToPut.put("four",4);
  moreToPut.put("five",5);

  ImmutableBiMap<String,Integer> map = new Builder<String,Integer>()
      .putAll(toPut)
      .putAll(moreToPut)
      .build();
  assertMapEquals(map,"one",1,"two",2,"three",3,"four",4,"five",5);
  assertMapEquals(map.inverse(),5,"five");
}
项目:guava-mock    文件:ImmutableBiMapTest.java   
public void testBuilderReuse() {
  Builder<String,Integer> builder = new Builder<String,Integer>();
  ImmutableBiMap<String,Integer> mapOne = builder
      .put("one",1)
      .put("two",2)
      .build();
  ImmutableBiMap<String,Integer> mapTwo = builder
      .put("three",3)
      .put("four",4)
      .build();

  assertMapEquals(mapOne,2);
  assertMapEquals(mapOne.inverse(),"two");
  assertMapEquals(mapTwo,4);
  assertMapEquals(mapTwo.inverse(),"four");
}
项目:guava-mock    文件:ImmutableBiMapTest.java   
public void testDuplicateValues() {
  ImmutableMap<String,Integer> map
      = new ImmutableMap.Builder<String,Integer>()
          .put("one",1)
          .put("two",2)
          .put("uno",1)
          .put("dos",2)
          .build();

  try {
    ImmutableBiMap.copyOf(map);
    fail();
  } catch (IllegalArgumentException expected) {
    assertThat(expected.getMessage()).contains("1");
  }
}
项目:googles-monorepo-demo    文件:ImmutableBiMapTest.java   
public void testBuilderPutAll() {
  Map<String,"five");
}
项目:googles-monorepo-demo    文件:ImmutableBiMapTest.java   
public void testBuilderReuse() {
  Builder<String,"four");
}
项目:googles-monorepo-demo    文件:ImmutableBiMapTest.java   
public void testDuplicateValues() {
  ImmutableMap<String,2)
          .build();

  try {
    ImmutableBiMap.copyOf(map);
    fail();
  } catch (IllegalArgumentException expected) {
    assertThat(expected.getMessage()).contains("1");
  }
}
项目:hashsdn-controller    文件:ModuleShardBackendResolver.java   
Long resolveShardForPath(final YangInstanceIdentifier path) {
    final String shardName = actorContext.getShardStrategyFactory().getStrategy(path).findShard(path);
    Long cookie = shards.get(shardName);
    if (cookie == null) {
        synchronized (this) {
            cookie = shards.get(shardName);
            if (cookie == null) {
                cookie = nextShard++;

                Builder<String,Long> builder = ImmutableBiMap.builder();
                builder.putAll(shards);
                builder.put(shardName,cookie);
                shards = builder.build();
            }
        }
    }

    return cookie;
}
项目:guava-libraries    文件:ImmutableBiMapTest.java   
public void testBuilderPutAll() {
  Map<String,"five");
}
项目:guava-libraries    文件:ImmutableBiMapTest.java   
public void testBuilderReuse() {
  Builder<String,"four");
}
项目:guava-libraries    文件:ImmutableBiMapTest.java   
public void testDuplicateValues() {
  ImmutableMap<String,2)
          .build();

  try {
    ImmutableBiMap.copyOf(map);
    fail();
  } catch (IllegalArgumentException expected) {
    assertTrue(expected.getMessage().contains("1"));
  }
}
项目:guava    文件:ImmutableBiMapTest.java   
public void testDuplicateValues() {
  ImmutableMap<String,Integer> map =
      new ImmutableMap.Builder<String,2)
          .build();

  try {
    ImmutableBiMap.copyOf(map);
    fail();
  } catch (IllegalArgumentException expected) {
    assertThat(expected.getMessage()).contains("1");
  }
}
项目:yangtools    文件:PrefixConverters.java   
/**
 * Create a prefix {@link Converter} for {@link XPathExpressionException} defined in a particular YANG
 * {@link Module} .Instantiation requires establishing how a module's imports are mapped to actual modules
 * and their namespaces. This information is cached and used for improved lookups.
 *
 * @param ctx A SchemaContext
 * @param module Module in which the XPath is defined
 * @return A new Converter
 */
public static @Nonnull Converter<String,QNameModule> create(final SchemaContext ctx,final Module module) {
    // Always check for null ctx
    requireNonNull(ctx,"Schema context may not be null");

    // Use immutable map builder for detection of duplicates (which should never occur)
    final Builder<String,QNameModule> b = ImmutableBiMap.builder();
    b.put(module.getPrefix(),module.getQNameModule());

    for (ModuleImport i : module.getImports()) {
        final Optional<Module> mod = ctx.findModule(i.getModuleName(),i.getRevision());
        checkArgument(mod.isPresent(),"Unsatisfied import of %s by module %s",i,module);

        b.put(i.getPrefix(),mod.get().getQNameModule());
    }

    return Maps.asConverter(b.build());
}
项目:guava-mock    文件:ImmutableBiMapTest.java   
public void testEmptyBuilder() {
  ImmutableBiMap<String,Integer> map
      = new Builder<String,Integer>().build();
  assertEquals(Collections.<String,Integer>emptyMap(),map);
  assertEquals(Collections.<Integer,String>emptyMap(),map.inverse());
  assertSame(ImmutableBiMap.of(),map);
}
项目:guava-mock    文件:ImmutableBiMapTest.java   
public void testSingletonBuilder() {
  ImmutableBiMap<String,Integer>()
      .put("one",1)
      .build();
  assertMapEquals(map,1);
  assertMapEquals(map.inverse(),"one");
}
项目:guava-mock    文件:ImmutableBiMapTest.java   
public void testBuilder_orderEntriesByValueAfterExactSizeBuild() {
  ImmutableBiMap.Builder<String,Integer> builder =
      new ImmutableBiMap.Builder<String,Integer>(2).put("four",4).put("one",1);
  ImmutableMap<String,Integer> keyOrdered = builder.build();
  ImmutableMap<String,Integer> valueOrdered =
      builder.orderEntriesByValue(Ordering.natural()).build();
  assertMapEquals(keyOrdered,1);
  assertMapEquals(valueOrdered,4);
}
项目:guava-mock    文件:ImmutableBiMapTest.java   
public void testBuilder_orderEntriesByValue_usedTwiceFails() {
  ImmutableBiMap.Builder<String,Integer>()
      .orderEntriesByValue(Ordering.natural());
  try {
    builder.orderEntriesByValue(Ordering.natural());
    fail("Expected IllegalStateException");
  } catch (IllegalStateException expected) {}
}
项目:guava-mock    文件:ImmutableBiMapTest.java   
public void testBuilderPutNullKey() {
  Builder<String,Integer>();
  try {
    builder.put(null,1);
    fail();
  } catch (NullPointerException expected) {
  }
}
项目:guava-mock    文件:ImmutableBiMapTest.java   
public void testBuilderPutNullValue() {
  Builder<String,Integer>();
  try {
    builder.put("one",null);
    fail();
  } catch (NullPointerException expected) {
  }
}
项目:guava-mock    文件:ImmutableBiMapTest.java   
public void testBuilderPutNullKeyViaPutAll() {
  Builder<String,Integer>();
  try {
    builder.putAll(Collections.<String,Integer>singletonMap(null,1));
    fail();
  } catch (NullPointerException expected) {
  }
}
项目:guava-mock    文件:ImmutableBiMapTest.java   
public void testBuilderPutNullValueViaPutAll() {
  Builder<String,Integer>singletonMap("one",null));
    fail();
  } catch (NullPointerException expected) {
  }
}
项目:guava-mock    文件:ImmutableBiMapTest.java   
public void testPuttingTheSameKeyTwiceThrowsOnBuild() {
  Builder<String,1)
      .put("one",1); // throwing on this line would be even better

  try {
    builder.build();
    fail();
  } catch (IllegalArgumentException expected) {
    assertThat(expected.getMessage()).contains("one");
  }
}
项目:guava-mock    文件:ImmutableBiMapTest.java   
public void testFromImmutableMap() {
  ImmutableBiMap<String,Integer> bimap = ImmutableBiMap.copyOf(
      new ImmutableMap.Builder<String,2)
          .put("three",3)
          .put("four",4)
          .put("five",5)
          .build());
  assertMapEquals(bimap,5);
  assertMapEquals(bimap.inverse(),"five");
}
项目:googles-monorepo-demo    文件:ImmutableBiMapTest.java   
public void testEmptyBuilder() {
  ImmutableBiMap<String,map);
}
项目:googles-monorepo-demo    文件:ImmutableBiMapTest.java   
public void testSingletonBuilder() {
  ImmutableBiMap<String,"one");
}
项目:googles-monorepo-demo    文件:ImmutableBiMapTest.java   
public void testBuilder_orderEntriesByValueAfterExactSizeBuild() {
  ImmutableBiMap.Builder<String,4);
}
项目:googles-monorepo-demo    文件:ImmutableBiMapTest.java   
public void testBuilder_orderEntriesByValue_usedTwiceFails() {
  ImmutableBiMap.Builder<String,Integer>()
      .orderEntriesByValue(Ordering.natural());
  try {
    builder.orderEntriesByValue(Ordering.natural());
    fail("Expected IllegalStateException");
  } catch (IllegalStateException expected) {}
}
项目:googles-monorepo-demo    文件:ImmutableBiMapTest.java   
public void testBuilderPutNullKey() {
  Builder<String,1);
    fail();
  } catch (NullPointerException expected) {
  }
}
项目:googles-monorepo-demo    文件:ImmutableBiMapTest.java   
public void testBuilderPutNullValue() {
  Builder<String,null);
    fail();
  } catch (NullPointerException expected) {
  }
}
项目:googles-monorepo-demo    文件:ImmutableBiMapTest.java   
public void testBuilderPutNullKeyViaPutAll() {
  Builder<String,1));
    fail();
  } catch (NullPointerException expected) {
  }
}
项目:googles-monorepo-demo    文件:ImmutableBiMapTest.java   
public void testBuilderPutNullValueViaPutAll() {
  Builder<String,null));
    fail();
  } catch (NullPointerException expected) {
  }
}
项目:googles-monorepo-demo    文件:ImmutableBiMapTest.java   
public void testPuttingTheSameKeyTwiceThrowsOnBuild() {
  Builder<String,1); // throwing on this line would be even better

  try {
    builder.build();
    fail();
  } catch (IllegalArgumentException expected) {
    assertThat(expected.getMessage()).contains("one");
  }
}
项目:googles-monorepo-demo    文件:ImmutableBiMapTest.java   
public void testFromImmutableMap() {
  ImmutableBiMap<String,"five");
}
项目:CustomWorldGen    文件:FMLDeobfuscatingRemapper.java   
public void setupLoadOnly(String deobfFileName,boolean loadAll)
{
    try
    {
        File mapData = new File(deobfFileName);
        LZMAInputSupplier zis = new LZMAInputSupplier(new FileInputStream(mapData));
        CharSource srgSource = zis.asCharSource(Charsets.UTF_8);
        List<String> srgList = srgSource.readLines();
        rawMethodMaps = Maps.newHashMap();
        rawFieldMaps = Maps.newHashMap();
        Builder<String,String> builder = ImmutableBiMap.builder();
        Splitter splitter = Splitter.on(CharMatcher.anyOf(": ")).omitEmptyStrings().trimResults();
        for (String line : srgList)
        {
            String[] parts = Iterables.toArray(splitter.split(line),String.class);
            String typ = parts[0];
            if ("CL".equals(typ))
            {
                parseClass(builder,parts);
            }
            else if ("MD".equals(typ) && loadAll)
            {
                parseMethod(parts);
            }
            else if ("FD".equals(typ) && loadAll)
            {
                parseField(parts);
            }
        }
        classNameBiMap = builder.build();
    }
    catch (IOException ioe)
    {
        FMLRelaunchLog.log(Level.ERROR,"An error occurred loading the deobfuscation map data",ioe);
    }
    methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size());
    fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size());

}
项目:TRHS_Club_Mod_2016    文件:FMLDeobfuscatingRemapper.java   
public void setupLoadOnly(String deobfFileName,String> builder = ImmutableBiMap.<String,String>builder();
        Splitter splitter = Splitter.on(CharMatcher.anyOf(": ")).omitEmptyStrings().trimResults();
        for (String line : srgList)
        {
            String[] parts = Iterables.toArray(splitter.split(line),ioe);
    }
    methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size());
    fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size());

}
项目:TRHS_Club_Mod_2016    文件:FMLDeobfuscatingRemapper.java   
public void setup(File mcDir,LaunchClassLoader classLoader,String deobfFileName)
{
    this.classLoader = classLoader;
    try
    {
        InputStream classData = getClass().getResourceAsStream(deobfFileName);
        LZMAInputSupplier zis = new LZMAInputSupplier(classData);
        CharSource srgSource = zis.asCharSource(Charsets.UTF_8);
        List<String> srgList = srgSource.readLines();
        rawMethodMaps = Maps.newHashMap();
        rawFieldMaps = Maps.newHashMap();
        Builder<String,parts);
            }
            else if ("MD".equals(typ))
            {
                parseMethod(parts);
            }
            else if ("FD".equals(typ))
            {
                parseField(parts);
            }
        }
        classNameBiMap = builder.build();
    }
    catch (IOException ioe)
    {
        FMLRelaunchLog.log(Level.ERROR,ioe,"An error occurred loading the deobfuscation map data");
    }
    methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size());
    fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size());
}
项目:FinanceAnalytics    文件:SecurityTypesDescriptionProvider.java   
/**
 * Restricted constructor
 */
private SecurityTypesDescriptionProvider() {
  Builder<String,String> builder = ImmutableBiMap.builder();
  AnnotationReflector reflector = AnnotationReflector.getDefaultReflector();
  Set<Class<?>> securityClasses = reflector.getReflector().getTypesAnnotatedWith(SecurityDescription.class);
  for (Class<?> securityClass : securityClasses) {
    SecurityDescription securityDescriptionAnnotation = securityClass.getAnnotation(SecurityDescription.class);
    if (securityDescriptionAnnotation != null) {
      // extract type
      String type = StringUtils.trimToNull(securityDescriptionAnnotation.type());
      if (type == null) {
        if (ManageableSecurity.class.isAssignableFrom(securityClass)) {
          MetaBean metaBean = JodaBeanUtils.metaBean(securityClass);
          ManageableSecurity bareSecurity = (ManageableSecurity) metaBean.builder().build();
          type = bareSecurity.getSecurityType();
        } else {
          s_logger.warn("{} anotated with {},but not subtype of {}",securityClass,SecurityDescription.class,ManageableSecurity.class);
        }
      }
      // extract description
      String description = StringUtils.trimToNull(securityDescriptionAnnotation.description());
      if (description == null) {
        description = securityClass.getSimpleName();
      }
      builder.put(type,description);
    }
  }
  _type2Description = builder.build();
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


com.google.gson.internal.bind.ArrayTypeAdapter的实例源码
com.google.gson.JsonSyntaxException的实例源码
com.google.gson.JsonDeserializer的实例源码
com.google.gson.internal.ConstructorConstructor的实例源码
com.google.gson.JsonPrimitive的实例源码
com.google.gson.LongSerializationPolicy的实例源码
com.google.gson.internal.GsonInternalAccess的实例源码
com.google.gson.JsonIOException的实例源码
com.google.gson.internal.StringMap的实例源码
com.google.gson.JsonObject的实例源码
com.google.gson.internal.bind.TimeTypeAdapter的实例源码
com.google.gson.FieldAttributes的实例源码
com.google.gson.internal.bind.TreeTypeAdapter的实例源码
com.google.gson.internal.LinkedHashTreeMap的实例源码
com.google.gson.TypeAdapterFactory的实例源码
com.google.gson.JsonSerializer的实例源码
com.google.gson.FieldNamingPolicy的实例源码
com.google.gson.JsonElement的实例源码
com.google.gson.internal.JsonReaderInternalAccess的实例源码
com.google.gson.TypeAdapter的实例源码