Java Code Examples for java.util.Map.values()

The following are Jave code examples for showing how to use values() of the java.util.Map class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: oscm   File: SubscriptionServiceBean.java   View Source Code Vote up 7 votes
/**
 * It returns a list of VOSubscriptionIdAndOrganizations objects, which
 * contain the subscriptionIdentifier and the associated customers of the
 * subscription in form of list.If there are no subscriptions an empty list
 * is returned.
 * 
 * The role of organization as a supplier, a broker or a reseller is needed
 * to execute this method.
 * 
 * @return List<VOSubscriptionIdAndOrganizations>
 */
@Override
@RolesAllowed({ "SERVICE_MANAGER", "BROKER_MANAGER", "RESELLER_MANAGER" })
public List<VOSubscriptionIdAndOrganizations> getCustomerSubscriptions()
        throws OrganizationAuthoritiesException {
    Set<SubscriptionStatus> states = EnumSet.of(SubscriptionStatus.ACTIVE,
            SubscriptionStatus.PENDING);
    LocalizerFacade lf = new LocalizerFacade(localizer,
            dataManager.getCurrentUser().getLocale());

    List<Subscription> queryResultList = getQueryResultListSubIdsAndOrgs(
            states);
    Map<String, VOSubscriptionIdAndOrganizations> mapSubIdsAndOrgs = getSubIdsAndOrgs(
            lf, queryResultList);

    return new ArrayList<>(mapSubIdsAndOrgs.values());
}
 
Example 2
Project: oneops   File: CmsCmRfcMrgProcessor.java   View Source Code Vote up 6 votes
/**
 * Gets the to ci relations naked no attrs.
 *
 * @param toId              the to id
 * @param relationName      the relation name
 * @param shortRelationName the short relation name
 * @param fromClazzName     the from clazz name
 * @return the to ci relations naked no attrs
 */
public List<CmsRfcRelation> getToCIRelationsNakedNoAttrs(long toId,
                                                         String relationName, String shortRelationName, String fromClazzName) {

    List<CmsCIRelation> cmRelations = cmProcessor.getToCIRelationsNakedNoAttrs(toId, relationName, shortRelationName, fromClazzName);
    List<CmsRfcRelation> rfcRelations = (fromClazzName != null) ?
            rfcProcessor.getOpenToRfcRelationByTargetClazz(toId, relationName, shortRelationName, fromClazzName) : rfcProcessor.getOpenRfcRelationBy2(null, toId, relationName, shortRelationName);

    Map<Long, Relations> relsMap = buildRelationsMap(cmRelations, rfcRelations);
    List<CmsRfcRelation> result = new ArrayList<>();
    for (Relations rels : relsMap.values()) {
        CmsRfcRelation mergedRel = rfcUtil.mergeRfcRelAndCiRel(rels.getRfcRelation(), rels.getCiRelation(), "df");
        if (mergedRel != null) {
            result.add(mergedRel);
        }
    }
    return result;
}
 
Example 3
Project: dubbox-hystrix   File: InjvmProtocol.java   View Source Code Vote up 6 votes
static Exporter<?> getExporter(Map<String, Exporter<?>> map, URL key) {
    Exporter<?> result = null;

    if (!key.getServiceKey().contains("*")) {
        result = map.get(key.getServiceKey());
    } else {
        if (map != null && !map.isEmpty()) {
            for (Exporter<?> exporter : map.values()) {
                if (UrlUtils.isServiceKeyMatch(key, exporter.getInvoker().getUrl())) {
                    result = exporter;
                    break;
                }
            }
        }
    }

    if (result == null) {
        return null;
    } else if (ProtocolUtils.isGeneric(
        result.getInvoker().getUrl().getParameter(Constants.GENERIC_KEY))) {
        return null;
    } else {
        return result;
    }
}
 
Example 4
Project: Matcher   File: Analysis.java   View Source Code Vote up 6 votes
private static BitSet getEntryPoints(MethodNode asmNode, Map<AbstractInsnNode, int[]> exitPoints) {
	InsnList il = asmNode.instructions;
	BitSet entryPoints = new BitSet(il.size());

	for (int[] eps : exitPoints.values()) {
		if (eps != null) {
			for (int ep : eps) entryPoints.set(ep);
		}
	}

	for (TryCatchBlockNode n : asmNode.tryCatchBlocks) {
		entryPoints.set(il.indexOf(n.handler));
	}

	return entryPoints;
}
 
Example 5
Project: oneops   File: CmsCmRfcMrgProcessor.java   View Source Code Vote up 6 votes
/**
 * Gets the to ci relations naked.
 *
 * @param toId              the to id
 * @param relationName      the relation name
 * @param shortRelationName the short relation name
 * @param fromClazzName     the from clazz name
 * @return the to ci relations naked
 */
public List<CmsRfcRelation> getToCIRelationsNaked(long toId,
                                                  String relationName, String shortRelationName, String fromClazzName) {

    List<CmsCIRelation> cmRelations = cmProcessor.getToCIRelationsNaked(toId, relationName, shortRelationName, fromClazzName);
    List<CmsRfcRelation> rfcRelations = (fromClazzName != null) ?
            rfcProcessor.getOpenToRfcRelationByTargetClazz(toId, relationName, shortRelationName, fromClazzName) : rfcProcessor.getOpenRfcRelationBy2(null, toId, relationName, shortRelationName);

    Map<Long, Relations> relsMap = buildRelationsMap(cmRelations, rfcRelations);
    List<CmsRfcRelation> result = new ArrayList<>();
    for (Relations rels : relsMap.values()) {
        CmsRfcRelation mergedRel = rfcUtil.mergeRfcRelAndCiRel(rels.getRfcRelation(), rels.getCiRelation(), "df");
        if (mergedRel != null) {
            result.add(mergedRel);
        }
    }
    return result;
}
 
Example 6
Project: oldmonk   File: ReporterAPI.java   View Source Code Vote up 6 votes
public Map<String, String> getAllParametersForTest(String testName)
{
    ITestContext overview = null;

    for (ISuite suite : suites)
    {
        Map<String, ISuiteResult> tests = suite.getResults();

        for (ISuiteResult r : tests.values())
        {
            overview = r.getTestContext();

            if (testName.equalsIgnoreCase(overview.getName()))
            {
                return overview.getCurrentXmlTest().getAllParameters();
            }
        }
    }

    return null;
}
 
Example 7
Project: dble   File: ReloadSqlSlowTime.java   View Source Code Vote up 6 votes
public static void execute(ManagerConnection c, long time) {

        Map<String, UserStat> statMap = UserStatAnalyzer.getInstance().getUserStatMap();
        for (UserStat userStat : statMap.values()) {
            userStat.setSlowTime(time);
        }

        LOGGER.info(String.valueOf(c) + "Reset show  @@sql.slow=" + time + " time success by manager");

        OkPacket ok = new OkPacket();
        ok.setPacketId(1);
        ok.setAffectedRows(1);
        ok.setServerStatus(2);
        ok.setMessage("Reset show  @@sql.slow time success".getBytes());
        ok.write(c);
    }
 
Example 8
Project: n4js   File: DeadCodeAnalyser.java   View Source Code Vote up 6 votes
/**
 * Separates the given set into sets where all {@link ControlFlowElement}s of each set have the same containing
 * {@link Block}.
 * <p>
 * Note that the assumption is:<br/>
 * <i>No block can contain more than one single dead code region.</i>
 */
private Collection<Set<ControlFlowElement>> separateOnTheirBlocks(Set<ControlFlowElement> unreachableElems) {
	Map<EObject, Set<ControlFlowElement>> unreachablesMap = new HashMap<>();
	for (ControlFlowElement unreachableElem : unreachableElems) {
		HashSet<ControlFlowElement> moreUnreachableElems = new HashSet<>();
		EObject cfeBlock = getReachableContainer(unreachableElems, unreachableElem, moreUnreachableElems);
		if (cfeBlock == null)
			continue;

		if (!unreachablesMap.containsKey(cfeBlock)) {
			unreachablesMap.put(cfeBlock, new HashSet<>());
		}
		Set<ControlFlowElement> unreachableInBlock = unreachablesMap.get(cfeBlock);
		unreachableInBlock.add(unreachableElem);
		unreachableInBlock.addAll(moreUnreachableElems);
	}

	return unreachablesMap.values();
}
 
Example 9
Project: Pogamut3   File: SPStoryPlace.java   View Source Code Vote up 5 votes
/**
 * @param distance must be &lt;0,1> ... 0 ~ pick from all possible navpoint, 1 ~ pick the furthest navpoint
 * @return
 */
public NavPoint getRandomNavPoint(SPLocation location, double distance) {
	if (distance >= 1) {
		return getFurthestNavPoint(location);
	}
	Map<Double, NavPoint> distances = getNavPointDistancesSwapped(location);
	
	if (distance <= 0) {
		Collection<NavPoint> navPoints = distances.values();
		int num = random.nextInt(navPoints.size());
		Iterator<NavPoint> np = navPoints.iterator();
		for (int i = 0; i < num-1; ++i) {
			np.next();
		}
		return np.next();				
	}
	
	Double[] keys = distances.keySet().toArray(new Double[distances.keySet().size()]);
	Arrays.sort(keys, new Comparator<Double>() {

		@Override
		public int compare(Double o1, Double o2) {
			return Double.compare(o1, o2);
		}
		
	});
	int randomInt = Double.valueOf(Math.round((1-distance)*keys.length)).intValue();
	int index = 0;
	if (randomInt > 1) {
		index = keys.length - 1 - random.nextInt(randomInt);
	} else { 
		index = keys.length - 1;
	}
	if (index < 0) {
		System.out.println("huh");
	}
	NavPoint navPoint = distances.get(keys[index]); 
	return navPoint;						
}
 
Example 10
Project: ArchUnit   File: JavaClasses.java   View Source Code Vote up 5 votes
static JavaClasses of(Map<String, JavaClass> classes, ImportContext importContext) {
    CompletionProcess completionProcess = new CompletionProcess(classes.values(), importContext);
    for (JavaClass clazz : new JavaClasses(classes)) {
        completionProcess.completeClass(clazz);
    }
    completionProcess.finish();
    return new JavaClasses(classes);
}
 
Example 11
Project: urule   File: ReteNodeLayout.java   View Source Code Vote up 5 votes
private int buildMaxSize(Map<Integer, List<NodeInfo>> nodeLevelMap) {
	int maxSize=1;
	for(List<NodeInfo> list:nodeLevelMap.values()){
		if(list.size()>maxSize){
			maxSize=list.size();
		}
	}
	return maxSize;
}
 
Example 12
Project: kafka-0.11.0.0-src-with-comment   File: RoundRobinAssignor.java   View Source Code Vote up 5 votes
public List<TopicPartition> allPartitionsSorted(Map<String, Integer> partitionsPerTopic,
                                                Map<String, Subscription> subscriptions) {
    SortedSet<String> topics = new TreeSet<>();
    for (Subscription subscription : subscriptions.values())
        topics.addAll(subscription.topics());

    List<TopicPartition> allPartitions = new ArrayList<>();
    for (String topic : topics) {
        Integer numPartitionsForTopic = partitionsPerTopic.get(topic);
        if (numPartitionsForTopic != null)
            allPartitions.addAll(AbstractPartitionAssignor.partitions(topic, numPartitionsForTopic));
    }
    return allPartitions;
}
 
Example 13
Project: winter   File: ProcessableCollection.java   View Source Code Vote up 5 votes
@Override
public 
<KeyType> 
Processable<Pair<RecordType,RecordType>> 
symmetricJoin( 
		Function<KeyType, RecordType> joinKeyGenerator, 
		final ProcessableCollector<Pair<RecordType, RecordType>> collector) {
	
	Map<KeyType, List<RecordType>> joinKeys = hashRecords(this, joinKeyGenerator);
	
	collector.setResult(createProcessable((Pair<RecordType,RecordType>)null));
	collector.initialise();
	
	for(List<RecordType> block : joinKeys.values()) {
		for(int i = 0; i < block.size(); i++) {
			for(int j = i+1; j<block.size(); j++) {
				if(i!=j) {
					collector.next(new Pair<>(block.get(i), block.get(j)));
				}
			}
		}
	}
	
	collector.finalise();
	
	return collector.getResult();
}
 
Example 14
Project: rlc-analyser   File: RLCDataAnalyser.java   View Source Code Vote up 5 votes
/**
 * Method is used get most used CommPoint given an input general properties
 * type map.
 *
 * @param countMap
 * @param maxResult
 * @return
 */
private List<TypeCountData> getCommPointProperties(final Map<String, Map<GeneralTabType, TypeCountData>> countMap, final int maxResult) {
	final List<TypeCountData> countList = new ArrayList<TypeCountData>();
	// if max result is -1, that means that we don't wish to apply the max result parameter.
	for (final Map<GeneralTabType, TypeCountData> value : countMap.values()) {
		if (maxResult == -1 || maxResult > countList.size()) {
			countList.add(value.get(GeneralTabType.TotalCounts));
		} else {
			break; // stop adding values to map.
		}
	}

	Collections.sort(countList);
	return countList;
}
 
Example 15
Project: incubator-netbeans   File: JpaControllerUtil.java   View Source Code Vote up 5 votes
private static void findNestedAnnotationsInternal(Object object, String annotationFqn, List<AnnotationMirror> result) {
    Collection<? extends AnnotationValue> annotationValueCollection = null;
    if (object instanceof AnnotationMirror) {
        AnnotationMirror annotationMirror = (AnnotationMirror)object;
        String annotationQualifiedName = getAnnotationQualifiedName(annotationMirror);
        if (annotationQualifiedName.equals(annotationFqn)) {
            result.add(annotationMirror);
        }
        else {
            //prepare to recurse
            Map<? extends ExecutableElement,? extends AnnotationValue> annotationMap = annotationMirror.getElementValues();
            annotationValueCollection = annotationMap.values();
        }
    }
    else if (object instanceof List) {
        //prepare to recurse
        annotationValueCollection = (Collection<? extends AnnotationValue>)object;
    }

    //recurse
    if (annotationValueCollection != null) {
        for (AnnotationValue annotationValue : annotationValueCollection) {
            Object value = annotationValue.getValue();
            findNestedAnnotationsInternal(value, annotationFqn, result);
        }
    }
}
 
Example 16
Project: sierra   File: FastHivdb.java   View Source Code Vote up 5 votes
public MutationSet getTriggeredMutations() {
	MutationSet result = new MutationSet();
	for (Map<String, MutationSet> partials : triggeredMuts.values()) {
		for (MutationSet muts : partials.values()) {
			result = result.mergesWith(muts);
		}
	}
	return result;
}
 
Example 17
Project: hadoop   File: TestDataNodeHotSwapVolumes.java   View Source Code Vote up 5 votes
@Test(timeout=60000)
public void testAddVolumesDuringWrite()
    throws IOException, InterruptedException, TimeoutException,
    ReconfigurationException {
  startDFSCluster(1, 1);
  String bpid = cluster.getNamesystem().getBlockPoolId();
  Path testFile = new Path("/test");
  createFile(testFile, 4);  // Each volume has 2 blocks.

  addVolumes(2);

  // Continue to write the same file, thus the new volumes will have blocks.
  DFSTestUtil.appendFile(cluster.getFileSystem(), testFile, BLOCK_SIZE * 8);
  verifyFileLength(cluster.getFileSystem(), testFile, 8 + 4);
  // After appending data, there should be [2, 2, 4, 4] blocks in each volume
  // respectively.
  List<Integer> expectedNumBlocks = Arrays.asList(2, 2, 4, 4);

  List<Map<DatanodeStorage, BlockListAsLongs>> blockReports =
      cluster.getAllBlockReports(bpid);
  assertEquals(1, blockReports.size());  // 1 DataNode
  assertEquals(4, blockReports.get(0).size());  // 4 volumes
  Map<DatanodeStorage, BlockListAsLongs> dnReport =
      blockReports.get(0);
  List<Integer> actualNumBlocks = new ArrayList<Integer>();
  for (BlockListAsLongs blockList : dnReport.values()) {
    actualNumBlocks.add(blockList.getNumberOfBlocks());
  }
  Collections.sort(actualNumBlocks);
  assertEquals(expectedNumBlocks, actualNumBlocks);
}
 
Example 18
Project: hadoop   File: DistBbp.java   View Source Code Vote up 4 votes
/** {@inheritDoc} */
public int run(String[] args) throws Exception {
  //parse arguments
  if (args.length != DistSum.Parameters.COUNT + 1)
    return Util.printUsage(args,
        getClass().getName() + " <b> " + Parameters.LIST
        + "\n  <b> The number of bits to skip, i.e. compute the (b+1)th position."
        + Parameters.DESCRIPTION);

  int i = 0;
  final long b = Util.string2long(args[i++]);
  final DistSum.Parameters parameters = DistSum.Parameters.parse(args, i);

  if (b < 0)
    throw new IllegalArgumentException("b = " + b + " < 0");
  Util.printBitSkipped(b);
  Util.out.println(parameters);
  Util.out.println();

  //initialize sums
  final DistSum distsum = new DistSum();
  distsum.setConf(getConf());
  distsum.setParameters(parameters);
  final boolean isVerbose = getConf().getBoolean(Parser.VERBOSE_PROPERTY, false);
  final Map<Parameter, List<TaskResult>> existings = new Parser(isVerbose).parse(parameters.localDir.getPath(), null);
  Parser.combine(existings);
  for(List<TaskResult> tr : existings.values())
    Collections.sort(tr);
  Util.out.println();
  final Map<Bellard.Parameter, Bellard.Sum> sums = Bellard.getSums(b, parameters.nJobs, existings);
  Util.out.println();

  //execute the computations
  execute(distsum, sums);

  //compute Pi from the sums 
  final double pi = Bellard.computePi(b, sums);
  Util.printBitSkipped(b);
  Util.out.println(Util.pi2string(pi, Bellard.bit2terms(b)));
  return 0;
}
 
Example 19
Project: googles-monorepo-demo   File: MapsTransformValuesUnmodifiableIteratorTest.java   View Source Code Vote up 4 votes
public void testTransformChangesAreReflectedInUnderlyingMap() {
  Map<String, Integer> underlying = Maps.newLinkedHashMap();
  underlying.put("a", 1);
  underlying.put("b", 2);
  underlying.put("c", 3);
  underlying.put("d", 4);
  underlying.put("e", 5);
  underlying.put("f", 6);
  underlying.put("g", 7);
  Map<String, String> map
      = Maps.transformValues(underlying, Functions.toStringFunction());

  map.remove("a");
  assertFalse(underlying.containsKey("a"));

  Set<String> keys = map.keySet();
  keys.remove("b");
  assertFalse(underlying.containsKey("b"));

  Iterator<String> keyIterator = keys.iterator();
  keyIterator.next();
  keyIterator.remove();
  assertFalse(underlying.containsKey("c"));

  Collection<String> values = map.values();
  values.remove("4");
  assertFalse(underlying.containsKey("d"));

  Iterator<String> valueIterator = values.iterator();
  valueIterator.next();
  valueIterator.remove();
  assertFalse(underlying.containsKey("e"));

  Set<Map.Entry<String, String>> entries = map.entrySet();
  Map.Entry<String, String> firstEntry = entries.iterator().next();
  entries.remove(firstEntry);
  assertFalse(underlying.containsKey("f"));

  Iterator<Map.Entry<String, String>> entryIterator = entries.iterator();
  entryIterator.next();
  entryIterator.remove();
  assertFalse(underlying.containsKey("g"));

  assertTrue(underlying.isEmpty());
  assertTrue(map.isEmpty());
  assertTrue(keys.isEmpty());
  assertTrue(values.isEmpty());
  assertTrue(entries.isEmpty());
}
 
Example 20
Project: coon   File: RedisMconf.java   View Source Code Vote up 4 votes
@SuppressWarnings("rawtypes")
@Override
public <T> void subscribe(Mcf mcf, Class<T> cls, CoonListener<T> listener) {
	if (isSubscribe) {
		this.pushSubscribe();
		isSubscribe = false;
	}

	String key = mcf.buildRoot(super.nurl).getPrefixKey();
	Jedis jedis = null;
	
	try {
		jedis = jedisPool.getResource();
		if (!pushClassMap.containsKey(key)) {
			pushClassMap.put(key, cls);
		}

		Set<CoonListener> notifies = pushNotifyMap.get(key);
		if (notifies == null) {
			pushNotifyMap.put(key, notifies = new ConcurrentHashSet<CoonListener>());
		}
		notifies.add(listener);

		// 第一次拉取式通知
		Map<String, String> dataMap = jedis.hgetAll(key);
		if (dataMap == null) {
			dataMap = new HashMap<String, String>();
		}

		List<T> list = new ArrayList<T>();
		for (String tempJson : dataMap.values()) {
			list.add(super.json2Obj(tempJson, cls));
		}

		pushValueMap.put(key, dataMap);
		listener.notify(list);
	} catch (Exception e) {
		logger.error("The push conf exception.", e);
	} finally {
		if (jedis != null) {
			jedis.close();
		}
	}
}