Java Code Examples for java.util.EnumSet#copyOf()
The following examples show how to use
java.util.EnumSet#copyOf() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListAccountsCmd.java From cloudstack with Apache License 2.0 | 6 votes |
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; }
Example 2
Source File: StackStatusCheckerJobTest.java From cloudbreak with Apache License 2.0 | 6 votes |
@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); }
Example 3
Source File: ListProjectsCmd.java From cloudstack with Apache License 2.0 | 6 votes |
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; }
Example 4
Source File: ListVMsCmd.java From cloudstack with Apache License 2.0 | 6 votes |
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; }
Example 5
Source File: LintDriver.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * 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; } }
Example 6
Source File: ListVMsCmd.java From cosmic with Apache License 2.0 | 6 votes |
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; }
Example 7
Source File: ScheduleCommandEditController.java From arcusandroid with Apache License 2.0 | 5 votes |
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); }
Example 8
Source File: ProxyServerFactoryTests.java From vividus with Apache License 2.0 | 5 votes |
@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]))); }
Example 9
Source File: CodeWriter.java From javapoet with Apache License 2.0 | 5 votes |
/** * 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(" "); } }
Example 10
Source File: DirectoryScanner.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 11
Source File: AndroidStyleableAttr.java From NBANDROID-V2 with Apache License 2.0 | 5 votes |
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(); }
Example 12
Source File: JsStructureScanner.java From netbeans with Apache License 2.0 | 5 votes |
@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; }
Example 13
Source File: CacheEventListenerConfigurationBuilder.java From ehcache3 with Apache License 2.0 | 5 votes |
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; }
Example 14
Source File: NumericShaper.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
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; } }); } }
Example 15
Source File: AbstractDiagnosticFormatter.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public void setVisible(Set<DiagnosticPart> diagParts) { visibleParts = EnumSet.copyOf(diagParts); }
Example 16
Source File: Options.java From tomee with Apache License 2.0 | 4 votes |
@Override public <T extends Enum<T>> Set<T> getAll(final String property, final T... defaultValue) { return EnumSet.copyOf(Arrays.asList(defaultValue)); }
Example 17
Source File: LegacyComponentSerializerImpl.java From adventure with MIT License | 4 votes |
Style(final @NonNull Style that) { this.color = that.color; this.decorations = EnumSet.copyOf(that.decorations); }
Example 18
Source File: AbstractDiagnosticFormatter.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public EnumSet<DiagnosticPart> getVisible() { return EnumSet.copyOf(visibleParts); }
Example 19
Source File: AbstractDiagnosticFormatter.java From javaide with GNU General Public License v3.0 | 4 votes |
public EnumSet<DiagnosticPart> getVisible() { return EnumSet.copyOf(visibleParts); }
Example 20
Source File: NumericShaper.java From JDKSourceCode1.8 with MIT License | 3 votes |
/** * 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); }