当前位置: 首页>>代码示例>>Java>>正文


Java Maps.newHashMap方法代码示例

本文整理汇总了Java中com.google.common.collect.Maps.newHashMap方法的典型用法代码示例。如果您正苦于以下问题:Java Maps.newHashMap方法的具体用法?Java Maps.newHashMap怎么用?Java Maps.newHashMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.Maps的用法示例。


在下文中一共展示了Maps.newHashMap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testForMapWithoutDefault

import com.google.common.collect.Maps; //导入方法依赖的package包/类
public void testForMapWithoutDefault() {
  Map<String, Integer> map = Maps.newHashMap();
  map.put("One", 1);
  map.put("Three", 3);
  map.put("Null", null);
  Function<String, Integer> function = Functions.forMap(map);

  assertEquals(1, function.apply("One").intValue());
  assertEquals(3, function.apply("Three").intValue());
  assertNull(function.apply("Null"));

  try {
    function.apply("Two");
    fail();
  } catch (IllegalArgumentException expected) {
  }

  new EqualsTester()
      .addEqualityGroup(function, Functions.forMap(map))
      .addEqualityGroup(Functions.forMap(map, 42))
      .testEquals();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:23,代码来源:FunctionsTest.java

示例2: Chunk

import com.google.common.collect.Maps; //导入方法依赖的package包/类
public Chunk(World worldIn, int x, int z)
{
    this.storageArrays = new ExtendedBlockStorage[16];
    this.blockBiomeArray = new byte[256];
    this.precipitationHeightMap = new int[256];
    this.updateSkylightColumns = new boolean[256];
    this.chunkTileEntityMap = Maps.<BlockPos, TileEntity>newHashMap();
    this.queuedLightChecks = 4096;
    this.tileEntityPosQueue = Queues.<BlockPos>newConcurrentLinkedQueue();
    this.entityLists = (ClassInheritanceMultiMap[])(new ClassInheritanceMultiMap[16]);
    this.worldObj = worldIn;
    this.xPosition = x;
    this.zPosition = z;
    this.heightMap = new int[256];

    for (int i = 0; i < this.entityLists.length; ++i)
    {
        this.entityLists[i] = new ClassInheritanceMultiMap(Entity.class);
    }

    Arrays.fill((int[])this.precipitationHeightMap, (int) - 999);
    Arrays.fill(this.blockBiomeArray, (byte) - 1);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:24,代码来源:Chunk.java

示例3: bepaalTeLeverenGegevenInOnderzoekObjecten

import com.google.common.collect.Maps; //导入方法依赖的package包/类
private List<Onderzoekbundel> bepaalTeLeverenGegevenInOnderzoekObjecten(final OnderzoekData data) {
    //selecteer de geautoriseerde GegevenInOnderzoek objecten
    final List<MetaObject> gegevenInOnderzoekLijst = Lists.newArrayList(
            data.berichtgegevens.getGeautoriseerdeObjecten(ElementHelper.getObjectElement(Element.GEGEVENINONDERZOEK)));

    final List<Onderzoekbundel> alleGegevensInOnderzoek = data.persoonslijst.getOnderzoekIndex().getAlleGegevensInOnderzoek();
    final Map<MetaObject, Onderzoekbundel> gegevenInOnderzoekMap = Maps.newHashMap();
    for (Onderzoekbundel inOnderzoek : alleGegevensInOnderzoek) {
        gegevenInOnderzoekMap.put(inOnderzoek.getGegevenInOnderzoek(), inOnderzoek);
    }
    final List<Onderzoekbundel> returnlist = Lists.newLinkedList();
    for (MetaObject gegevenInOnderzoekMetaObject : gegevenInOnderzoekLijst) {
        final Onderzoekbundel onderzoekbundel = gegevenInOnderzoekMap.get(gegevenInOnderzoekMetaObject);
        if (moetGegevenInOnderzoekGeleverdWorden(onderzoekbundel, data)) {
            returnlist.add(onderzoekbundel);
        }
    }
    return returnlist;
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:20,代码来源:AutoriseerOnderzoekServiceImpl.java

示例4: generate

import com.google.common.collect.Maps; //导入方法依赖的package包/类
public Map<String, String> generate(Parser parser) throws Exception {
    Map<String, String> code = Maps.newHashMap();
    Set<String> schemaNames = Sets.newHashSet();
    this.dsl = parser.getAllParsedDSL();
    for (String name : parser.getSchemaNames()) {
        NamedSchema schema = (NamedSchema) parser.getSchema(name);
        if (schema.isRemoved()) {
            continue;
        }
        schemaNames.add(schema.getName());
        if (schema instanceof EnumSchema) {
            code.put(name, generateEnum((EnumSchema) schema));
        } else if (schema instanceof RecordSchema) {
            String className = SchemaNameUtils.classNameWithPackageFor(schema.getName());
            code.put(className, generateRecord((RecordSchema) schema));
        } else {
            throw new IllegalArgumentException("Unknown schema type " + schema);
        }
    }
    return code;
}
 
开发者ID:atlascon,项目名称:travny,代码行数:22,代码来源:Codegen.java

示例5: addLinks

import com.google.common.collect.Maps; //导入方法依赖的package包/类
@Override
public EquellaItemBean addLinks(EquellaItemBean itemBean)
{
	final Map<String, String> links = Maps.newHashMap();
	final ItemId itemId = new ItemId(itemBean.getUuid(), itemBean.getVersion());
	links.put(REL_SELF, getItemURLStr(itemId));
	links.put(REL_VIEW, linkFactory.createViewLink(itemId).getHref());

	final List<AttachmentBean> attachments = itemBean.getAttachments();
	if( attachments != null )
	{
		for( AttachmentBean attachmentBean : attachments )
		{
			final Map<String, String> attachLinks = Maps.newHashMap();
			attachLinks.put(REL_VIEW,
				linkFactory.createViewAttachmentLink(itemId, attachmentBean.getUuid()).getHref());
			attachLinks.put(REL_THUMB,
				linkFactory.createThumbnailAttachmentLink(itemId, attachmentBean.getUuid()).getHref());
			attachmentBean.set("links", attachLinks);
		}
	}
	itemBean.set("links", links);
	return itemBean;
}
 
开发者ID:equella,项目名称:Equella,代码行数:25,代码来源:ItemLinkServiceImpl.java

示例6: convertToParamMap

import com.google.common.collect.Maps; //导入方法依赖的package包/类
public static Map<String, String[]> convertToParamMap(String... params)
{
	Map<String, String[]> eventParams = Maps.newHashMap();
	for( int i = 0; i < params.length; i++ )
	{
		String param = params[i];
		String[] paramArray = new String[]{param};
		if( i == 0 )
		{
			eventParams.put(EVENT_ID, paramArray);
		}
		else
		{
			eventParams.put(EVENT_PARAM + (i - 1), paramArray);
		}
	}
	return eventParams;
}
 
开发者ID:equella,项目名称:Equella,代码行数:19,代码来源:EventGeneratorListener.java

示例7: getAllService

import com.google.common.collect.Maps; //导入方法依赖的package包/类
@RequestMapping(value = "getAllService", method = RequestMethod.GET)
public List<Map<String, Object>> getAllService() throws Exception {
  List<Map<String, Object>> services = Lists.newArrayList();
  try {
    Collection<Object> instances = getTypedBeansWithAnnotation(SalukiService.class);
    for (Object instance : instances) {
      Object target = GrpcAop.getTarget(instance);
      Class<?>[] interfaces = ClassUtils.getAllInterfacesForClass(target.getClass());
      Class<?> clzz = interfaces[0];
      Map<String, Object> serviceMap = Maps.newHashMap();
      serviceMap.put("simpleName", clzz.getSimpleName());
      serviceMap.put("name", clzz.getName());
      ServiceDefinition sd = Jaket.build(clzz);
      List<MethodDefinition> methodDefines = sd.getMethods();
      List<String> functions = Lists.newArrayList();
      for (MethodDefinition methodDefine : methodDefines) {
        functions.add(methodDefine.getName());
      }
      serviceMap.put("functions", functions);
      services.add(serviceMap);
    }
    return services;
  } catch (Exception e) {
    throw e;
  }
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:27,代码来源:TestController.java

示例8: viewMessageByBrokerAndOffset

import com.google.common.collect.Maps; //导入方法依赖的package包/类
@RequestMapping(value = "/viewMessageByBrokerAndOffset.query", method = RequestMethod.GET)
@JsonBody
public Object viewMessageByBrokerAndOffset(@RequestParam String brokerHost,@RequestParam int port, @RequestParam long offset) {
    Map<String, Object> messageViewMap = Maps.newHashMap();
    Pair<MessageView, List<MessageTrack>> messageViewListPair =  messageService.viewMessageByBrokerAndOffset(brokerHost,port, offset);
    messageViewMap.put("messageView", messageViewListPair.getObject1());
    messageViewMap.put("messageTrackList", messageViewListPair.getObject2());
    return messageViewMap;
}
 
开发者ID:didapinchegit,项目名称:rocket-console,代码行数:10,代码来源:MessageController.java

示例9: ServerConfigurationManager

import com.google.common.collect.Maps; //导入方法依赖的package包/类
public ServerConfigurationManager(MinecraftServer server)
{
    this.bannedPlayers = new UserListBans(FILE_PLAYERBANS);
    this.bannedIPs = new BanList(FILE_IPBANS);
    this.ops = new UserListOps(FILE_OPS);
    this.whiteListedPlayers = new UserListWhitelist(FILE_WHITELIST);
    this.playerStatFiles = Maps.<UUID, StatisticsFile>newHashMap();
    this.mcServer = server;
    this.bannedPlayers.setLanServer(false);
    this.bannedIPs.setLanServer(false);
    this.maxPlayers = 8;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:13,代码来源:ServerConfigurationManager.java

示例10: withProperty

import com.google.common.collect.Maps; //导入方法依赖的package包/类
@Override
public <T extends Comparable<T>, V extends T> IBlockState withProperty(IProperty<T> property, V value)
{
    if (!this.getProperties().containsKey(property))
    {
        throw new IllegalArgumentException("Cannot set property " + property + " as it does not exist in " + getBlock().getBlockState());
    }
    else
    {
        if (!property.getAllowedValues().contains(value))
        {
            throw new IllegalArgumentException("Cannot set property " + property + " to " + value + " on block " + Block.REGISTRY.getNameForObject(getBlock()) + ", it is not an allowed value");
        } else
        {
            if (this.getProperties().get(property) == value)
            {
                return this;
            }
            Map<IProperty<?>, Comparable<?>> map = Maps.newHashMap(getProperties());
            map.put(property, value);
            if (Iterables.all(unlistedProperties.values(), Predicates.<Optional<?>>equalTo(Optional.absent())))
            { // no dynamic properties present, looking up in the normal table
                return normalMap.get(map);
            }
            ImmutableTable<IProperty<?>, Comparable<?>, IBlockState> table = propertyValueTable;
            table = ((StateImplementation) table.get(property, value)).getPropertyValueTable();
            return new ExtendedStateImplementation(getBlock(), ImmutableMap.copyOf(map), unlistedProperties, table).setMap(this.normalMap);
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:31,代码来源:ExtendedBlockState.java

示例11: createDefaultConfig

import com.google.common.collect.Maps; //导入方法依赖的package包/类
/**
 * Helper method.
 */
private Map createDefaultConfig(List<String> zkServers, String zkRootNode, String consumerIdPrefix) {
    Map config = Maps.newHashMap();
    config.put(SidelineConfig.PERSISTENCE_ZK_SERVERS, zkServers);
    config.put(SidelineConfig.PERSISTENCE_ZK_ROOT, zkRootNode);
    config.put(SpoutConfig.VIRTUAL_SPOUT_ID_PREFIX, consumerIdPrefix);

    return Tools.immutableCopy(SpoutConfig.setDefaults(config));
}
 
开发者ID:salesforce,项目名称:storm-dynamic-spout,代码行数:12,代码来源:ZookeeperPersistenceAdapterTest.java

示例12: buildResponsesMap

import com.google.common.collect.Maps; //导入方法依赖的package包/类
public Map<String, Response> buildResponsesMap(Response... responses) {
    Map<String, Response> responsesMap = Maps.newHashMap();

    for (Response response : responses) {
        responsesMap.put(response.identifier, response);
    }
    return responsesMap;
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:9,代码来源:ResponsesMapBuilder.java

示例13: getFields

import com.google.common.collect.Maps; //导入方法依赖的package包/类
private static Map<String, Field> getFields(Class<?> type) {
    Map<String, Field> fields = Maps.newHashMap();
    for (Field field : type.getDeclaredFields()) {
        fields.put(field.getName(), field);
    }
    return fields;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:8,代码来源:DefaultTaskClassValidatorExtractor.java

示例14: createDefaultInstance

import com.google.common.collect.Maps; //导入方法依赖的package包/类
/**
 * Helper method for creating a default instance.
 * @return factory method for create an instance of the buffer.
 */
public static RoundRobinBuffer createDefaultInstance() {
    Map<String, Object> map = Maps.newHashMap();
    map.put(SpoutConfig.TUPLE_BUFFER_MAX_SIZE, 10000);

    RoundRobinBuffer buffer = new RoundRobinBuffer();
    buffer.open(map);

    return buffer;
}
 
开发者ID:salesforce,项目名称:storm-dynamic-spout,代码行数:14,代码来源:RoundRobinBuffer.java

示例15: bake

import com.google.common.collect.Maps; //导入方法依赖的package包/类
@Override
public IBakedModel bake(IModelState state, VertexFormat format,
		java.util.function.Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {

	ImmutableMap<TransformType, TRSRTransformation> transformMap = PerspectiveMapWrapper.getTransforms(state);

	TRSRTransformation transform = (TRSRTransformation.identity());

	ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();

	if (headTexture != null && haftTexture != null && handleTexture != null) {
		
		ImmutableList.Builder<ResourceLocation> texBuilder = ImmutableList.builder();
		if (haftTexture != null) {
			texBuilder.add(haftTexture);
		}
		if (headTexture != null) {
			texBuilder.add(headTexture);
		}
		if (handleTexture != null) {
			texBuilder.add(handleTexture);
		}
		if (adornmentTexture != null) {
			texBuilder.add(adornmentTexture);
		}
		ImmutableList<ResourceLocation> textures = texBuilder.build();
		
		IBakedModel model = (new ItemLayerModel(textures)).bake(state, format, bakedTextureGetter);
		builder.addAll(model.getQuads(null, null, 0));
	}

	return new BakedPickaxeModel(this, builder.build(), format, Maps.immutableEnumMap(transformMap),
			Maps.<String, IBakedModel>newHashMap());
}
 
开发者ID:the-realest-stu,项目名称:Adventurers-Toolbox,代码行数:35,代码来源:PickaxeModel.java


注:本文中的com.google.common.collect.Maps.newHashMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。