List of usage examples for com.google.common.collect ImmutableMap size
int size();
From source file:org.jclouds.sqs.options.CreateQueueOptions.java
@Override public Multimap<String, String> buildFormParameters() { Multimap<String, String> params = super.buildFormParameters(); ImmutableMap<String, String> attributes = this.attributes.build(); if (attributes.size() > 0) { int nameIndex = 1; for (Entry<String, String> attribute : attributes.entrySet()) { params.put("Attribute." + nameIndex + ".Name", attribute.getKey()); params.put("Attribute." + nameIndex + ".Value", attribute.getValue()); nameIndex++;/*from w ww. j a v a2 s .c o m*/ } } return params; }
From source file:com.google.devtools.build.lib.analysis.TransitiveInfoProviderMapOffsetBased.java
TransitiveInfoProviderMapOffsetBased( ImmutableMap<Class<? extends TransitiveInfoProvider>, TransitiveInfoProvider> map) { int count = map.size(); Class<? extends TransitiveInfoProvider>[] providerClasses = new Class[count]; this.providers = new TransitiveInfoProvider[count]; int i = 0;/*www . j ava 2 s .c o m*/ for (Entry<Class<? extends TransitiveInfoProvider>, TransitiveInfoProvider> entry : map.entrySet()) { providerClasses[i] = entry.getKey(); providers[i] = entry.getValue(); ++i; } OffsetTable offsetTable = new OffsetTable(providerClasses); this.offsetTable = offsetTables.intern(offsetTable); }
From source file:org.gradle.internal.execution.history.impl.DefaultPreviousExecutionStateSerializer.java
public void writeInputProperties(Encoder encoder, ImmutableMap<String, ValueSnapshot> properties) throws Exception { encoder.writeSmallInt(properties.size()); for (Map.Entry<String, ValueSnapshot> entry : properties.entrySet()) { encoder.writeString(entry.getKey()); writeValueSnapshot(encoder, entry.getValue()); }/*from w ww . jav a2 s. c o m*/ }
From source file:org.spongepowered.granite.mixin.block.state.MixinBlockState.java
@Override @SuppressWarnings("unchecked") public Collection<String> getPropertyNames() { ImmutableMap<IProperty, Comparable<?>> properties = ((IBlockState) this).getProperties(); List<String> names = Lists.newArrayListWithCapacity(properties.size()); for (IProperty property : properties.keySet()) { names.add(property.getName());/*from ww w. j a v a 2s . co m*/ } return Collections.unmodifiableCollection(names); }
From source file:com.google.devtools.build.lib.skyframe.serialization.ImmutableMapCodec.java
@Override public void serialize(SerializationContext context, ImmutableMap<?, V> map, CodedOutputStream codedOut) throws SerializationException, IOException { codedOut.writeInt32NoTag(map.size()); boolean serializeAsSortedMap = false; if (map instanceof ImmutableSortedMap) { Comparator<?> comparator = ((ImmutableSortedMap<?, ?>) map).comparator(); // In practice the comparator seems to always be Ordering.natural(), but be flexible. serializeAsSortedMap = comparator.equals(Ordering.natural()) || comparator.equals(Comparator.naturalOrder()); }// ww w.ja v a2s. c o m codedOut.writeBoolNoTag(serializeAsSortedMap); for (Map.Entry<?, ?> entry : map.entrySet()) { context.serialize(entry.getKey(), codedOut); try { context.serialize(entry.getValue(), codedOut); } catch (SerializationException | IOException e) { throw SerializationException .propagate(String.format("Exception while serializing value of type %s for key '%s'", entry.getValue().getClass().getName(), entry.getKey()), e); } } }
From source file:org.elasticsearch.rest.action.admin.indices.mapping.get.RestGetFieldMappingAction.java
/** * Helper method to find out if the only included fieldmapping metadata is typed NULL, which means * that type and index exist, but the field did not *//* w ww. j a va2 s. c om*/ private boolean isFieldMappingMissingField( ImmutableMap<String, ImmutableMap<String, ImmutableMap<String, FieldMappingMetaData>>> mappingsByIndex) throws IOException { if (mappingsByIndex.size() != 1) { return false; } for (ImmutableMap<String, ImmutableMap<String, FieldMappingMetaData>> value : mappingsByIndex.values()) { for (ImmutableMap<String, FieldMappingMetaData> fieldValue : value.values()) { for (Map.Entry<String, FieldMappingMetaData> fieldMappingMetaDataEntry : fieldValue.entrySet()) { if (fieldMappingMetaDataEntry.getValue().isNull()) { return true; } } } } return false; }
From source file:hmi.facegraphics.HMIFaceController.java
/** * NOTE: this function should be called in some synchronisation; to ensure that the values are not changed during the copy method! *///from w w w . ja v a2s. c o m public synchronized void copy() { if (glHead != null) { // send the new MPEG4 configuration for (FAP fap : MPEG4.getFAPs().values()) { Integer value = currentConfig.getValue(fap.getIndex()); if (value == null) continue; glHead.getDeformer(fap).setValue(value); } glHead.deformWhenScheduled(); } ImmutableMap<String, Float> desiredMorphTargets = morphTargetHandler.getDesiredMorphTargets(); String[] targetNames = new String[desiredMorphTargets.size()]; float[] targetWeights = new float[desiredMorphTargets.size()]; int i = 0; for (String targetName : desiredMorphTargets.keySet()) { targetNames[i] = targetName; targetWeights[i] = desiredMorphTargets.get(targetName); i++; } theGLScene.setMorphTargets(targetNames, targetWeights); }
From source file:org.lenskit.data.store.MapEntityCollectionBuilder.java
@Override public MapEntityCollection build() { Preconditions.checkState(store != null, "build() already called"); ImmutableMap.Builder<String, EntityIndex> indexes = ImmutableMap.builder(); for (Map.Entry<String, EntityIndexBuilder> e : indexBuilders.entrySet()) { indexes.put(e.getKey(), e.getValue().build()); }// w ww . j a v a 2 s . c om KeyedObjectMap<Entity> map = store.build(); ImmutableMap<String, EntityIndex> idxMap = indexes.build(); logger.debug("built collection of {} entities with type {} and {} indexes", map.size(), type, idxMap.size()); store = null; indexBuilders = null; return new MapEntityCollection(type, map, idxMap, hasher.hash()); }
From source file:org.jclouds.sqs.options.CreateQueueOptions.java
/** * {@inheritDoc}// ww w. ja v a2s . c om */ @Override public String toString() { ImmutableMap<String, String> attributes = this.attributes.build(); return Objects.toStringHelper(this).omitNullValues() .add("attributes", attributes.size() > 0 ? attributes : null).toString(); }
From source file:com.facebook.buck.android.StringResources.java
private void writePlurals(DataOutputStream outputStream) throws IOException { outputStream.writeInt(plurals.size()); if (plurals.isEmpty()) { return;//from w w w . j a v a 2 s.co m } int previousResourceId = plurals.firstKey(); outputStream.writeInt(previousResourceId); try (ByteArrayOutputStream dataStream = new ByteArrayOutputStream()) { for (Map.Entry<Integer, ImmutableMap<String, String>> entry : plurals.entrySet()) { writeShort(outputStream, entry.getKey() - previousResourceId); ImmutableMap<String, String> categoryMap = entry.getValue(); outputStream.writeByte(categoryMap.size()); for (Map.Entry<String, String> cat : categoryMap.entrySet()) { outputStream.writeByte(PLURAL_CATEGORY_MAP.get(cat.getKey()).byteValue()); byte[] pluralValue = getUnescapedStringBytes(cat.getValue()); writeShort(outputStream, pluralValue.length); dataStream.write(pluralValue); } previousResourceId = entry.getKey(); } outputStream.write(dataStream.toByteArray()); } }