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

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

源代码1 项目: cosmic   文件: ListVMsCmd.java
public EnumSet<VMDetails> getDetails() throws InvalidParameterValueException {
    final EnumSet<VMDetails> dv;
    if (viewDetails == null || viewDetails.size() <= 0) {
        dv = EnumSet.of(VMDetails.all);
    } else {
        try {
            final ArrayList<VMDetails> dc = new ArrayList<>();
            for (final String detail : viewDetails) {
                dc.add(VMDetails.valueOf(detail));
            }
            dv = EnumSet.copyOf(dc);
        } catch (final IllegalArgumentException e) {
            throw new InvalidParameterValueException("The details parameter contains a non permitted value. The allowed values are " + EnumSet.allOf(VMDetails.class));
        }
    }
    return dv;
}
 
源代码2 项目: javaide   文件: LintDriver.java
/**
 * Requests another pass through the data for the given detector. This is
 * typically done when a detector needs to do more expensive computation,
 * but it only wants to do this once it <b>knows</b> that an error is
 * present, or once it knows more specifically what to check for.
 *
 * @param detector the detector that should be included in the next pass.
 *            Note that the lint runner may refuse to run more than a couple
 *            of runs.
 * @param scope the scope to be revisited. This must be a subset of the
 *       current scope ({@link #getScope()}, and it is just a performance hint;
 *       in particular, the detector should be prepared to be called on other
 *       scopes as well (since they may have been requested by other detectors).
 *       You can pall null to indicate "all".
 */
public void requestRepeat(@NonNull Detector detector, @Nullable EnumSet<Scope> scope) {
    if (mRepeatingDetectors == null) {
        mRepeatingDetectors = new ArrayList<Detector>();
    }
    mRepeatingDetectors.add(detector);

    if (scope != null) {
        if (mRepeatScope == null) {
            mRepeatScope = scope;
        } else {
            mRepeatScope = EnumSet.copyOf(mRepeatScope);
            mRepeatScope.addAll(scope);
        }
    } else {
        mRepeatScope = Scope.ALL;
    }
}
 
源代码3 项目: cloudstack   文件: ListAccountsCmd.java
public EnumSet<DomainDetails> getDetails() throws InvalidParameterValueException {
    EnumSet<DomainDetails> dv;
    if (viewDetails == null || viewDetails.size() <= 0) {
        dv = EnumSet.of(DomainDetails.all);
    } else {
        try {
            ArrayList<DomainDetails> dc = new ArrayList<DomainDetails>();
            for (String detail : viewDetails) {
                dc.add(DomainDetails.valueOf(detail));
            }
            dv = EnumSet.copyOf(dc);
        } catch (IllegalArgumentException e) {
            throw new InvalidParameterValueException("The details parameter contains a non permitted value. The allowed values are " +
                EnumSet.allOf(DomainDetails.class));
        }
    }
    return dv;
}
 
源代码4 项目: cloudstack   文件: ListVMsCmd.java
public EnumSet<VMDetails> getDetails() throws InvalidParameterValueException {
    EnumSet<VMDetails> dv;
    if (viewDetails == null || viewDetails.size() <= 0) {
        dv = EnumSet.of(VMDetails.all);
    } else {
        try {
            ArrayList<VMDetails> dc = new ArrayList<VMDetails>();
            for (String detail : viewDetails) {
                dc.add(VMDetails.valueOf(detail));
            }
            dv = EnumSet.copyOf(dc);
        } catch (IllegalArgumentException e) {
            throw new InvalidParameterValueException("The details parameter contains a non permitted value. The allowed values are " + EnumSet.allOf(VMDetails.class));
        }
    }
    return dv;
}
 
源代码5 项目: cloudstack   文件: ListProjectsCmd.java
public EnumSet<DomainDetails> getDetails() throws InvalidParameterValueException {
    EnumSet<DomainDetails> dv;
    if (viewDetails == null || viewDetails.size() <= 0) {
        dv = EnumSet.of(DomainDetails.all);
    } else {
        try {
            ArrayList<DomainDetails> dc = new ArrayList<DomainDetails>();
            for (String detail : viewDetails) {
                dc.add(DomainDetails.valueOf(detail));
            }
            dv = EnumSet.copyOf(dc);
        } catch (IllegalArgumentException e) {
            throw new InvalidParameterValueException("The details parameter contains a non permitted value. The allowed values are " +
                EnumSet.allOf(DomainDetails.class));
        }
    }
    return dv;
}
 
源代码6 项目: cloudbreak   文件: StackStatusCheckerJobTest.java
@Test
public void testHandledAllStatesSeparately() {
    Set<Status> unshedulableStates = underTest.unshedulableStates();
    Set<Status> ignoredStates = underTest.ignoredStates();
    Set<Status> syncableStates = underTest.syncableStates();

    assertTrue(Sets.intersection(unshedulableStates, ignoredStates).isEmpty());
    assertTrue(Sets.intersection(unshedulableStates, syncableStates).isEmpty());
    assertTrue(Sets.intersection(ignoredStates, syncableStates).isEmpty());

    Set<Status> allPossibleStates = EnumSet.allOf(Status.class);
    Set<Status> allHandledStates = EnumSet.copyOf(unshedulableStates);
    allHandledStates.addAll(ignoredStates);
    allHandledStates.addAll(syncableStates);
    assertEquals(allPossibleStates, allHandledStates);
}
 
源代码7 项目: openjdk-jdk8u-backup   文件: DirectoryScanner.java
/**
 * Constructs a new {@code DirectoryScanner}.
 * <p>This constructor is
 * package protected, and this MBean cannot be created by a remote
 * client, because it needs a reference to the {@link ResultLogManager},
 * which cannot be provided from remote.
 * </p>
 * <p>This is a conscious design choice: {@code DirectoryScanner} MBeans
 * are expected to be completely managed (created, registered, unregistered)
 * by the {@link ScanManager} which does provide this reference.
 * </p>
 *
 * @param config This {@code DirectoryScanner} configuration.
 * @param logManager The info log manager with which to log the info
 *        records.
 * @throws IllegalArgumentException if one of the parameter is null, or if
 *         the provided {@code config} doesn't have its {@code name} set,
 *         or if the {@link DirectoryScannerConfig#getRootDirectory
 *         root directory} provided in the {@code config} is not acceptable
 *         (not provided or not found or not readable, etc...).
 **/
public DirectoryScanner(DirectoryScannerConfig config,
                        ResultLogManager logManager)
    throws IllegalArgumentException {
    if (logManager == null)
        throw new IllegalArgumentException("log=null");
    if (config == null)
        throw new IllegalArgumentException("config=null");
    if (config.getName() == null)
        throw new IllegalArgumentException("config.name=null");

     broadcaster = new NotificationBroadcasterSupport();

     // Clone the config: ensure data encapsulation.
     //
     this.config = XmlConfigUtils.xmlClone(config);

     // Checks that the provided root directory is valid.
     // Throws IllegalArgumentException if it isn't.
     //
     rootFile = validateRoot(config.getRootDirectory());

     // Initialize the Set<Action> for which this DirectoryScanner
     // is configured.
     //
     if (config.getActions() == null)
         actions = Collections.emptySet();
     else
         actions = EnumSet.copyOf(Arrays.asList(config.getActions()));
     this.logManager = logManager;
}
 
源代码8 项目: jdk8u_jdk   文件: NumericShaper.java
private NumericShaper(Range defaultContext, Set<Range> ranges) {
    shapingRange = defaultContext;
    rangeSet = EnumSet.copyOf(ranges); // throws NPE if ranges is null.

    // Give precedance to EASTERN_ARABIC if both ARABIC and
    // EASTERN_ARABIC are specified.
    if (rangeSet.contains(Range.EASTERN_ARABIC)
        && rangeSet.contains(Range.ARABIC)) {
        rangeSet.remove(Range.ARABIC);
    }

    // As well as the above case, give precedance to TAI_THAM_THAM if both
    // TAI_THAM_HORA and TAI_THAM_THAM are specified.
    if (rangeSet.contains(Range.TAI_THAM_THAM)
        && rangeSet.contains(Range.TAI_THAM_HORA)) {
        rangeSet.remove(Range.TAI_THAM_HORA);
    }

    rangeArray = rangeSet.toArray(new Range[rangeSet.size()]);
    if (rangeArray.length > BSEARCH_THRESHOLD) {
        // sort rangeArray for binary search
        Arrays.sort(rangeArray,
                    new Comparator<Range>() {
                        public int compare(Range s1, Range s2) {
                            return s1.base > s2.base ? 1 : s1.base == s2.base ? 0 : -1;
                        }
                    });
    }
}
 
private EnumSet<DayOfWeek> deserializeDays (Set<String> days) {
    Set<DayOfWeek> daysOfWeek = new HashSet<>();
    for (String thisDay : days) {
        daysOfWeek.add(DayOfWeek.from(thisDay));
    }

    return EnumSet.copyOf(daysOfWeek);
}
 
源代码10 项目: vividus   文件: ProxyServerFactoryTests.java
@Test
public void testCreateProxyServer()
{
    Set<CaptureType> expectedHarCaptureTypes = EnumSet.copyOf(CaptureType.getAllContentCaptureTypes());

    proxyServerFactory.setCaptureTypes(CaptureType.getAllContentCaptureTypes());
    assertThat(proxyServerFactory.createProxyServer().getHarCaptureTypes(),
            hasItems(expectedHarCaptureTypes.toArray(new CaptureType[0])));
}
 
源代码11 项目: javapoet   文件: CodeWriter.java
/**
 * Emits {@code modifiers} in the standard order. Modifiers in {@code implicitModifiers} will not
 * be emitted.
 */
public void emitModifiers(Set<Modifier> modifiers, Set<Modifier> implicitModifiers)
    throws IOException {
  if (modifiers.isEmpty()) return;
  for (Modifier modifier : EnumSet.copyOf(modifiers)) {
    if (implicitModifiers.contains(modifier)) continue;
    emitAndIndent(modifier.name().toLowerCase(Locale.US));
    emitAndIndent(" ");
  }
}
 
源代码12 项目: NBANDROID-V2   文件: AndroidStyleableAttr.java
public AndroidStyleableAttr(String name, String description, AndroidStyleableAttrType... attrTypes) {
    this.attrTypes = EnumSet.copyOf(Arrays.asList(attrTypes));
    this.enums = null;
    this.flags = null;
    this.description = description;
    if (name.contains(":")) {
        this.name = name.substring(name.lastIndexOf(':') + 1);
    } else {
        this.name = name;
    }
    handleBugs();
}
 
源代码13 项目: netbeans   文件: JsStructureScanner.java
@Override
public Set<Modifier> getModifiers() {
    Set<Modifier> modifiers = modelElement.getModifiers().isEmpty() ? Collections.EMPTY_SET : EnumSet.copyOf(modelElement.getModifiers());
    if (modifiers.contains(Modifier.PRIVATE) && (modifiers.contains(Modifier.PUBLIC) || modifiers.contains(Modifier.PROTECTED))) {
        modifiers.remove(Modifier.PUBLIC);
        modifiers.remove(Modifier.PROTECTED);
    }
    return modifiers;
}
 
private CacheEventListenerConfigurationBuilder(CacheEventListenerConfigurationBuilder other) {
  eventFiringMode = other.eventFiringMode;
  eventOrdering = other.eventOrdering;
  eventsToFireOn = EnumSet.copyOf(other.eventsToFireOn);
  listenerClass = other.listenerClass;
  this.listenerInstance = other.listenerInstance;
  listenerArguments = other.listenerArguments;
}
 
public EnumSet<DiagnosticPart> getVisible() {
    return EnumSet.copyOf(visibleParts);
}
 
public void setVisible(Set<DiagnosticPart> diagParts) {
    visibleParts = EnumSet.copyOf(diagParts);
}
 
源代码17 项目: tomee   文件: Options.java
@Override
public <T extends Enum<T>> Set<T> getAll(final String property, final T... defaultValue) {
    return EnumSet.copyOf(Arrays.asList(defaultValue));
}
 
源代码18 项目: adventure   文件: LegacyComponentSerializerImpl.java
Style(final @NonNull Style that) {
  this.color = that.color;
  this.decorations = EnumSet.copyOf(that.decorations);
}
 
源代码19 项目: javaide   文件: AbstractDiagnosticFormatter.java
public EnumSet<DiagnosticPart> getVisible() {
    return EnumSet.copyOf(visibleParts);
}
 
源代码20 项目: JDKSourceCode1.8   文件: NumericShaper.java
/**
 * Returns a {@code Set} representing all the Unicode ranges in
 * this {@code NumericShaper} that will be shaped.
 *
 * @return all the Unicode ranges to be shaped.
 * @since 1.7
 */
public Set<Range> getRangeSet() {
    if (rangeSet != null) {
        return EnumSet.copyOf(rangeSet);
    }
    return Range.maskToRangeSet(mask);
}