本文整理汇总了Java中java.util.Map.Entry类的典型用法代码示例。如果您正苦于以下问题:Java Entry类的具体用法?Java Entry怎么用?Java Entry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Entry类属于java.util.Map包,在下文中一共展示了Entry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createRangeQuery
import java.util.Map.Entry; //导入依赖的package包/类
private static RangeQueryBuilder createRangeQuery(String name, Map<String, Object> rangeOperation,
Float boost) {
RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery(name+RAW_APPEND);
for (Map.Entry<String, Object> it : rangeOperation.entrySet()) {
if (it.getKey().equalsIgnoreCase(LTE)) {
rangeQueryBuilder.lte(it.getValue());
} else if (it.getKey().equalsIgnoreCase(LT)) {
rangeQueryBuilder.lt(it.getValue());
} else if (it.getKey().equalsIgnoreCase(GTE)) {
rangeQueryBuilder.gte(it.getValue());
} else if (it.getKey().equalsIgnoreCase(GT)) {
rangeQueryBuilder.gt(it.getValue());
}
}
if (isNotNull(boost)) {
return rangeQueryBuilder.boost(boost);
}
return rangeQueryBuilder;
}
示例2: toXml
import java.util.Map.Entry; //导入依赖的package包/类
/**
* 微信下单map to xml
*
* @param params
* 参数
* @return String
*/
public static String toXml(Map<String, String> params) {
StringBuilder xml = new StringBuilder();
xml.append("<xml>");
for (Entry<String, String> entry : params.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
// 略过空值
if (StringUtils.isBlank(value))
continue;
xml.append("<").append(key).append(">");
xml.append(entry.getValue());
xml.append("</").append(key).append(">");
}
xml.append("</xml>");
return xml.toString();
}
示例3: toJsonableMap
import java.util.Map.Entry; //导入依赖的package包/类
public static Map<String,Object> toJsonableMap(Map<String,Object> stringKeyMap){
Map<String,Object> jsonableMap = new HashMap<String,Object>();
for (Entry<String, Object> es : stringKeyMap.entrySet()){
String stringKey = es.getKey();
if (stringKey.contains(".")){
stringKey = stringKey.replace(".", "->");
String[] arr = stringKey.split("->");
String jsonKey = arr[0];
String propKey = arr[1];
Object obj = jsonableMap.get(jsonKey);
Map<String,Object> objMap = null;
if (Objects.isNull(obj)){
objMap = new HashMap<String,Object>();
jsonableMap.put(jsonKey, objMap);
}else {
objMap = (Map<String,Object>) obj;
}
objMap.put(propKey, es.getValue());
}else{
jsonableMap.put(stringKey, es.getValue());
}
}
return jsonableMap;
}
示例4: createNlpContext
import java.util.Map.Entry; //导入依赖的package包/类
protected NlpContext createNlpContext(final Result aiResponseResult) {
final NlpContext result = new NlpContext();
if (aiResponseResult.getMetadata() != null) {
final NlpIntent nlpIntent = createNlpIntent(aiResponseResult);
result.addIntent(nlpIntent);
}
if (aiResponseResult.getParameters() != null) {
for (final Entry<String, JsonElement> entry : aiResponseResult.getParameters().entrySet()) {
final NlpNamedEntity nlpNamedEntity = createNamedEntity(entry);
result.addNamedEntity(nlpNamedEntity);
}
}
return result;
}
示例5: create
import java.util.Map.Entry; //导入依赖的package包/类
static <KEY, RESULT> QuorumCall<KEY, RESULT> create(
Map<KEY, ? extends ListenableFuture<RESULT>> calls) {
final QuorumCall<KEY, RESULT> qr = new QuorumCall<KEY, RESULT>();
for (final Entry<KEY, ? extends ListenableFuture<RESULT>> e : calls.entrySet()) {
Preconditions.checkArgument(e.getValue() != null,
"null future for key: " + e.getKey());
Futures.addCallback(e.getValue(), new FutureCallback<RESULT>() {
@Override
public void onFailure(Throwable t) {
qr.addException(e.getKey(), t);
}
@Override
public void onSuccess(RESULT res) {
qr.addResult(e.getKey(), res);
}
});
}
return qr;
}
示例6: generateCandidatesForLevel
import java.util.Map.Entry; //导入依赖的package包/类
private Set<InclusionDependency> generateCandidatesForLevel(int i) {
Set<ColumnIdentifier> unaryIndNodes = new HashSet<>();
// INDs from one table (dep & ref from same table) generate invalid INDs
if (INCLUDE_INDS_FROM_ONE_TABLE) {
unaryIndNodes = unaryIndMap.keySet();
} else {
unaryIndNodes = unaryIndMap.entrySet().stream()
.filter(e -> !e.getKey().getTableIdentifier().equals(e.getValue().getTableIdentifier()))
.map(Entry::getKey)
.collect(Collectors.toSet());
}
Set<Set<ColumnIdentifier>> indsForLevel = Sets.combinations(unaryIndNodes,i);
System.out.println("Combinations for level " + i + " : " + indsForLevel.toString());
return indsForLevel.stream()
.map(this::nodeToInd)
.collect(Collectors.toSet());
}
示例7: assertCorrectEntriesInDatasetFileToLearningAlgorithmsMap
import java.util.Map.Entry; //导入依赖的package包/类
/**
* Checks if the given map contains all {@link ILearningAlgorithm}'s which are using relative
* datasets.
*
* @param datasetFileToLearningAlgorithmsMap the map resulting after execution of the
* {@link DetermineApplicableAlgorithmsCommand}
*/
private void assertCorrectEntriesInDatasetFileToLearningAlgorithmsMap(
Map<DatasetFile, List<ILearningAlgorithm>> datasetFileToLearningAlgorithmsMap) {
Assert.assertEquals(1, datasetFileToLearningAlgorithmsMap.size());
Set<String> allLearningAlgorithmsForRelativeDataset = getAllLearningAlgorithmClassNamesUsingRelativeDataset();
for (Entry<DatasetFile, List<ILearningAlgorithm>> entry : datasetFileToLearningAlgorithmsMap.entrySet()) {
Assert.assertEquals(allLearningAlgorithmsForRelativeDataset.size(), entry.getValue().size());
for (ILearningAlgorithm learningAlgorithm : entry.getValue()) {
String learningAlgorithmName = learningAlgorithm.toString();
if (allLearningAlgorithmsForRelativeDataset.contains(learningAlgorithmName)) {
allLearningAlgorithmsForRelativeDataset.remove(learningAlgorithmName);
} else {
Assert.fail(String.format(ERROR_ALGORITHM_NOT_USES_DATASET_BUT_IS_APPLICABLE, learningAlgorithmName,
DefaultDataset.class.getSimpleName()));
}
}
}
}
开发者ID:Intelligent-Systems-Group,项目名称:jpl-framework,代码行数:27,代码来源:DetermineApplicableAlgorithmsCommandTest.java
示例8: filterGroupOrVersion
import java.util.Map.Entry; //导入依赖的package包/类
/**
* 过滤一下:不符合标准的version, 含有: %
* @return
*/
private Map<String, byte[]> filterGroupOrVersion(Map<String, byte[]> dbAdd) throws Exception {
Map<String, byte[]> invalid = Maps.newHashMap();
for (Entry<String, byte[]> entry: dbAdd.entrySet()) {
try {
URL url = URL.valueOf(entry.getKey());
if (StringUtils.hasText(url.getParameter(Constants.VERSION_KEY))) {
if(url.getParameter(Constants.VERSION_KEY).contains("%")){
logger.warn("节点{}的version包含不支持的字符, 过滤不同步到db", url.toFullString());
invalid.put(url.toFullString(), entry.getValue());
}
}
} catch (Exception e) {
logger.error("filterGroupOrVersion error, key:" + entry.getKey(), e);
throw e;
}
}
return Maps.difference(dbAdd, invalid).entriesOnlyOnLeft();
}
示例9: mapThrowableFlat
import java.util.Map.Entry; //导入依赖的package包/类
/** Mapping without checking the cause (done in mapThrowable). */
protected Integer mapThrowableFlat(Throwable throwable) {
Class<? extends Throwable> throwableClass = throwable.getClass();
Integer resId = throwableToMsgIdMap.get(throwableClass);
if (resId == null) {
Class<? extends Throwable> closestClass = null;
Set<Entry<Class<? extends Throwable>, Integer>> mappings = throwableToMsgIdMap.entrySet();
for (Entry<Class<? extends Throwable>, Integer> mapping : mappings) {
Class<? extends Throwable> candidate = mapping.getKey();
if (candidate.isAssignableFrom(throwableClass)) {
if (closestClass == null || closestClass.isAssignableFrom(candidate)) {
closestClass = candidate;
resId = mapping.getValue();
}
}
}
}
return resId;
}
示例10: removeStaleSpans
import java.util.Map.Entry; //导入依赖的package包/类
/**
* Scans all of the cached spans in the in-memory representation, removing any for which files
* no longer exist.
*/
private void removeStaleSpans() {
Iterator<Entry<String, TreeSet<CacheSpan>>> iterator = cachedSpans.entrySet().iterator();
while (iterator.hasNext()) {
Entry<String, TreeSet<CacheSpan>> next = iterator.next();
Iterator<CacheSpan> spanIterator = next.getValue().iterator();
boolean isEmpty = true;
while (spanIterator.hasNext()) {
CacheSpan span = spanIterator.next();
if (!span.file.exists()) {
spanIterator.remove();
if (span.isCached) {
totalSpace -= span.length;
}
notifySpanRemoved(span);
} else {
isEmpty = false;
}
}
if (isEmpty) {
iterator.remove();
}
}
}
示例11: LocaleStore
import java.util.Map.Entry; //导入依赖的package包/类
/**
* Constructor.
*
* @param valueTextMap the map of values to text to store, assigned and not altered, not null
*/
LocaleStore(Map<TextStyle, Map<Long, String>> valueTextMap) {
this.valueTextMap = valueTextMap;
Map<TextStyle, List<Entry<String, Long>>> map = new HashMap<>();
List<Entry<String, Long>> allList = new ArrayList<>();
for (Map.Entry<TextStyle, Map<Long, String>> vtmEntry : valueTextMap.entrySet()) {
Map<String, Entry<String, Long>> reverse = new HashMap<>();
for (Map.Entry<Long, String> entry : vtmEntry.getValue().entrySet()) {
if (reverse.put(entry.getValue(), createEntry(entry.getValue(), entry.getKey())) != null) {
// TODO: BUG: this has no effect
continue; // not parsable, try next style
}
}
List<Entry<String, Long>> list = new ArrayList<>(reverse.values());
Collections.sort(list, COMPARATOR);
map.put(vtmEntry.getKey(), list);
allList.addAll(list);
map.put(null, allList);
}
Collections.sort(allList, COMPARATOR);
this.parsable = map;
}
示例12: toXml
import java.util.Map.Entry; //导入依赖的package包/类
/**
* 微信下单map to xml
*
* @param params
* 参数
* @return {String}
*/
public static String toXml(Map<String, String> params) {
StringBuilder xml = new StringBuilder();
xml.append("<xml>");
for (Entry<String, String> entry : params.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
// 略过空值
if (StrKit.isBlank(value))
continue;
xml.append("<").append(key).append(">");
xml.append(entry.getValue());
xml.append("</").append(key).append(">");
}
xml.append("</xml>");
return xml.toString();
}
示例13: accept
import java.util.Map.Entry; //导入依赖的package包/类
@Override
public boolean accept(Object object, FailedReason failedReason) {
if (null == object) {
return false;
}
for (Entry<String, List<AbstractConditionValidator>> validators : validatorsMap.entrySet()) {
List<AbstractConditionValidator> cs = validators.getValue();
String fieldName = validators.getKey();
Object fieldValue = fields.get(fieldName).get(object);
for (AbstractConditionValidator abstractConditionValidator : cs) {
if (!abstractConditionValidator.accept(fieldValue)) {
failedReason.setReason(abstractConditionValidator.refuseReason()).setFieldName(fieldName);
return false;
}
}
}
return true;
}
示例14: testAsMapGet
import java.util.Map.Entry; //导入依赖的package包/类
public void testAsMapGet() {
for (K key : sampleKeys()) {
List<V> expectedValues = new ArrayList<V>();
for (Entry<K, V> entry : getSampleElements()) {
if (entry.getKey().equals(key)) {
expectedValues.add(entry.getValue());
}
}
Collection<V> collection = multimap().asMap().get(key);
if (expectedValues.isEmpty()) {
assertNull(collection);
} else {
assertEqualIgnoringOrder(expectedValues, collection);
}
}
}
示例15: tickTriangs
import java.util.Map.Entry; //导入依赖的package包/类
public void tickTriangs() {
for (Entry<String, AddonPlayerInfo> entry : playerInfos.entrySet()) {
EntityPlayer player = ServerUtils.getPlayer(entry.getKey());
for (Integer freq : entry.getValue().triangSet) {
double spinto;
if (!RedstoneEther.server().isFreqOn(freq)) {
spinto = -1;
} else if (isRemoteOn(player, freq)) {
spinto = -2;
} else {
Vector3 strengthvec = getBroadcastVector(player, freq);
if (strengthvec == null)//in another dimension
{
spinto = -2;//spin to a random place
} else {
spinto = (player.rotationYaw + 180) * MathHelper.torad - Math.atan2(-strengthvec.x, strengthvec.z);//spin to the transmitter vec
}
}
WRServerPH.sendTriangAngleTo(player, freq, (float) spinto);
}
}
}