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


Java Maps类代码示例

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


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

示例1: applyMapDiff

import com.google.common.collect.Maps; //导入依赖的package包/类
private static void applyMapDiff(Schema.Field field, GenericRecord avroObj, GenericRecord fieldsValue, Map<Object, Object> modifiedObj, Object key) throws IOException {
    Map<String, Object> changedKeys = ((MapDiff) fieldsValue).getChangedKeys();

    for (String changedKey : changedKeys.keySet()) {
        Class<?> clazz = changedKeys.get(changedKey).getClass();

        if (clazz.isAssignableFrom(PrimitiveDiff.class)) {
            AvroDiffPrimitive.applyPrimitiveDiff(field, avroObj, changedKeys.get(changedKey), changedKeys, changedKey);
            modifiedObj.put(key, changedKeys);
        } else if (clazz.isAssignableFrom(MapDiff.class)) {
            AvroDiffMap.applyMapDiff(field, avroObj, (GenericRecord) changedKeys.get(changedKey), Maps.newHashMap(changedKeys), changedKey);
        } else if (clazz.isAssignableFrom(ArrayDiff.class)) {
            AvroDiffArray.applyArrayDiff(field, avroObj, (GenericRecord) changedKeys.get(changedKey), null);
        } else if (clazz.isAssignableFrom(RecordDiff.class)) {
            Object avroField = ((Map) avroObj.get(field.pos())).get(key);
            GenericRecord genericRecord = AvroDiff.applyDiff((GenericRecord) ((Map) avroField).get(changedKey), (RecordDiff) changedKeys.get(changedKey),
                    ((GenericRecord) ((Map) avroField).get(changedKey)).getSchema());
            ((Map) avroField).put(changedKey, genericRecord);
            modifiedObj.put(key, avroField);
        }
    }
}
 
开发者ID:atlascon,项目名称:avro-diff,代码行数:23,代码来源:AvroDiffMap.java

示例2: func_150876_a

import com.google.common.collect.Maps; //导入依赖的package包/类
public void func_150876_a(EntityPlayerMP p_150876_1_)
{
    int i = this.mcServer.getTickCounter();
    Map<StatBase, Integer> map = Maps.<StatBase, Integer>newHashMap();

    if (this.field_150886_g || i - this.field_150885_f > 300)
    {
        this.field_150885_f = i;

        for (StatBase statbase : this.func_150878_c())
        {
            map.put(statbase, Integer.valueOf(this.readStat(statbase)));
        }
    }

    p_150876_1_.playerNetServerHandler.sendPacket(new S37PacketStatistics(map));
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:18,代码来源:StatisticsFile.java

示例3: getInformationForRoles

import com.google.common.collect.Maps; //导入依赖的package包/类
@Override
public Map<String, RoleBean> getInformationForRoles(final Collection<String> roleIds)
{
	String sql = config.getRoleInfo();
	if( Check.isEmpty(sql) )
	{
		return null;
	}

	final Map<String, RoleBean> roles = Maps.newHashMapWithExpectedSize(roleIds.size());
	handleIn(sql, roleIds, new RowCallbackHandler()
	{
		@Override
		public void processRow(ResultSet set) throws SQLException
		{
			String id = set.getString(1);
			String name = set.getString(2);
			roles.put(id, new DefaultRoleBean(id, name));
		}
	});
	return roles;
}
 
开发者ID:equella,项目名称:Equella,代码行数:23,代码来源:ReplicatedUserPlugin.java

示例4: enhance

import com.google.common.collect.Maps; //导入依赖的package包/类
/**
 * Loop over the {@link #setTokenEnhancers(List) delegates} passing the result into the next member of the chain.
 *
 * @see org.springframework.security.oauth2.provider.token.TokenEnhancer#enhance(org.springframework.security.oauth2.common.OAuth2AccessToken,
 * org.springframework.security.oauth2.provider.OAuth2Authentication)
 */
public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) {
	DefaultOAuth2AccessToken tempResult = (DefaultOAuth2AccessToken) accessToken;


	final Map<String, Object> additionalInformation = new HashMap<String, Object>();

	Map<String, String> details = Maps.newHashMap();
	Object userDetails = authentication.getUserAuthentication().getDetails();
	if (userDetails != null) {
		details = (Map<String, String>) userDetails;
	}


	//you can do extra functions from authentication details

	OAuth2AccessToken result = tempResult;
	for (TokenEnhancer enhancer : delegates) {
		result = enhancer.enhance(result, authentication);
	}
	return result;
}
 
开发者ID:xienjiang,项目名称:session-cloud,代码行数:28,代码来源:TokenEnhancerChainFilter.java

示例5: parseEnchantments

import com.google.common.collect.Maps; //导入依赖的package包/类
public Map<Enchantment, Integer> parseEnchantments(Element el, String name) throws InvalidXMLException {
    Map<Enchantment, Integer> enchantments = Maps.newHashMap();

    Node attr = Node.fromAttr(el, name, StringUtils.pluralize(name));
    if(attr != null) {
        Iterable<String> enchantmentTexts = Splitter.on(";").split(attr.getValue());
        for(String enchantmentText : enchantmentTexts) {
            int level = 1;
            List<String> parts = Lists.newArrayList(Splitter.on(":").limit(2).split(enchantmentText));
            Enchantment enchant = XMLUtils.parseEnchantment(attr, parts.get(0));
            if(parts.size() > 1) {
                level = XMLUtils.parseNumber(attr, parts.get(1), Integer.class);
            }
            enchantments.put(enchant, level);
        }
    }

    for(Element elEnchantment : el.getChildren(name)) {
        Pair<Enchantment, Integer> entry = parseEnchantment(elEnchantment);
        enchantments.put(entry.first, entry.second);
    }

    return enchantments;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:25,代码来源:GlobalItemParser.java

示例6: 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:Notoh,项目名称:DecompiledMinecraft,代码行数:24,代码来源:Chunk.java

示例7: func_175354_a

import com.google.common.collect.Maps; //导入依赖的package包/类
private static void func_175354_a(String p_175354_0_, Item p_175354_1_, int p_175354_2_, BiomeGenBase p_175354_3_, List<String> p_175354_4_, FlatLayerInfo... p_175354_5_)
{
    FlatGeneratorInfo flatgeneratorinfo = new FlatGeneratorInfo();

    for (int i = p_175354_5_.length - 1; i >= 0; --i)
    {
        flatgeneratorinfo.getFlatLayers().add(p_175354_5_[i]);
    }

    flatgeneratorinfo.setBiome(p_175354_3_.biomeID);
    flatgeneratorinfo.func_82645_d();

    if (p_175354_4_ != null)
    {
        for (String s : p_175354_4_)
        {
            flatgeneratorinfo.getWorldFeatures().put(s, Maps.<String, String>newHashMap());
        }
    }

    FLAT_WORLD_PRESETS.add(new GuiFlatPresets.LayerItem(p_175354_1_, p_175354_2_, p_175354_0_, flatgeneratorinfo.toString()));
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:23,代码来源:GuiFlatPresets.java

示例8: fromXml

import com.google.common.collect.Maps; //导入依赖的package包/类
public Map<String, AttributeConfigElement> fromXml(final XmlElement configRootNode) throws DocumentedException {
    Map<String, AttributeConfigElement> retVal = Maps.newHashMap();

    // FIXME add identity map to runtime data
    Map<String, AttributeReadingStrategy> strats = new ObjectXmlReader().prepareReading(yangToAttrConfig,
            Collections.<String, Map<Date, IdentityMapping>>emptyMap());

    for (Entry<String, AttributeReadingStrategy> readStratEntry : strats.entrySet()) {
        List<XmlElement> configNodes = configRootNode.getChildElements(readStratEntry.getKey());
        AttributeConfigElement readElement = readStratEntry.getValue().readElement(configNodes);
        retVal.put(readStratEntry.getKey(), readElement);
    }

    resolveConfiguration(retVal);
    return retVal;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:InstanceRuntimeRpc.java

示例9: getItemLock

import com.google.common.collect.Maps; //导入依赖的package包/类
/**
 * Similar operation in the ItemLockResource
 * 
 * @see com.tle.web.api.item.interfaces.ItemLockResource#get(UriInfo,
 *      String, int)
 * @param uuid
 * @param version
 * @return
 */
private ItemLockBean getItemLock(EquellaItemBean equellaBean)
{
	Item item = itemService.get(new ItemId(equellaBean.getUuid(), equellaBean.getVersion()));
	final ItemLock lock = lockingService.get(item);
	if( lock == null )
	{
		return null;
	}
	final URI loc = urlLinkService.getMethodUriBuilder(ItemLockResource.class, "get").build(item.getUuid(),
		item.getVersion());
	final ItemLockBean lockBean = new ItemLockBean();
	final Map<String, String> linkMap = Maps.newHashMap();
	linkMap.put("self", loc.toString());
	lockBean.setOwner(new UserBean(lock.getUserID()));
	lockBean.setUuid(lock.getUserSession());
	lockBean.set("links", linkMap);
	return lockBean;
}
 
开发者ID:equella,项目名称:Equella,代码行数:28,代码来源:ItemResourceImpl.java

示例10: createSnapshot

import com.google.common.collect.Maps; //导入依赖的package包/类
JarSnapshot createSnapshot(HashCode hash, FileTree classes, final ClassFilesAnalyzer analyzer) {
    final Map<String, HashCode> hashes = Maps.newHashMap();
    classes.visit(new FileVisitor() {
        public void visitDir(FileVisitDetails dirDetails) {
        }

        public void visitFile(FileVisitDetails fileDetails) {
            analyzer.visitFile(fileDetails);
            String className = fileDetails.getPath().replaceAll("/", ".").replaceAll("\\.class$", "");
            HashCode classHash = hasher.hash(fileDetails.getFile());
            hashes.put(className, classHash);
        }
    });

    return new JarSnapshot(new JarSnapshotData(hash, hashes, analyzer.getAnalysis()));
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:DefaultJarSnapshotter.java

示例11: getModelResourceLocation

import com.google.common.collect.Maps; //导入依赖的package包/类
protected ModelResourceLocation getModelResourceLocation(IBlockState state)
{
    Map < IProperty<?>, Comparable<? >> map = Maps. < IProperty<?>, Comparable<? >> newLinkedHashMap(state.getProperties());
    String s;

    if (this.name == null)
    {
        s = ((ResourceLocation)Block.REGISTRY.getNameForObject(state.getBlock())).toString();
    }
    else
    {
        s = this.removeName(this.name, map);
    }

    if (this.suffix != null)
    {
        s = s + this.suffix;
    }

    for (IProperty<?> iproperty : this.ignored)
    {
        map.remove(iproperty);
    }

    return new ModelResourceLocation(s, this.getPropertyString(map));
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:27,代码来源:StateMap.java

示例12: assertRequestHeaders

import com.google.common.collect.Maps; //导入依赖的package包/类
private void assertRequestHeaders(HttpHeaders actualHeaders, Object requestObject, Map<String, Matcher<? super List<String>>> additionalExpectedHeaders) {
    Map<String, Matcher<? super List<String>>> expectedHeaders = new HashMap<>();

    if (requestObject != null && requestObject instanceof HttpEntity) {
        HttpEntity httpEntity = (HttpEntity) requestObject;
        HttpHeaders headers = httpEntity.getHeaders();
        Map<String, Matcher<List<String>>> stringMatcherMap = Maps.transformValues(headers, new Function<List<String>, Matcher<List<String>>>() {
            @Override
            public Matcher<List<String>> apply(List<String> input) {
                return is(input);
            }
        });
        expectedHeaders.putAll(stringMatcherMap);
    }

    expectedHeaders.putAll(additionalExpectedHeaders);

    Set<String> headerNames = expectedHeaders.keySet();
    for (String headerName : headerNames) {
        Matcher<? super List<String>> headerValuesMatcher = expectedHeaders.get(headerName);
        assertThat(format("Contains header %s", headerName), actualHeaders.containsKey(headerName), is(true));
        assertThat(format("'%s' header value fails assertion", headerName), actualHeaders.get(headerName), headerValuesMatcher);
    }
}
 
开发者ID:tyro,项目名称:pact-spring-mvc,代码行数:25,代码来源:ReturnExpect.java

示例13: getClassForIdentifier

import com.google.common.collect.Maps; //导入依赖的package包/类
private static Class<? extends TokenIdentifier>
    getClassForIdentifier(Text kind) {
  Class<? extends TokenIdentifier> cls = null;
  synchronized (Token.class) {
    if (tokenKindMap == null) {
      tokenKindMap = Maps.newHashMap();
      for (TokenIdentifier id : ServiceLoader.load(TokenIdentifier.class)) {
        tokenKindMap.put(id.getKind(), id.getClass());
      }
    }
    cls = tokenKindMap.get(kind);
  }
  if (cls == null) {
    LOG.warn("Cannot find class for token kind " + kind);
    return null;
  }
  return cls;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:19,代码来源:Token.java

示例14: filter

import com.google.common.collect.Maps; //导入依赖的package包/类
private Set<Integer> filter(final List<SelectieAutorisatiebundel> autorisatiebundels, final Collection<Persoonslijst> lijstMetPersonen) {
    final Set<Integer> ongeldigeSelectietaken = Sets.newHashSet();
    final Map<Long, ZonedDateTime> gbaSystematiekMap = Maps.newHashMap();
    for (Persoonslijst persoonslijst : lijstMetPersonen) {
        //we berekenen dit nu altijd. We zouden ook kunnen detecteren dat peilmoment formeel niet is gezet vanuit beheer maar op 'nu' is gezet in
        // selectie run voor alle taken.
        final ZonedDateTime laatsteWijzigingGBASystematiek = persoonslijst.bepaalTijdstipLaatsteWijzigingGBASystematiek();
        gbaSystematiekMap.put(persoonslijst.getId(), laatsteWijzigingGBASystematiek);
    }
    for (SelectieAutorisatiebundel autorisatiebundel : autorisatiebundels) {
        //alleen voor standaard selectie relevant en als peilmoment formeel gezet
        if (isStandaardSelectie(autorisatiebundel.getAutorisatiebundel().getDienst())
                && autorisatiebundel.getSelectieAutorisatieBericht().getPeilmomentFormeel() != null) {
            bepaalOngeldigeSelectietaak(lijstMetPersonen, ongeldigeSelectietaken, gbaSystematiekMap, autorisatiebundel);
        }
    }
    return ongeldigeSelectietaken;
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:19,代码来源:SelectieTaakVerwerkerImpl.java

示例15: render

import com.google.common.collect.Maps; //导入依赖的package包/类
private String render(Renderable renderable, PebbleTemplate template) {
	try {
		StringWriter writer=new StringWriter();
		
		PebbleWrapper it = PebbleWrapper.builder()
				.markupRenderFactory(markupRenderFactory)
				.context(renderable.context())
				.addAllAllBlobs(renderable.blobs())
				.build();
		
		template.evaluate(writer, Maps.newLinkedHashMap(ImmutableMap.of("it",it)));
		return writer.toString();
	} catch (PebbleException | IOException | RuntimePebbleException px) {
		throw new RuntimeException("rendering fails for "+template.getName(),px);
	}
}
 
开发者ID:flapdoodle-oss,项目名称:de.flapdoodle.solid,代码行数:17,代码来源:PebbleTheme.java


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