下面列出了java.util.EnumSet#copyOf ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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;
}
/**
* 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;
}
}
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;
}
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;
}
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;
}
@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);
}
/**
* 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;
}
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);
}
@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])));
}
/**
* 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(" ");
}
}
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();
}
@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);
}
@Override
public <T extends Enum<T>> Set<T> getAll(final String property, final T... defaultValue) {
return EnumSet.copyOf(Arrays.asList(defaultValue));
}
Style(final @NonNull Style that) {
this.color = that.color;
this.decorations = EnumSet.copyOf(that.decorations);
}
public EnumSet<DiagnosticPart> getVisible() {
return EnumSet.copyOf(visibleParts);
}
/**
* 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);
}