Java Code Examples for java.util.EnumSet#removeAll()
The following examples show how to use
java.util.EnumSet#removeAll() .
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: ModelGenerator.java From netbeans with Apache License 2.0 | 6 votes |
private String overrideSync( String url, Map<HttpRequests, String> httpPaths, Map<HttpRequests, Boolean> useIds ) throws IOException { StringBuilder builder = new StringBuilder(); for( Entry<HttpRequests,String> entry : httpPaths.entrySet() ){ overrideMethod(url, entry.getValue(), useIds.get(entry.getKey()), entry.getKey(), builder); } EnumSet<HttpRequests> set = EnumSet.allOf(HttpRequests.class); set.removeAll( httpPaths.keySet()); for( HttpRequests request : set ){ overrideMethod(url, null, null, request, builder); } return getModifierdSync(builder.toString()); }
Example 2
Source File: CodeStyle.java From netbeans with Apache License 2.0 | 5 votes |
private boolean check(ElementKind kind, Set<Modifier> modifiers) { if (this.kind != kind) return false; if (modifiers == null || modifiers.isEmpty()) return mods.isEmpty(); if (!modifiers.containsAll(this.mods)) return false; EnumSet<Modifier> copy = EnumSet.copyOf(modifiers); copy.removeAll(this.mods); copy.retainAll(ignoreVisibility? EnumSet.of(Modifier.STATIC) : EnumSet.of(Modifier.STATIC, Modifier.PUBLIC, Modifier.PRIVATE, Modifier.PROTECTED)); return copy.isEmpty(); }
Example 3
Source File: ConnectionProfile.java From crate with Apache License 2.0 | 5 votes |
/** * Creates a new {@link ConnectionProfile} based on the added connections. * @throws IllegalStateException if any of the {@link org.elasticsearch.transport.TransportRequestOptions.Type} enum is missing */ public ConnectionProfile build() { EnumSet<TransportRequestOptions.Type> types = EnumSet.allOf(TransportRequestOptions.Type.class); types.removeAll(addedTypes); if (types.isEmpty() == false) { throw new IllegalStateException("not all types are added for this connection profile - missing types: " + types); } return new ConnectionProfile(Collections.unmodifiableList(handles), numConnections, connectTimeout, handshakeTimeout, pingInterval, compressionEnabled); }
Example 4
Source File: BlipMetaDomImpl.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
@Override public void disable(Set<MenuOption> toDisable) { Pair<EnumMap<MenuOption, BlipMenuItemDomImpl>, EnumSet<MenuOption>> state = getMenuState(); EnumSet<MenuOption> options = EnumSet.copyOf(state.first.keySet()); EnumSet<MenuOption> selected = state.second; options.removeAll(toDisable); selected.removeAll(toDisable); setMenuState(options, selected); }
Example 5
Source File: EnumFilterConverter.java From bazel with Apache License 2.0 | 5 votes |
/** * Returns the set of allowed values for the option. * * Implements {@link #convert(String)}. */ @Override public Set<E> convert(String input) throws OptionsParsingException { if (input.isEmpty()) { return Collections.emptySet(); } EnumSet<E> includedSet = EnumSet.noneOf(typeClass); EnumSet<E> excludedSet = EnumSet.noneOf(typeClass); for (String value : input.split(",", -1)) { boolean excludeFlag = value.startsWith("-"); String s = (excludeFlag ? value.substring(1) : value).toUpperCase(); if (!allowedValues.contains(s)) { throw new OptionsParsingException("Invalid " + prettyEnumName + " filter '" + value + "' in the input '" + input + "'"); } (excludeFlag ? excludedSet : includedSet).add(Enum.valueOf(typeClass, s)); } if (includedSet.isEmpty()) { includedSet = EnumSet.complementOf(excludedSet); } else { includedSet.removeAll(excludedSet); } if (includedSet.isEmpty()) { throw new OptionsParsingException( Character.toUpperCase(prettyEnumName.charAt(0)) + prettyEnumName.substring(1) + " filter '" + input + "' definition cannot match any tests"); } return includedSet; }
Example 6
Source File: BlipMetaDomImpl.java From swellrt with Apache License 2.0 | 5 votes |
@Override public void disable(Set<MenuOption> toDisable) { Pair<EnumMap<MenuOption, BlipMenuItemDomImpl>, EnumSet<MenuOption>> state = getMenuState(); EnumSet<MenuOption> options = EnumSet.copyOf(state.first.keySet()); EnumSet<MenuOption> selected = state.second; options.removeAll(toDisable); selected.removeAll(toDisable); setMenuState(options, selected); }
Example 7
Source File: BaseUDPSourceTest.java From datacollector with Apache License 2.0 | 5 votes |
public void testIterator(int numThreads, boolean epoll) throws Exception { int maxRuns = 3; List<AssertionError> failures = new ArrayList<>(); EnumSet<DatagramMode> remainingFormats = EnumSet.of( DatagramMode.NETFLOW, DatagramMode.SYSLOG, DatagramMode.RAW_DATA ); for (int i = 0; i < maxRuns; i++) { try { EnumSet<DatagramMode> succeededFormats = EnumSet.noneOf(DatagramMode.class); for (DatagramMode mode : remainingFormats) { doBasicTest(mode, epoll, numThreads); succeededFormats.add(mode); } remainingFormats.removeAll(succeededFormats); } catch (Exception ex) { // we don't expect exceptions to be thrown, // even when udp messages are lost throw ex; } catch (AssertionError failure) { String msg = "Test failed on iteration: " + i; LOG.error(msg, failure); failures.add(failure); Assert.assertTrue("Interrupted while sleeping", ThreadUtil.sleep(10 * 1000)); } } if (failures.size() >= maxRuns) { throw failures.get(0); } }
Example 8
Source File: SecurityCatalogService.java From streamline with Apache License 2.0 | 5 votes |
public boolean checkUserPermissions(String objectNamespace, Long objectId, Long userId, EnumSet<Permission> required) { User user = getUser(userId); if (user == null) { return false; } EnumSet<Permission> remaining = EnumSet.copyOf(required); // try direct user acl entry first List<QueryParam> qps = QueryParam.params( AclEntry.OBJECT_NAMESPACE, objectNamespace, AclEntry.OBJECT_ID, String.valueOf(objectId), AclEntry.SID_TYPE, USER.toString(), AclEntry.SID_ID, String.valueOf(userId)); Collection<AclEntry> acls = listAcls(qps); if (acls.size() > 1) { throw new IllegalStateException("More than one ACL entry for " + qps); } else if (acls.size() == 1) { AclEntry aclEntry = acls.iterator().next(); remaining.removeAll(aclEntry.getPermissions()); } // try role based permissions next if (!remaining.isEmpty() && user.getRoles() != null) { qps = QueryParam.params( AclEntry.OBJECT_NAMESPACE, objectNamespace, AclEntry.OBJECT_ID, String.valueOf(objectId), AclEntry.SID_TYPE, AclEntry.SidType.ROLE.toString()); acls = listAcls(qps); Set<Role> userRoles = getAllUserRoles(user); Iterator<AclEntry> it = acls.iterator(); while (!remaining.isEmpty() && it.hasNext()) { AclEntry roleEntry = it.next(); if (userRoles.contains(getRole(roleEntry.getSidId()))) { remaining.removeAll(roleEntry.getPermissions()); } } } return remaining.isEmpty(); }
Example 9
Source File: SecurityCatalogResource.java From streamline with Apache License 2.0 | 5 votes |
private boolean shouldAllowAclAddOrUpdate(AclEntry aclEntry, SecurityContext securityContext) { if (SecurityUtil.hasRole(authorizer, securityContext, ROLE_SECURITY_ADMIN)) { return true; } User currentUser = getCurrentUser(securityContext); // check if the current user is the owner or can grant permission on the specific object EnumSet<Permission> remaining = aclEntry.getPermissions(); Collection<AclEntry> userAcls = catalogService.listUserAcls(currentUser.getId(), aclEntry.getObjectNamespace(), aclEntry.getObjectId()); for (AclEntry userAcl : userAcls) { if (userAcl.isOwner()) { return true; } else if (userAcl.isGrant()) { remaining.removeAll(userAcl.getPermissions()); if (remaining.isEmpty()) { return true; } } } // check if any roles that the current user belongs to is the owner or can grant Set<Role> currentUserRoles = catalogService.getAllUserRoles(currentUser); for (Role role : currentUserRoles) { Collection<AclEntry> roleAcls = catalogService.listRoleAcls(role.getId(), aclEntry.getObjectNamespace(), aclEntry.getObjectId()); for (AclEntry roleAcl : roleAcls) { if (roleAcl.isOwner()) { return true; } else if (roleAcl.isGrant()) { remaining.removeAll(roleAcl.getPermissions()); if (remaining.isEmpty()) { return true; } } } } return false; }
Example 10
Source File: GridClientDataImpl.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public GridClientData flagsOff(GridClientCacheFlag... flags) throws GridClientException { if (flags == null || flags.length == 0 || this.flags == null || this.flags.isEmpty()) return this; EnumSet<GridClientCacheFlag> flagSet = EnumSet.copyOf(this.flags); flagSet.removeAll(Arrays.asList(flags)); return createProjection(nodes, filter, balancer, new GridClientDataFactory(flagSet)); }
Example 11
Source File: DatadogExpansionFilteredReporterFactory.java From emodb with Apache License 2.0 | 5 votes |
private EnumSet<DatadogReporter.Expansion> getExpansions() { final EnumSet<DatadogReporter.Expansion> expansions; if (_includeExpansions == null) { expansions = EnumSet.allOf(DatadogReporter.Expansion.class); } else { expansions = EnumSet.copyOf(asExpansions(_includeExpansions)); } if (_excludeExpansions != null) { expansions.removeAll(asExpansions(_excludeExpansions)); } return expansions; }
Example 12
Source File: SemanticHighlighterBase.java From netbeans with Apache License 2.0 | 5 votes |
private boolean hasAllTypes(List<Use> uses, EnumSet<UseTypes> types) { for (Use u : uses) { if (types.isEmpty()) { return true; } types.removeAll(u.type); } return types.isEmpty(); }
Example 13
Source File: Sets.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
private static <E extends Enum<E>> EnumSet<E> makeComplementByHand( Collection<E> collection, Class<E> type) { EnumSet<E> result = EnumSet.allOf(type); result.removeAll(collection); return result; }
Example 14
Source File: Sets.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
private static <E extends Enum<E>> EnumSet<E> makeComplementByHand(Collection<E> collection, Class<E> type) { EnumSet<E> result = EnumSet.allOf(type); result.removeAll(collection); return result; }
Example 15
Source File: Sets.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
private static <E extends Enum<E>> EnumSet<E> makeComplementByHand(Collection<E> collection, Class<E> type) { EnumSet<E> result = EnumSet.allOf(type); result.removeAll(collection); return result; }
Example 16
Source File: Sets.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
private static <E extends Enum<E>> EnumSet<E> makeComplementByHand(Collection<E> collection, Class<E> type) { EnumSet<E> result = EnumSet.allOf(type); result.removeAll(collection); return result; }
Example 17
Source File: Sets.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
private static <E extends Enum<E>> EnumSet<E> makeComplementByHand(Collection<E> collection, Class<E> type) { EnumSet<E> result = EnumSet.allOf(type); result.removeAll(collection); return result; }
Example 18
Source File: RamUsageEstimator.java From incubator-retired-blur with Apache License 2.0 | 4 votes |
/** Return the set of unsupported JVM features that improve the estimation. */ public static EnumSet<JvmFeature> getUnsupportedFeatures() { EnumSet<JvmFeature> unsupported = EnumSet.allOf(JvmFeature.class); unsupported.removeAll(supportedFeatures); return unsupported; }
Example 19
Source File: RamUsageEstimator.java From incubator-iotdb with Apache License 2.0 | 4 votes |
/** * Return the set of unsupported JVM features that improve the estimation. */ public static EnumSet<JvmFeature> getUnsupportedFeatures() { EnumSet<JvmFeature> unsupported = EnumSet.allOf(JvmFeature.class); unsupported.removeAll(supportedFeatures); return unsupported; }