java.util.EnumSet#forEach ( )源码实例Demo

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

源代码1 项目: NNAnalytics   文件: TestNNAnalyticsBase.java
@Test
public void testEndpoints() throws IOException {
  EnumSet<Endpoint> clone = UNSECURED_ENDPOINTS.clone();
  clone.remove(Endpoint.login);
  clone.remove(Endpoint.logout);
  clone.remove(Endpoint.credentials);
  clone.forEach(
      x -> {
        String url = "http://localhost:4567/" + x.name();
        System.out.println("Calling: " + url);
        HttpGet get = new HttpGet(url);
        HttpResponse res = null;
        try {
          res = client.execute(hostPort, get);
          IOUtils.readLines(res.getEntity().getContent()).clear();
        } catch (IOException e) {
          fail();
        }
        assertThat(res.getStatusLine().getStatusCode(), is(200));
      });
}
 
源代码2 项目: NBANDROID-V2   文件: AttrCompletionItem.java
public AttrCompletionItem(AndroidStyleable styleable, AndroidStyleableAttr attr, String prefix) {
    if (prefix == null) {
        prefix = "";
    }
    prefix = prefix.replace("xmlns:", "");
    this.styleable = styleable;
    this.attr = attr;
    this.prefix = prefix;
    completionText = prefix + ":" + attr.getName();
    classNameText = "";
    EnumSet<AndroidStyleableAttrType> attrTypes = attr.getAttrTypes();
    List<String> types = new ArrayList<>();
    attrTypes.forEach(t -> {
        types.add(t.toString());
    });
    typeNames = String.join(", ", types);
    lowerCasecompletionText = completionText.toLowerCase();
    if (attr.getName() != null) {
        lowerCaseSimpleCompletionText = attr.getName().toLowerCase();
    } else {
        lowerCaseSimpleCompletionText = "";
    }
}
 
源代码3 项目: ipst   文件: WCAFilteredClusters.java
public void removeClusters(String contingencyId, EnumSet<WCAClusterNum> clustersNums, WCAClusterOrigin flag) {
    Objects.requireNonNull(contingencyId, "contingency id is null");
    Objects.requireNonNull(clustersNums, "clustersNums is null");
    LOGGER.info("Network {}, contingency {}: removing clusters {} for {}", networkId, contingencyId, clustersNums.toString(), flag);
    if (contingencyClusters.containsKey(contingencyId)) {
        // remove clusters from the list of the contingency
        EnumSet<WCAClusterNum> clusters = contingencyClusters.get(contingencyId);
        clustersNums.forEach(clusterNum -> clusters.remove(clusterNum));
        contingencyClusters.put(contingencyId, clusters);
        if (flag != null) {
            // add flag to the list of the contingency
            EnumSet<WCAClusterOrigin> flags = EnumSet.noneOf(WCAClusterOrigin.class);
            if (contingencyFlags.containsKey(contingencyId)) {
                flags = contingencyFlags.get(contingencyId);
            }
            flags.add(flag);
            contingencyFlags.put(contingencyId, flags);
        }
    } else {
        LOGGER.warn("Network {}, contingency {}: no possible clusters", networkId, contingencyId);
    }
}
 
源代码4 项目: ipst   文件: WCAFilteredClusters.java
public void addClusters(String contingencyId, EnumSet<WCAClusterNum> clustersNums, WCAClusterOrigin flag) {
    Objects.requireNonNull(contingencyId, "contingency id is null");
    Objects.requireNonNull(clustersNums, "clustersNums is null");
    LOGGER.info("Network {}, contingency {}: adding clusters {} for {}", networkId, contingencyId, clustersNums.toString(), flag);
    if (contingencyClusters.containsKey(contingencyId)) {
        // add clusters to the list of the contingency
        EnumSet<WCAClusterNum> clusters = contingencyClusters.get(contingencyId);
        clustersNums.forEach(clusterNum -> clusters.add(clusterNum));
        contingencyClusters.put(contingencyId, clusters);
        if (flag != null) {
            // add flag to the list of the contingency
            EnumSet<WCAClusterOrigin> flags = EnumSet.noneOf(WCAClusterOrigin.class);
            if (contingencyFlags.containsKey(contingencyId)) {
                flags = contingencyFlags.get(contingencyId);
            }
            flags.add(flag);
            contingencyFlags.put(contingencyId, flags);
        }
    } else {
        LOGGER.warn("Network {}, contingency {}: no possible clusters", networkId, contingencyId);
    }
}
 
public static void main(String args[]) {
    EnumSet<MethodGroup> notIgnoredMethodGroups
            = EnumSet.complementOf(EnumSet.of(MethodGroup.IGNORED));

    notIgnoredMethodGroups.forEach(
            TestMutuallyExclusivePlatformPredicates::verifyPredicates);

    TestMutuallyExclusivePlatformPredicates.verifyCoverage();
}
 
public static void main(String args[]) {
    EnumSet<MethodGroup> notIgnoredMethodGroups
            = EnumSet.complementOf(EnumSet.of(MethodGroup.IGNORED));

    notIgnoredMethodGroups.forEach(
            TestMutuallyExclusivePlatformPredicates::verifyPredicates);

    TestMutuallyExclusivePlatformPredicates.verifyCoverage();
}
 
public static void main(String args[]) {
    EnumSet<MethodGroup> notIgnoredMethodGroups
            = EnumSet.complementOf(EnumSet.of(MethodGroup.IGNORED));

    notIgnoredMethodGroups.forEach(
            TestMutuallyExclusivePlatformPredicates::verifyPredicates);

    TestMutuallyExclusivePlatformPredicates.verifyCoverage();
}
 
public static void main(String args[]) {
    EnumSet<MethodGroup> notIgnoredMethodGroups
            = EnumSet.complementOf(EnumSet.of(MethodGroup.IGNORED));

    notIgnoredMethodGroups.forEach(
            TestMutuallyExclusivePlatformPredicates::verifyPredicates);

    TestMutuallyExclusivePlatformPredicates.verifyCoverage();
}
 
public static void main(String args[]) {
    EnumSet<MethodGroup> notIgnoredMethodGroups
            = EnumSet.complementOf(EnumSet.of(MethodGroup.IGNORED));

    notIgnoredMethodGroups.forEach(
            TestMutuallyExclusivePlatformPredicates::verifyPredicates);

    TestMutuallyExclusivePlatformPredicates.verifyCoverage();
}
 
源代码10 项目: openjdk-jdk9   文件: MethodGenerator.java
/**
 * Generates triples from the given enum sets
 * for each of the method elements
 *
 * @param classSet  set of allowed elements for class
 * @param methodSet set of allowed elements for method
 * @param signSet   set of allowed elements for signature
 * @param <E>       type of generated triples
 * @return list of triples
 */
private static <E extends Enum<E>> List<Combination<E>> generate(
        EnumSet<E> classSet, EnumSet<E> methodSet, EnumSet<E> signSet) {
    List<Combination<E>> list = new ArrayList<>();
    classSet.forEach(clsElement ->
        methodSet.forEach(methodElement ->
            signSet.forEach(signElement ->
                list.add(new Combination<>(clsElement, methodElement,
                        signElement))
            )
        )
    );
    return list;
}
 
public static void main(String args[]) {
    EnumSet<MethodGroup> notIgnoredMethodGroups
            = EnumSet.complementOf(EnumSet.of(MethodGroup.IGNORED));

    notIgnoredMethodGroups.forEach(
            TestMutuallyExclusivePlatformPredicates::verifyPredicates);

    TestMutuallyExclusivePlatformPredicates.verifyCoverage();
}
 
源代码12 项目: tutorials   文件: EnumSets.java
public static void main(String[] args) {
    EnumSet<Color> allColors = EnumSet.allOf(Color.class);
    System.out.println(allColors);

    EnumSet<Color> noColors = EnumSet.noneOf(Color.class);
    System.out.println(noColors);

    EnumSet<Color> blackAndWhite = EnumSet.of(Color.BLACK, Color.WHITE);
    System.out.println(blackAndWhite);

    EnumSet<Color> noBlackOrWhite = EnumSet.complementOf(blackAndWhite);
    System.out.println(noBlackOrWhite);

    EnumSet<Color> range = EnumSet.range(Color.YELLOW, Color.BLUE);
    System.out.println(range);

    EnumSet<Color> blackAndWhiteCopy = EnumSet.copyOf(EnumSet.of(Color.BLACK, Color.WHITE));
    System.out.println(blackAndWhiteCopy);

    List<Color> colorsList = new ArrayList<>();
    colorsList.add(Color.RED);
    EnumSet<Color> listCopy = EnumSet.copyOf(colorsList);
    System.out.println(listCopy);

    EnumSet<Color> set = EnumSet.noneOf(Color.class);
    set.add(Color.RED);
    set.add(Color.YELLOW);
    set.contains(Color.RED);
    set.forEach(System.out::println);
    set.remove(Color.RED);
}
 
public EnumSet<TestEnum> getNextValueEnumSet(EnumSet<TestEnum> value) {
    EnumSet<TestEnum> enumSet = EnumSet.noneOf(TestEnum.class);
    value.forEach(testEnum -> enumSet
            .add(TestEnum.getTestEnum(testEnum.getValue() + 1)));
    return enumSet;
}
 
源代码14 项目: ambry   文件: SimpleOperationTracker.java
/**
 * Get eligible replicas by states for given partition from specified data center. If dcName is null, it gets all eligible
 * replicas from all data centers.
 * @param partitionId the {@link PartitionId} that replicas belong to.
 * @param dcName the name of data center from which the replicas should come from. This can be {@code null}.
 * @param states a set of {@link ReplicaState}(s) that replicas should match.
 * @return a list of eligible replicas that are in specified states.
 */
private List<ReplicaId> getEligibleReplicas(PartitionId partitionId, String dcName, EnumSet<ReplicaState> states) {
  Set<ReplicaId> eligibleReplicas = new HashSet<>();
  states.forEach(state -> eligibleReplicas.addAll(partitionId.getReplicaIdsByState(state, dcName)));
  return new ArrayList<>(eligibleReplicas);
}