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

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

源代码1 项目: neoscada   文件: ProxyDataItem.java
/**
 * @param id
 * @param proxyValueHolder
 * @param executor
 *            the executor to use for write calls
 */
public ProxyDataItem ( final String id, final ProxyValueHolder proxyValueHolder, final ProxyWriteHandler writeHandler, final Executor executor )
{
    super ( new DataItemInformationBase ( id, EnumSet.allOf ( IODirection.class ) ), executor );
    this.proxyValueHolder = proxyValueHolder;
    this.proxyValueHolder.setListener ( new ItemUpdateListener () {
        @Override
        public void notifyDataChange ( final Variant value, final Map<String, Variant> attributes, final boolean cache )
        {
            ProxyDataItem.this.updateData ( value, attributes, cache ? AttributeMode.SET : AttributeMode.UPDATE );
        }

        @Override
        public void notifySubscriptionChange ( final SubscriptionState subscriptionState, final Throwable subscriptionError )
        {
            // TODO: (jr2) is there something which is to be done?
        }
    } );

    this.writeHandler = writeHandler;
}
 
源代码2 项目: buck   文件: SkylarkProjectBuildFileParserTest.java
@Test
public void nativeFunctionUsageAtTopLevelIsReportedAsAnError() throws Exception {
  EventCollector eventCollector = new EventCollector(EnumSet.allOf(EventKind.class));
  parser = createParser(eventCollector);
  Path buildFile = projectFilesystem.resolve("BUCK");
  Files.write(buildFile, Collections.singletonList("load('//:ext.bzl', 'ext')"));
  Path extensionFile = projectFilesystem.resolve("ext.bzl");
  Files.write(extensionFile, Collections.singletonList("ext = native.read_config('foo', 'bar')"));
  try {
    parser.getManifest(buildFile);
    fail("Parsing should have failed.");
  } catch (BuildFileParseException e) {
    Event printEvent = eventCollector.iterator().next();
    assertThat(
        printEvent.getMessage(),
        equalTo(
            "Top-level invocations of native.read_config are not allowed in .bzl files. "
                + "Wrap it in a macro and call it from a BUCK file."));
    assertThat(printEvent.getKind(), equalTo(EventKind.ERROR));
  }
}
 
源代码3 项目: lua-for-android   文件: Analyzer.java
/**
 * This method is used to parse the {@code find} option.
 * Possible modes are separated by colon; a mode can be excluded by
 * prepending '-' to its name. Finally, the special mode 'all' can be used to
 * add all modes to the resulting enum.
 */
static EnumSet<AnalyzerMode> getAnalyzerModes(String opt, Source source) {
    if (opt == null) {
        return EnumSet.noneOf(AnalyzerMode.class);
    }
    List<String> modes = List.from(opt.split(","));
    EnumSet<AnalyzerMode> res = EnumSet.noneOf(AnalyzerMode.class);
    if (modes.contains("all")) {
        res = EnumSet.allOf(AnalyzerMode.class);
    }
    for (AnalyzerMode mode : values()) {
        if (modes.contains(mode.opt)) {
            res.add(mode);
        } else if (modes.contains("-" + mode.opt) || !mode.sourceFilter.test(source)) {
            res.remove(mode);
        }
    }
    return res;
}
 
源代码4 项目: crate   文件: ConnectionProfile.java
/**
 * Builds a connection profile that is dedicated to a single channel type. Allows passing connection and
 * handshake timeouts and compression settings.
 */
public static ConnectionProfile buildSingleChannelProfile(TransportRequestOptions.Type channelType, @Nullable TimeValue connectTimeout,
                                                          @Nullable TimeValue handshakeTimeout, @Nullable TimeValue pingInterval,
                                                          @Nullable Boolean compressionEnabled) {
    Builder builder = new Builder();
    builder.addConnections(1, channelType);
    final EnumSet<TransportRequestOptions.Type> otherTypes = EnumSet.allOf(TransportRequestOptions.Type.class);
    otherTypes.remove(channelType);
    builder.addConnections(0, otherTypes.toArray(new TransportRequestOptions.Type[0]));
    if (connectTimeout != null) {
        builder.setConnectTimeout(connectTimeout);
    }
    if (handshakeTimeout != null) {
        builder.setHandshakeTimeout(handshakeTimeout);
    }
    if (pingInterval != null) {
        builder.setPingInterval(pingInterval);
    }
    if (compressionEnabled != null) {
        builder.setCompressionEnabled(compressionEnabled);
    }
    return builder.build();
}
 
源代码5 项目: buck   文件: SkylarkUserDefinedRulesParserTest.java
@Test
public void acceptsAutomaticallyAddedAttributes() throws IOException, InterruptedException {
  setupWorkspace("rule_with_builtin_arguments");

  // TODO: Change this to visibility when that is added to SkylarkUserDefinedRule
  EventCollector eventCollector = new EventCollector(EnumSet.allOf(EventKind.class));

  Path buildFile = projectFilesystem.resolve("subdir").resolve("BUCK");

  ImmutableMap<String, ImmutableMap<String, Object>> expected =
      ImmutableMap.of(
          "target1",
          ImmutableMap.<String, Object>builder()
              .put("name", "target1")
              .put("buck.base_path", "subdir")
              .put("buck.type", "//subdir:foo.bzl:some_rule")
              .put("attr1", 3)
              .put("attr2", 2)
              .put("licenses", ImmutableSortedSet.of())
              .put("labels", ImmutableSortedSet.of())
              .put("default_target_platform", Optional.empty())
              .put("compatible_with", ImmutableList.of())
              .build());

  parser = createParser(eventCollector);

  BuildFileManifest rules = parser.getManifest(buildFile);

  assertEquals(expected, rules.getTargets());
}
 
源代码6 项目: workspacemechanic   文件: BaseOutputDialog.java
/**
 * Create an output dialog for the given shell.
 * 
 * @param parentShell the shell to create this dialog in.
 * @param extension the file type extension.
 * @param components the set of task parameter components to show.
 * If empty, show all components.
 */
public BaseOutputDialog(Shell parentShell, String extension,
    Component... components) {
  super(parentShell);
  this.extension = extension;
  if (components.length == 0) {
    this.components = EnumSet.allOf(Component.class);
  } else {
    this.components = EnumSet.noneOf(Component.class);
    this.components.addAll(Arrays.asList(components));
  }
}
 
源代码7 项目: hadoop   文件: StartupProgress.java
/**
 * Returns true if the entire startup process has completed, determined by
 * checking if each phase is complete.
 * 
 * @return boolean true if the entire startup process has completed
 */
private boolean isComplete() {
  for (Phase phase: EnumSet.allOf(Phase.class)) {
    if (getStatus(phase) != Status.COMPLETE) {
      return false;
    }
  }
  return true;
}
 
源代码8 项目: vespa   文件: StateFilter.java
/** Returns a node filter which matches a comma or space-separated list of states */
public static StateFilter from(String states, boolean includeDeprovisioned, NodeFilter next) {
    if (states == null) {
        return new StateFilter(includeDeprovisioned ?
                EnumSet.allOf(Node.State.class) : EnumSet.complementOf(EnumSet.of(Node.State.deprovisioned)), next);
    }

    return new StateFilter(StringUtilities.split(states).stream().map(Node.State::valueOf).collect(Collectors.toSet()), next);
}
 
源代码9 项目: atlas   文件: OptimizerOptions.java
/**
 * Compares the output of the optimizer run normally with a run skipping
 * some optional steps. Results are printed to stderr.
 *
 * @param nonOptRmeth {@code non-null;} origional rop method
 * @param paramSize {@code >= 0;} parameter size of method
 * @param isStatic true if this method has no 'this' pointer argument.
 * @param args {@code non-null;} translator arguments
 * @param advice {@code non-null;} translation advice
 * @param rmeth {@code non-null;} method with all optimization steps run.
 */
public static void compareOptimizerStep(RopMethod nonOptRmeth,
        int paramSize, boolean isStatic, CfOptions args,
        TranslationAdvice advice, RopMethod rmeth) {
    EnumSet<Optimizer.OptionalStep> steps;

    steps = EnumSet.allOf(Optimizer.OptionalStep.class);

    // This is the step to skip.
    steps.remove(Optimizer.OptionalStep.CONST_COLLECTOR);

    RopMethod skipRopMethod
            = Optimizer.optimize(nonOptRmeth,
                    paramSize, isStatic, args.localInfo, advice, steps);

    int normalInsns
            = rmeth.getBlocks().getEffectiveInstructionCount();
    int skipInsns
            = skipRopMethod.getBlocks().getEffectiveInstructionCount();

    System.err.printf(
            "optimize step regs:(%d/%d/%.2f%%)"
            + " insns:(%d/%d/%.2f%%)\n",
            rmeth.getBlocks().getRegCount(),
            skipRopMethod.getBlocks().getRegCount(),
            100.0 * ((skipRopMethod.getBlocks().getRegCount()
                    - rmeth.getBlocks().getRegCount())
                    / (float) skipRopMethod.getBlocks().getRegCount()),
            normalInsns, skipInsns,
            100.0 * ((skipInsns - normalInsns) / (float) skipInsns));
}
 
源代码10 项目: buck   文件: SkylarkUserDefinedRulesParserTest.java
@Test
public void attrsOutputHandlesAbsentDefault() throws IOException, InterruptedException {
  setupWorkspace("attr");

  EventCollector eventCollector = new EventCollector(EnumSet.allOf(EventKind.class));
  Path noDefault = projectFilesystem.resolve("output").resolve("no_default").resolve("BUCK");

  parser = createParser(eventCollector);

  assertParserFails(
      eventCollector,
      parser,
      noDefault,
      "output attributes must have a default value, or be mandatory");
}
 
源代码11 项目: hadoop   文件: FileBench.java
public static <T extends Enum<T>> EnumSet<T> rem(Class<T> c,
    EnumSet<T> set, String s) {
  if (null != fullmap.get(c) && fullmap.get(c).get(s) != null) {
    if (null == set) {
      set = EnumSet.allOf(c);
    }
    set.remove(fullmap.get(c).get(s));
  }
  return set;
}
 
源代码12 项目: codebuff   文件: Enums.java
@GwtIncompatible // java.lang.ref.WeakReference
private static <T extends Enum<T>> Map<String, WeakReference<? extends Enum<?>>> populateCache(Class<T> enumClass) {
  Map<String, WeakReference<? extends Enum<?>>> result = new HashMap<String, WeakReference<? extends Enum<?>>>();
  for (T enumInstance : EnumSet.allOf(enumClass)) {
    result.put(enumInstance.name(), new WeakReference<Enum<?>>(enumInstance));
  }
  enumConstantCache.put(enumClass, result);
  return result;
}
 
源代码13 项目: secure-data-service   文件: EdfiEntityTest.java
@Test
public void testLayersFinish() {
    Set<EdfiEntity> set = EnumSet.allOf(EdfiEntity.class);

    for (int i = 1; i < 100; i++) {
        Set<EdfiEntity> cleansed = EdfiEntity.cleanse(set);
        set.removeAll(cleansed);
        LOG.info(cleansed.toString());
        if (set.isEmpty()) {
            LOG.info("Dependency diminuation finished in: {} passes", i);
            break;
        }
    }
}
 
@Test
public void testSignToken() throws GeneralSecurityException, IOException {
  String keystore = new File(KEYSTORES_DIR, "keystore.jks")
      .getAbsolutePath();
  String truststore = new File(KEYSTORES_DIR, "truststore.jks")
      .getAbsolutePath();
  String trustPassword = "trustPass";
  String keyStorePassword = "keyStorePass";
  String keyPassword = "keyPass";


  KeyStoreTestUtil.createKeyStore(keystore, keyStorePassword, keyPassword,
      "OzoneMaster", keyPair.getPrivate(), cert);

  // Create trust store and put the certificate in the trust store
  Map<String, X509Certificate> certs = Collections.singletonMap("server",
      cert);
  KeyStoreTestUtil.createTrustStore(truststore, trustPassword, certs);

  // Sign the OzoneMaster Token with Ozone Master private key
  PrivateKey privateKey = keyPair.getPrivate();
  OzoneBlockTokenIdentifier tokenId = new OzoneBlockTokenIdentifier(
      "testUser", "84940",
      EnumSet.allOf(HddsProtos.BlockTokenSecretProto.AccessModeProto.class),
      expiryTime, cert.getSerialNumber().toString(), 128L);
  byte[] signedToken = signTokenAsymmetric(tokenId, privateKey);

  // Verify a valid signed OzoneMaster Token with Ozone Master
  // public key(certificate)
  boolean isValidToken = verifyTokenAsymmetric(tokenId, signedToken, cert);
  LOG.info("{} is {}", tokenId, isValidToken ? "valid." : "invalid.");

  // Verify an invalid signed OzoneMaster Token with Ozone Master
  // public key(certificate)
  tokenId = new OzoneBlockTokenIdentifier("", "",
      EnumSet.allOf(HddsProtos.BlockTokenSecretProto.AccessModeProto.class),
      expiryTime, cert.getSerialNumber().toString(), 128L);
  LOG.info("Unsigned token {} is {}", tokenId,
      verifyTokenAsymmetric(tokenId, RandomUtils.nextBytes(128), cert));

}
 
源代码15 项目: Dividers   文件: SingleItemSelector.java
@Override public EnumSet<Direction> getDirectionsByPosition(Position position) {
  return EnumSet.allOf(Direction.class);
}
 
源代码16 项目: morphia   文件: ExperimentalTaglet.java
@Override
public Set<Location> getAllowedLocations() {
    return EnumSet.allOf(Location.class);
}
 
@Override
protected Set<Property> getPropertyInfoSet()
{
	return EnumSet.allOf(Property.class);
}
 
源代码18 项目: APICloud-Studio   文件: SnippetNode.java
@Override
protected Set<Property> getPropertyInfoSet()
{
	return EnumSet.allOf(Property.class);
}
 
源代码19 项目: buck   文件: SkylarkUserDefinedRulesParserTest.java
@Test
public void attrsOutputThrowsExceptionOnInvalidTypes() throws IOException, InterruptedException {

  setupWorkspace("attr");

  EventCollector eventCollector = new EventCollector(EnumSet.allOf(EventKind.class));
  Path buildFile = projectFilesystem.resolve("output").resolve("malformed").resolve("BUCK");

  parser = createParser(eventCollector);

  assertParserFails(
      eventCollector, parser, buildFile, "expected value of type 'string or NoneType'");
}
 
源代码20 项目: development   文件: ServiceInstanceServiceBean.java
/**
 * List all available operations for the given service instance.
 * 
 * @param serviceInstance
 *            - the service instance object
 * @return a set of instance operations
 */
public EnumSet<InstanceOperation> listOperationsForInstance(
        ServiceInstance serviceInstance) {
    return EnumSet.allOf(InstanceOperation.class);
}