java.util.Map.Entry#setValue ( )源码实例Demo

下面列出了java.util.Map.Entry#setValue ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ToroQuest   文件: Timer.java
private Runnable popRunQueue() {
	Entry<Runnable, Integer> next = null;
	for (Entry<Runnable, Integer> n : queue.entrySet()) {
		next = n;
		break;
	}

	if (next == null) {
		return null;
	}

	if (next.getValue() < 1) {
		queue.remove(next.getKey());
		return next.getKey();
	} else {
		next.setValue(next.getValue() - 1);
		return null;
	}
}
 
@Override
public void loadDefaults() {
	if(project == null) {
		return;
	}
	
	ProjectBuildInfo buildInfo;
	try {
		buildInfo = getBuildInfo();
	} catch(CommonException e) {
		UIOperationsStatusHandler.handleStatus(true, "Error loading defaults", e);
		return;
	}
	
	for (Entry<String, BuildTargetData> entry : buildOptionsToChange) {
		String targetName = entry.getKey();
		BuildTargetData newData = buildInfo.getDefaultBuildTarget(targetName).getDataCopy(); 
		entry.setValue(newData);
	}
	handleBuildTargetChanged();
}
 
源代码3 项目: scava   文件: ReadmeSimilarityCalculator.java
private HashMap<String, Integer> getAllTerms() throws IOException {
	HashMap<String, Integer> allTerms = new HashMap<>();
	int pos = 0;
	for (int docId = 0; docId < getTotalDocumentInIndex(); docId++) {
		Terms vector = getIndexReader().getTermVector(docId, FIELD_CONTENT);
		TermsEnum termsEnum = null;
		termsEnum = vector.iterator();
		BytesRef text = null;
		while ((text = termsEnum.next()) != null) {
			String term = text.utf8ToString();
			allTerms.put(term, pos++);
		}
	}

	// Update postition
	pos = 0;
	for (Entry<String, Integer> s : allTerms.entrySet()) {
		s.setValue(pos++);
	}
	return allTerms;
}
 
源代码4 项目: PlayerVaults   文件: Serialization.java
@Deprecated
private static Map<String, Object> handleSerialization(Map<String, Object> map) {
    Map<String, Object> serialized = recreateMap(map);
    for (Entry<String, Object> entry : serialized.entrySet()) {
        if (entry.getValue() instanceof ConfigurationSerializable) {
            entry.setValue(serialize((ConfigurationSerializable) entry.getValue()));
        } else if (entry.getValue() instanceof Iterable<?>) {
            List<Object> newList = new ArrayList<>();
            for (Object object : ((Iterable<?>) entry.getValue())) {
                if (object instanceof ConfigurationSerializable) {
                    object = serialize((ConfigurationSerializable) object);
                }
                newList.add(object);
            }
            entry.setValue(newList);
        } else if (entry.getValue() instanceof Map<?, ?>) {
            // unchecked cast here.  If you're serializing to a non-standard Map you deserve ClassCastExceptions
            entry.setValue(handleSerialization((Map<String, Object>) entry.getValue()));
        }
    }
    return serialized;
}
 
源代码5 项目: scava   文件: MapInterfaceTest.java
public void testEntrySetSetValue() {
    // TODO: Investigate the extent to which, in practice, maps that support
    // put() also support Entry.setValue().
    if (!supportsPut || !supportsEntrySetValue) {
        return;
    }

    final Map<K, V> map;
    final V valueToSet;
    try {
        map = makePopulatedMap();
        valueToSet = getValueNotInPopulatedMap();
    } catch (UnsupportedOperationException e) {
        return;
    }

    Set<Entry<K, V>> entrySet = map.entrySet();
    Entry<K, V> entry = entrySet.iterator().next();
    final V oldValue = entry.getValue();
    final V returnedValue = entry.setValue(valueToSet);
    assertEquals(oldValue, returnedValue);
    assertTrue(entrySet.contains(
            mapEntry(entry.getKey(), valueToSet)));
    assertEquals(valueToSet, map.get(entry.getKey()));
    assertInvariants(map);
}
 
源代码6 项目: codebuff   文件: MapConstraints.java
/**
 * Returns a constrained view of the specified entry, using the specified
 * constraint. The {@link Entry#setValue} operation will be verified with the
 * constraint.
 *
 * @param entry the entry to constrain
 * @param constraint the constraint for the entry
 * @return a constrained view of the specified entry
 */

private static <K, V> Entry<K, V> constrainedEntry(
  final Entry<K, V> entry, final MapConstraint<? super K, ? super V> constraint) {
  checkNotNull(entry);
  checkNotNull(constraint);
  return new ForwardingMapEntry<K, V>() {
    @Override
    protected Entry<K, V> delegate() {
      return entry;
    }

    @Override
    public V setValue(V value) {
      constraint.checkKeyValue(getKey(), value);
      return entry.setValue(value);
    }
  };
}
 
/**
 * Find any fields that look like WKT or EWKT and replace them with the database-specific value.
 */
@Override
public Sql[] generateSql(final InsertStatement statement, final Database database,
      final SqlGeneratorChain sqlGeneratorChain) {
   for (final Entry<String, Object> entry : statement.getColumnValues().entrySet()) {
      entry.setValue(handleColumnValue(entry.getValue(), database));
   }
   return super.generateSql(statement, database, sqlGeneratorChain);
}
 
源代码8 项目: denominator   文件: Denominator.java
@Override
public Map<String, Object> read(JsonReader in) throws IOException {
  Map<String, Object> map = delegate.read(in);
  for (Entry<String, Object> entry : map.entrySet()) {
    if (entry.getValue() instanceof Double) {
      entry.setValue(Double.class.cast(entry.getValue()).intValue());
    }
  }
  return map;
}
 
源代码9 项目: streaminer   文件: MapCategoricalTarget.java
@Override
protected MapCategoricalTarget mult(double multiplier) {
 for (Entry<Object, Double> categoryCount : getCounts().entrySet()) {
   categoryCount.setValue(categoryCount.getValue() * multiplier);
 }

 return this;
}
 
源代码10 项目: rtc2jira   文件: Settings.java
void setProperties(Properties props) {
  for (Entry<Object, Object> entry : props.entrySet()) {
    if (entry.getValue() != null) {
      entry.setValue(entry.getValue().toString().trim());
    }
  }
  this.props = props;
}
 
源代码11 项目: jstarcraft-ai   文件: ShareVertex.java
public ShareVertex(String name, MathCache factory, int numberOfShares, Layer layer, Learner learner, Normalizer normalizer) {
    super(name, factory, layer, learner, normalizer);
    this.numberOfShares = numberOfShares;
    this.vertexGradients = new HashMap<>(layer.getGradients());
    for (Entry<String, MathMatrix> term : vertexGradients.entrySet()) {
        MathMatrix matrix = term.getValue();
        matrix = factory.makeMatrix(matrix.getRowSize(), matrix.getColumnSize());
        term.setValue(matrix);
    }
}
 
源代码12 项目: AppTroy   文件: DexWriter.java
private void writeTypeLists(@Nonnull DexDataWriter writer) throws IOException {
    writer.align();
    typeListSectionOffset = writer.getPosition();
    for (Entry<? extends TypeListKey, Integer> entry: typeListSection.getItems()) {
        writer.align();
        entry.setValue(writer.getPosition());

        Collection<? extends TypeKey> types = typeListSection.getTypes(entry.getKey());
        writer.writeInt(types.size());
        for (TypeKey typeKey: types) {
            writer.writeUshort(typeSection.getItemIndex(typeKey));
        }
    }
}
 
源代码13 项目: CodeChickenLib   文件: InsnListSection.java
public Map<LabelNode, LabelNode> cloneLabels() {
    Map<LabelNode, LabelNode> labelMap = identityLabelMap();
    for(Entry<LabelNode, LabelNode> entry : labelMap.entrySet())
        entry.setValue(new LabelNode());

    return labelMap;
}
 
源代码14 项目: apiman   文件: OrganizationResourceImpl.java
/**
 * Decrypt the endpoint properties
 */
private void decryptEndpointProperties(ApiVersionBean versionBean) {
    Map<String, String> endpointProperties = versionBean.getEndpointProperties();
    if (endpointProperties != null) {
        for (Entry<String, String> entry : endpointProperties.entrySet()) {
            DataEncryptionContext ctx = new DataEncryptionContext(
                    versionBean.getApi().getOrganization().getId(),
                    versionBean.getApi().getId(),
                    versionBean.getVersion(),
                    EntityType.Api);
            entry.setValue(encrypter.decrypt(entry.getValue(), ctx));
        }
    }
}
 
源代码15 项目: armeria   文件: DefaultAttributeMap.java
@Override
public T setValue(T value) {
    final Entry<AttributeKey<T>, T> childAttr = this.childAttr;
    if (childAttr == null) {
        this.childAttr = setAttr(rootAttr.getKey(), value, false);
        return rootAttr.getValue();
    }

    final T old = childAttr.getValue();
    childAttr.setValue(value);
    return old;
}
 
源代码16 项目: vividus   文件: ConfigurationResolver.java
public static ConfigurationResolver getInstance() throws IOException
{
    if (instance != null)
    {
        return instance;
    }

    PropertiesLoader propertiesLoader = new PropertiesLoader(BeanFactory.getResourcePatternResolver());

    Properties configurationProperties = propertiesLoader.loadFromSingleResource("configuration.properties");
    Properties overridingProperties = propertiesLoader.loadFromOptionalResource("overriding.properties");

    Properties properties = new Properties();
    properties.putAll(configurationProperties);
    properties.putAll(propertiesLoader.loadFromResourceTreeRecursively("defaults"));

    Multimap<String, String> configuration = assembleConfiguration(configurationProperties, overridingProperties);
    for (Entry<String, String> configurationEntry : configuration.entries())
    {
        properties.putAll(propertiesLoader.loadFromResourceTreeRecursively(configurationEntry.getKey(),
                configurationEntry.getValue()));
    }

    properties.putAll(propertiesLoader.loadFromResourceTreeRecursively(ROOT));

    Properties deprecatedProperties = propertiesLoader.loadFromResourceTreeRecursively("deprecated");
    DeprecatedPropertiesHandler deprecatedPropertiesHandler = new DeprecatedPropertiesHandler(
            deprecatedProperties, PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX);
    deprecatedPropertiesHandler.replaceDeprecated(properties);

    Properties overridingAndSystemProperties = new Properties();
    overridingAndSystemProperties.putAll(overridingProperties);
    overridingAndSystemProperties.putAll(System.getenv());
    overridingAndSystemProperties.putAll(loadFilteredSystemProperties());

    deprecatedPropertiesHandler.replaceDeprecated(overridingAndSystemProperties, properties);

    properties.putAll(overridingAndSystemProperties);

    resolveSpelExpressions(properties, true);

    PropertyPlaceholderHelper propertyPlaceholderHelper = createPropertyPlaceholderHelper(false);

    for (Entry<Object, Object> entry : properties.entrySet())
    {
        String key = (String) entry.getKey();
        String value = (String) entry.getValue();
        deprecatedPropertiesHandler.warnIfDeprecated(key, value);
        entry.setValue(propertyPlaceholderHelper.replacePlaceholders(value, properties::getProperty));
    }
    deprecatedPropertiesHandler.removeDeprecated(properties);
    resolveSpelExpressions(properties, false);
    processSystemProperties(properties);

    instance = new ConfigurationResolver(properties);
    return instance;
}
 
源代码17 项目: 1.13-Command-API   文件: CommandAPI.java
static void register(String commandName, CommandPermission permissions, String[] aliases, LinkedHashMap<String, Argument> args, CustomCommandExecutor executor) {
	if(!canRegister) {
		CommandAPIMain.getLog().severe("Cannot register command /" + commandName + ", because the server has finished loading!");
		return;
	}
	try {

		//Sanitize commandNames
		if(commandName == null || commandName.length() == 0) {
			throw new InvalidCommandNameException(commandName);
		}
		
		//Make a local copy of args to deal with
		@SuppressWarnings("unchecked")
		LinkedHashMap<String, Argument> copyOfArgs = args == null ? new LinkedHashMap<>() : (LinkedHashMap<String, Argument>) args.clone();
		
		//if args contains a GreedyString && args.getLast != GreedyString
		long numGreedyArgs = copyOfArgs.values().stream().filter(arg -> arg instanceof IGreedyArgument).count();
		if(numGreedyArgs >= 1) {
			//A GreedyString has been found
			if(!(copyOfArgs.values().toArray()[copyOfArgs.size() - 1] instanceof IGreedyArgument)) {
				throw new GreedyArgumentException();
			}
			
			if(numGreedyArgs > 1) {
				throw new GreedyArgumentException();
			}
		}
		
		//Reassign permissions to arguments if not declared
		for(Entry<String, Argument> entry : copyOfArgs.entrySet()) {
			if(entry.getValue().getArgumentPermission() == null) {
				entry.setValue(entry.getValue().withPermission(permissions));
			}
		}
		
		handler.register(commandName, permissions, aliases, copyOfArgs, executor);
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
源代码18 项目: openjdk-jdk8u   文件: Encodings.java
/**
 * Loads a list of all the supported encodings.
 *
 * System property "encodings" formatted using URL syntax may define an
 * external encodings list. Thanks to Sergey Ushakov for the code
 * contribution!
 */
private void loadEncodingInfo() {
    try {
        // load (java name)->(preferred mime name) mapping.
        final Properties props = loadProperties();

        // create instances of EncodingInfo from the loaded mapping
        Enumeration keys = props.keys();
        Map<String, EncodingInfo> canonicals = new HashMap<>();
        while (keys.hasMoreElements()) {
            final String javaName = (String) keys.nextElement();
            final String[] mimes = parseMimeTypes(props.getProperty(javaName));

            final String charsetName = findCharsetNameFor(javaName, mimes);
            if (charsetName != null) {
                final String kj = toUpperCaseFast(javaName);
                final String kc = toUpperCaseFast(charsetName);
                for (int i = 0; i < mimes.length; ++i) {
                    final String mimeName = mimes[i];
                    final String km = toUpperCaseFast(mimeName);
                    EncodingInfo info = new EncodingInfo(mimeName, charsetName);
                    _encodingTableKeyMime.put(km, info);
                    if (!canonicals.containsKey(kc)) {
                        // canonicals will map the charset name to
                        //   the info containing the prefered mime name
                        //   (the preferred mime name is the first mime
                        //   name in the list).
                        canonicals.put(kc, info);
                        _encodingTableKeyJava.put(kc, info);
                    }
                    _encodingTableKeyJava.put(kj, info);
                }
            } else {
                // None of the java or mime names on the line were
                // recognized => this charset is not supported?
            }
        }

        // Fix up the _encodingTableKeyJava so that the info mapped to
        // the java name contains the preferred mime name.
        // (a given java name can correspond to several mime name,
        //  but we want the _encodingTableKeyJava to point to the
        //  preferred mime name).
        for (Entry<String, EncodingInfo> e : _encodingTableKeyJava.entrySet()) {
            e.setValue(canonicals.get(toUpperCaseFast(e.getValue().javaName)));
        }

    } catch (java.net.MalformedURLException mue) {
        throw new com.sun.org.apache.xml.internal.serializer.utils.WrappedRuntimeException(mue);
    } catch (java.io.IOException ioe) {
        throw new com.sun.org.apache.xml.internal.serializer.utils.WrappedRuntimeException(ioe);
    }
}
 
源代码19 项目: jlogstash-input-plugin   文件: MonitorCluster.java
/**
 * 重置配置,默认都为false。
 */
private void resetChgInfo(){
	for(Entry<String, Boolean> tmp : infoChg.entrySet()){
		tmp.setValue(false);
	}
}
 
源代码20 项目: spf   文件: TreeHashVector.java
@Override
public void add(final double num) {
	for (final Entry<KeyArgs, Double> entry : values.entrySet()) {
		entry.setValue(entry.getValue() + num);
	}
}