/** * Creates an {@code EnumSet} consisting of all enum values that are not in the specified * collection. This is equivalent to {@link EnumSet#complementOf}, but can act on any input * collection, as long as the elements are of enum type. * * @param collection the collection whose complement should be stored in the {@code EnumSet} * @param type the type of the elements in the set * @return a new, modifiable {@code EnumSet} initially containing all the values of the enum not * present in the given collection */ public static <E extends Enum<E>> EnumSet<E> complementOf( Collection<E> collection, Class<E> type) { checkNotNull(collection); return (collection instanceof EnumSet) ? EnumSet.complementOf((EnumSet<E>) collection) : makeComplementByHand(collection, type); }
/** * Creates an {@code EnumSet} consisting of all enum values that are not in the specified * collection. If the collection is an {@link EnumSet}, this method has the same behavior as * {@link EnumSet#complementOf}. Otherwise, the specified collection must contain at least one * element, in order to determine the element type. If the collection could be empty, use {@link * #complementOf(Collection, Class)} instead of this method. * * @param collection the collection whose complement should be stored in the enum set * @return a new, modifiable {@code EnumSet} containing all values of the enum that aren't present * in the given collection * @throws IllegalArgumentException if {@code collection} is not an {@code EnumSet} instance and * contains no elements */ public static <E extends Enum<E>> EnumSet<E> complementOf(Collection<E> collection) { if (collection instanceof EnumSet) { return EnumSet.complementOf((EnumSet<E>) collection); } checkArgument( !collection.isEmpty(), "collection is empty; use the other version of this method"); Class<E> type = collection.iterator().next().getDeclaringClass(); return makeComplementByHand(collection, type); }
@Override public boolean test(Object object) { // Skip Collection test, we override this below to extend the immutability test for collection elements. for (Immutability immutability : EnumSet.complementOf(EnumSet.of(Immutability.COLLECTION))) { if (immutability.test(object)) return true; } return false; } },
protected Set<MetricAttribute> getDisabledAttributes() { final EnumSet<MetricAttribute> metricAttributes = EnumSet.complementOf(getIncludesAttributes()); metricAttributes.addAll(getExcludesAttributes()); return metricAttributes; } }
/** * Creates an {@code EnumSet} consisting of all enum values that are not in the specified * collection. If the collection is an {@link EnumSet}, this method has the same behavior as * {@link EnumSet#complementOf}. Otherwise, the specified collection must contain at least one * element, in order to determine the element type. If the collection could be empty, use {@link * #complementOf(Collection, Class)} instead of this method. * * @param collection the collection whose complement should be stored in the enum set * @return a new, modifiable {@code EnumSet} containing all values of the enum that aren't present * in the given collection * @throws IllegalArgumentException if {@code collection} is not an {@code EnumSet} instance and * contains no elements */ public static <E extends Enum<E>> EnumSet<E> complementOf(Collection<E> collection) { if (collection instanceof EnumSet) { return EnumSet.complementOf((EnumSet<E>) collection); } checkArgument( !collection.isEmpty(), "collection is empty; use the other version of this method"); Class<E> type = collection.iterator().next().getDeclaringClass(); return makeComplementByHand(collection, type); }
@Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setValidator(new EnumValidator<>(EvictionStrategy.class, EnumSet.complementOf(EnumSet.of(EvictionStrategy.MANUAL)))); } },
@Override public ResourceDescriptor apply(ResourceDescriptor descriptor) { return descriptor.addAttributes(EnumSet.complementOf(EnumSet.of(DeprecatedAttribute.MAX_ENTRIES))) .addAlias(DeprecatedAttribute.MAX_ENTRIES, Attribute.SIZE) ; } }
/** * Creates an {@code EnumSet} consisting of all enum values that are not in the specified * collection. This is equivalent to {@link EnumSet#complementOf}, but can act on any input * collection, as long as the elements are of enum type. * * @param collection the collection whose complement should be stored in the {@code EnumSet} * @param type the type of the elements in the set * @return a new, modifiable {@code EnumSet} initially containing all the values of the enum not * present in the given collection */ public static <E extends Enum<E>> EnumSet<E> complementOf( Collection<E> collection, Class<E> type) { checkNotNull(collection); return (collection instanceof EnumSet) ? EnumSet.complementOf((EnumSet<E>) collection) : makeComplementByHand(collection, type); }
@Override public void writeObject(FSTObjectOutput out, Object toWrite, FSTClazzInfo clzInfo, FSTClazzInfo.FSTFieldInfo referencedBy, int streamPosition) throws IOException { EnumSet enset = (EnumSet) toWrite; int count = 0; out.writeInt(enset.size()); if ( enset.isEmpty() ) { //WTF only way to determine enumtype .. EnumSet compl = EnumSet.complementOf(enset); out.writeStringUTF(FSTUtil.getRealEnumClass(compl.iterator().next().getClass()).getName()); } else { for (Object element : enset) { if ( count == 0 ) { out.writeStringUTF(FSTUtil.getRealEnumClass(element.getClass()).getName()); } out.writeStringUTF(element.toString()); count++; } } }
@Override public void registerTransformers(SubsystemTransformerRegistration registration) { // Register transformers for all but the current model for (ModClusterModel modClusterModel : EnumSet.complementOf(EnumSet.of(ModClusterModel.CURRENT))) { ModelVersion version = modClusterModel.getVersion(); register(ModClusterSubsystemResourceDefinition.buildTransformation(version), registration, version); } } }
@Override public void registerTransformers(SubsystemTransformerRegistration registration) { // Register transformers for all but the current model for (InfinispanModel model : EnumSet.complementOf(EnumSet.of(InfinispanModel.CURRENT))) { ModelVersion version = model.getVersion(); register(InfinispanSubsystemResourceDefinition.buildTransformation(version), registration, version); } } }
@Override public void registerTransformers(SubsystemTransformerRegistration registration) { // Register transformers for all but the current model for (SingletonModel model : EnumSet.complementOf(EnumSet.of(SingletonModel.CURRENT))) { ModelVersion version = model.getVersion(); register(SingletonResourceDefinition.buildTransformers(version), registration, version); } } }
@Override public void registerTransformers(SubsystemTransformerRegistration registration) { // Register transformers for all but the current model for (JGroupsModel model : EnumSet.complementOf(EnumSet.of(JGroupsModel.CURRENT))) { ModelVersion version = model.getVersion(); register(JGroupsSubsystemResourceDefinition.buildTransformers(version), registration, version); } } }
@Override public void writeObject(FSTObjectOutput out, Object toWrite, FSTClazzInfo clzInfo, FSTClazzInfo.FSTFieldInfo referencedBy, int streamPosition) throws IOException { EnumSet enset = (EnumSet) toWrite; int count = 0; out.writeInt(enset.size()); if ( enset.isEmpty() ) { //WTF only way to determine enumtype .. EnumSet compl = EnumSet.complementOf(enset); out.writeClassTag(FSTUtil.getRealEnumClass(compl.iterator().next().getClass())); } else { for (Object element : enset) { if ( count == 0 ) { out.writeClassTag(FSTUtil.getRealEnumClass(element.getClass())); } out.writeObjectInternal(element, null, Enum.class); count++; } } }
public static Iterator<Object[]> getSamplesExcept( final EnumSet<NodeType> types) { return getSamples(EnumSet.complementOf(types)); }
private static void writeGenericProtocolAttributes(XMLExtendedStreamWriter writer, Property property) throws XMLStreamException { writer.writeAttribute(XMLAttribute.TYPE.getLocalName(), property.getName()); writeAttributes(writer, property.getValue(), EnumSet.complementOf(EnumSet.of(AbstractProtocolResourceDefinition.Attribute.PROPERTIES))); }
GlobalConfigurationServiceConfigurator(PathAddress address) { super(CONFIGURATION, address); this.name = address.getLastElement().getValue(); this.module = new ServiceSupplierDependency<>(CacheContainerComponent.MODULE.getServiceName(address)); this.transport = new ServiceSupplierDependency<>(CacheContainerComponent.TRANSPORT.getServiceName(address)); this.site = new ServiceSupplierDependency<>(CacheContainerComponent.SITE.getServiceName(address)); for (ThreadPoolResourceDefinition pool : EnumSet.complementOf(EnumSet.of(ThreadPoolResourceDefinition.CLIENT))) { this.pools.put(pool, new ServiceSupplierDependency<>(pool.getServiceName(address))); } for (ScheduledThreadPoolResourceDefinition pool : EnumSet.allOf(ScheduledThreadPoolResourceDefinition.class)) { this.schedulers.put(pool, new ServiceSupplierDependency<>(pool.getServiceName(address))); } }
@Override public void exitUnquotedIdentifier(SqlBaseParser.UnquotedIdentifierContext context) { String identifier = context.IDENTIFIER().getText(); for (IdentifierSymbol identifierSymbol : EnumSet.complementOf(allowedIdentifierSymbols)) { char symbol = identifierSymbol.getSymbol(); if (identifier.indexOf(symbol) >= 0) { throw new ParsingException("identifiers must not contain '" + identifierSymbol.getSymbol() + "'", null, context.IDENTIFIER().getSymbol().getLine(), context.IDENTIFIER().getSymbol().getCharPositionInLine()); } } }
@Test public void nontAuthSuccessesShouldNotThrowAnException() { EnumSet<AuditEventType> userAuthenticationSuccess = EnumSet.of(UserAuthenticationSuccess, PasswordChangeSuccess, UserAccountUnlockedEvent, MfaAuthenticationSuccess); EnumSet<AuditEventType> complementOfUserAuthenticationSuccess = EnumSet.complementOf(userAuthenticationSuccess); for (AuditEventType ofUserAuthenticationSuccess : complementOfUserAuthenticationSuccess) { AuditEvent auditEvent = new AuditEvent(ofUserAuthenticationSuccess, "1", authDetails, "joe", System.currentTimeMillis(), IdentityZone.getUaa().getId(), null, null); auditService.log(auditEvent, "some zone"); } }
@DataProvider public static Object[][] allTypeComponentButFile() { Object[][] res = new Object[Component.Type.values().length - 1][1]; int i = 0; for (Component.Type type : EnumSet.complementOf(EnumSet.of(Component.Type.FILE))) { if (type.isReportType()) { res[i][0] = ReportComponent.builder(type, i).build(); } else { res[i][0] = ViewsComponent.builder(type, i).build(); } i++; } return res; }