本文整理汇总了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);
}
}
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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()));
}
示例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;
}
示例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;
}
示例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()));
}
示例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));
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
}