List of usage examples for java.util Map.Entry get
V get(Object key);
From source file:org.jasig.cas.authentication.principal.AbstractPersonDirectoryCredentialsToPrincipalResolver.java
public final Principal resolvePrincipal(final Credentials credentials) { if (log.isDebugEnabled()) { log.debug("Attempting to resolve a principal..."); }/*from w ww.ja v a 2s . co m*/ final String principalId = extractPrincipalId(credentials); if (principalId == null) { return null; } if (log.isDebugEnabled()) { log.debug("Creating SimplePrincipal for [" + principalId + "]"); } final Map<String, List<Object>> attributes = this.attributeRepository .getMultivaluedUserAttributes(principalId); final Map<String, Object> convertedAttributes = new HashMap<String, Object>(); for (final Map.Entry<String, List<Object>> entry : attributes.entrySet()) { final String key = entry.getKey(); final Object value = entry.getValue().size() == 1 ? entry.getValue().get(0) : entry.getValue(); convertedAttributes.put(key, value); } return new SimplePrincipal(principalId, convertedAttributes); }
From source file:org.onosproject.teyang.utils.topology.NodeConverter.java
private static TeNodeAttributesBuilder te2YangConnectivityMatrix( TeNodeAttributesBuilder teNodeAttributesConfigBuilder, Map<Long, ConnectivityMatrix> connectivityMatrices) { ConnectivityMatrixBuilder connectivityMatrixConfigBuilder = DefaultConnectivityMatrix.builder(); ConnectivityMatricesBuilder yangConnectivityMatricesBuilder = DefaultConnectivityMatrices.builder(); for (Map.Entry<Long, ConnectivityMatrix> teCmEntry : connectivityMatrices.entrySet()) { connectivityMatrixConfigBuilder = connectivityMatrixConfigBuilder.id(teCmEntry.getKey()) .isAllowed(!teCmEntry.getValue().flags().get(ConnectivityMatrix.BIT_DISALLOWED)) .from(new DefaultFrom.FromBuilder() // TODO: for now, assuming that there is // only one 'from', and mergingList is empty .tpRef(((TeLinkId) teCmEntry.getValue().from()).value()).build()) .to(new DefaultTo.ToBuilder() // TODO: for now, assuming that there is only // one item in constrainingElements list .tpRef(((TeLinkId) teCmEntry.getValue().constrainingElements().get(0)).value()) .build());//from w w w .j a v a2 s . com if (teCmEntry.getValue().teAttributes() != null) { connectivityMatrixConfigBuilder = connectivityMatrixConfigBuilder .teDefaultMetric(teCmEntry.getValue().teAttributes().cost()) .teDelayMetric(teCmEntry.getValue().teAttributes().delay()); } TeSrlgs.TeSrlgsBuilder teSrlgsBuilder = DefaultTeSrlgs.builder(); if (teCmEntry.getValue().teAttributes().srlgs() != null) { for (Long val : teCmEntry.getValue().teAttributes().srlgs()) { Srlg srlg = new Srlg(val); teSrlgsBuilder = teSrlgsBuilder.addToValue(srlg); } connectivityMatrixConfigBuilder = connectivityMatrixConfigBuilder.teSrlgs(teSrlgsBuilder.build()); } Underlay.UnderlayBuilder underlayBuilder = DefaultUnderlay.builder(); PrimaryPath.PrimaryPathBuilder primaryPathBuilder = DefaultPrimaryPath.builder(); PathElement.PathElementBuilder pathElementBuilder = DefaultPathElement.builder(); if (teCmEntry.getValue().underlayPath() != null && teCmEntry.getValue().underlayPath().pathElements() != null && !teCmEntry.getValue().underlayPath().pathElements().isEmpty()) { for (org.onosproject.tetopology.management.api.link.PathElement patel : teCmEntry.getValue() .underlayPath().pathElements()) { pathElementBuilder = pathElementBuilder.pathElementId(patel.pathElementId()); if (patel.type() instanceof AsNumber) { org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.explicitroutesubobject.type.AsNumber.AsNumberBuilder asNumberBuilder = new DefaultAsNumber.AsNumberBuilder(); asNumberBuilder = asNumberBuilder.asNumber(((AsNumber) patel.type()).asNumber()); pathElementBuilder = pathElementBuilder.type(asNumberBuilder.build()); } else if (patel.type() instanceof UnnumberedLink) { org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.explicitroutesubobject.type.UnnumberedLink.UnnumberedLinkBuilder unNumberBuilder = DefaultUnnumberedLink .builder(); unNumberBuilder = unNumberBuilder .interfaceId(((UnnumberedLink) patel.type()).interfaceId()); unNumberBuilder = unNumberBuilder.routerId( IpAddress.fromString(((UnnumberedLink) patel.type()).routerId().toString())); pathElementBuilder = pathElementBuilder.type(unNumberBuilder.build()); } primaryPathBuilder = primaryPathBuilder.addToPathElement(pathElementBuilder.build()); } } underlayBuilder = underlayBuilder.primaryPath(primaryPathBuilder.build()); connectivityMatrixConfigBuilder = connectivityMatrixConfigBuilder.underlay(underlayBuilder.build()); yangConnectivityMatricesBuilder = yangConnectivityMatricesBuilder .addToConnectivityMatrix(connectivityMatrixConfigBuilder.build()); } teNodeAttributesConfigBuilder = teNodeAttributesConfigBuilder .connectivityMatrices(yangConnectivityMatricesBuilder.build()); return teNodeAttributesConfigBuilder; }
From source file:cn.cnic.bigdatalab.flume.sink.mongodb.MappingDefinition.java
private FieldDefinition populateFieldDefinition(Map.Entry<String, JsonNode> entry) { String type = entry.getValue().get(TYPE).asText().toUpperCase(Locale.ENGLISH); FieldDefinition fieldDefinition = null; switch (MongoDataType.valueOf(type)) { case DATE://from w w w. j av a 2 s.c o m fieldDefinition = new DateFieldDefinition(entry.getKey()); populateDateFormatField(entry, (DateFieldDefinition) fieldDefinition); break; case DOCUMENT: fieldDefinition = new DocumentFieldDefinition(entry.getKey()); populateDocumentType(entry, (DocumentFieldDefinition) fieldDefinition); break; default: fieldDefinition = new SimpleFieldDefinition(entry.getKey(), MongoDataType.valueOf(type)); populateMappedFromField(entry, (SimpleFieldDefinition) fieldDefinition); } return fieldDefinition; }
From source file:it.polimi.diceH2020.SPACE4Cloud.shared.inputDataMultiProvider.JobProfilesMap.java
@JsonIgnore public Map<String, Map<String, JobProfile>> get_IdVMTypes_Map(String provider) { Map<String, Map<String, JobProfile>> idAndTypes = new HashMap<String, Map<String, JobProfile>>(); for (Map.Entry<String, Map<String, Map<String, JobProfile>>> jobIDs : getMapJobProfile().entrySet()) { idAndTypes.put(jobIDs.getKey(), jobIDs.getValue().get(provider)); }// w w w .j a v a2 s . c o m return idAndTypes; }
From source file:com.epam.ta.reportportal.core.widget.content.CasesTrendContentLoader.java
/** * Calculation of group differences between TOTAL parameter of items * /* w w w. j av a 2 s .c om*/ * @param initial * @param sorting * @return */ private Map<String, List<ChartObject>> calculateGroupedDiffs(Map<String, List<ChartObject>> initial, Sort sorting) { if (initial.keySet().isEmpty()) return new HashMap<>(); if (sorting.toString().contains(Sort.Direction.ASC.name())) { ArrayList<String> keys = new ArrayList<>(initial.keySet()); /* Last element in map */ Integer previous = Integer .valueOf(initial.get(keys.get(keys.size() - 1)).get(0).getValues().get(getTotalFieldName())); /* Iteration in reverse order */ for (int i = keys.size() - 1; i >= 0; i--) { Integer current = Integer .valueOf(initial.get(keys.get(i)).get(0).getValues().get(getTotalFieldName())); initial.get(keys.get(i)).get(0).getValues().put(DELTA, String.valueOf(current - previous)); previous = current; } } else { Integer previous = Integer.valueOf( initial.get(initial.keySet().iterator().next()).get(0).getValues().get(getTotalFieldName())); for (Map.Entry<String, List<ChartObject>> entry : initial.entrySet()) { Integer current = Integer.valueOf(entry.getValue().get(0).getValues().get(getTotalFieldName())); entry.getValue().get(0).getValues().put(DELTA, String.valueOf(current - previous)); previous = current; } } return initial; }
From source file:it.polimi.diceH2020.SPACE4Cloud.shared.inputDataMultiProvider.PublicCloudParametersMap.java
@JsonIgnore public Map<String, Map<String, PublicCloudParameters>> get_IdVMTypes_Map(String provider) { Map<String, Map<String, PublicCloudParameters>> idAndTypes = new HashMap<String, Map<String, PublicCloudParameters>>(); for (Map.Entry<String, Map<String, Map<String, PublicCloudParameters>>> jobIDs : mapPublicCloudParameters .entrySet()) {//from w w w .j ava2s . c om idAndTypes.put(jobIDs.getKey(), jobIDs.getValue().get(provider)); } return idAndTypes; }
From source file:org.opendaylight.ovsdb.lib.schema.TableSchema.java
public TableUpdate<E> updatesFromJson(JsonNode value) { TableUpdate<E> tableUpdate = new TableUpdate<>(); Iterator<Entry<String, JsonNode>> fields = value.fields(); while (fields.hasNext()) { Map.Entry<String, JsonNode> idOldNew = fields.next(); String uuid = idOldNew.getKey(); ObjectNode newObjectNode = (ObjectNode) idOldNew.getValue().get("new"); ObjectNode oldObjectNode = (ObjectNode) idOldNew.getValue().get("old"); Row<E> newRow = newObjectNode != null ? createRow(newObjectNode) : null; Row<E> oldRow = oldObjectNode != null ? createRow(oldObjectNode) : null; tableUpdate.addRow(new UUID(uuid), oldRow, newRow); }/* w w w .j ava 2 s . c om*/ return tableUpdate; }
From source file:com.mac.holdempoker.app.hands.Pair.java
private Card[] findPair() { List<Card> pair = new ArrayList(); List<Card> singles = new ArrayList(); for (Map.Entry<Rank, List<Card>> entry : cards.entrySet()) { if (entry.getValue().size() == 2 && pair.isEmpty()) { pair = entry.getValue();//from w w w. j a va2 s.com } else if (entry.getValue().size() == 1 && singles.size() < 3) { singles.add(entry.getValue().get(0)); } } if (pair.size() == 2 && singles.size() == 3) { return (Card[]) CollectionUtils.union(pair, singles).toArray(new Card[5]); } else { return null; } }
From source file:com.alibaba.dubbo.rpc.protocol.rest.support.LoggingFilter.java
protected void logHttpHeaders(MultivaluedMap<String, String> headers) { StringBuilder msg = new StringBuilder("The HTTP headers are: \n"); for (Map.Entry<String, List<String>> entry : headers.entrySet()) { msg.append(entry.getKey()).append(": "); for (int i = 0; i < entry.getValue().size(); i++) { msg.append(entry.getValue().get(i)); if (i < entry.getValue().size() - 1) { msg.append(", "); }/*from w w w . j ava 2s . c o m*/ } msg.append("\n"); } logger.info(msg.toString()); }
From source file:com.alibaba.jstorm.ui.utils.UIUtils.java
public static List<ChartSeries> getChartSeries(List<MetricInfo> infos, int window) { Map<String, ChartSeries> chartMap = Maps.newHashMap(); for (MetricInfo info : infos) { for (Map.Entry<String, Map<Integer, MetricSnapshot>> metric : info.get_metrics().entrySet()) { String name = metric.getKey(); String[] split_name = name.split("@"); String metricName = UIMetricUtils.extractMetricName(split_name); if (!metric.getValue().containsKey(window)) { LOG.info("snapshot {} missing window:{}", metric.getKey(), window); continue; }//from w w w.j ava 2 s. c o m MetricSnapshot snapshot = metric.getValue().get(window); ChartSeries series; if (chartMap.containsKey(metricName)) { series = chartMap.get(metricName); } else { series = new ChartSeries(metricName); chartMap.put(metricName, series); } Number number = UIMetricUtils.getMetricNumberValue(snapshot); series.addData(number); if (metricName != null && metricName.equals(MetricDef.MEMORY_USED)) { series.addLabel(UIUtils.prettyFileSize(number.longValue())); } else { series.addLabel(UIMetricUtils.getMetricValue(snapshot)); } series.addCategory(UIUtils.parseDayTime(snapshot.get_ts())); } } return Lists.newArrayList(chartMap.values()); }