本文整理了Java中java.util.EnumSet.complementOf()
方法的一些代码示例,展示了EnumSet.complementOf()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EnumSet.complementOf()
方法的具体详情如下:
包路径:java.util.EnumSet
类名称:EnumSet
方法名:complementOf
[英]Creates an enum set. All the contained elements complement those from the specified enum set.
[中]
代码示例来源:origin: google/guava
/**
* 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);
}
代码示例来源:origin: google/guava
/**
* 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);
}
代码示例来源:origin: wildfly/wildfly
@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;
}
},
代码示例来源:origin: dropwizard/dropwizard
protected Set<MetricAttribute> getDisabledAttributes() {
final EnumSet<MetricAttribute> metricAttributes = EnumSet.complementOf(getIncludesAttributes());
metricAttributes.addAll(getExcludesAttributes());
return metricAttributes;
}
}
代码示例来源:origin: prestodb/presto
/**
* 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);
}
代码示例来源:origin: wildfly/wildfly
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder.setValidator(new EnumValidator<>(EvictionStrategy.class, EnumSet.complementOf(EnumSet.of(EvictionStrategy.MANUAL))));
}
},
代码示例来源:origin: wildfly/wildfly
@Override
public ResourceDescriptor apply(ResourceDescriptor descriptor) {
return descriptor.addAttributes(EnumSet.complementOf(EnumSet.of(DeprecatedAttribute.MAX_ENTRIES)))
.addAlias(DeprecatedAttribute.MAX_ENTRIES, Attribute.SIZE)
;
}
}
代码示例来源:origin: prestodb/presto
/**
* 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);
}
代码示例来源:origin: redisson/redisson
@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++;
}
}
}
代码示例来源:origin: wildfly/wildfly
@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);
}
}
}
代码示例来源:origin: wildfly/wildfly
@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);
}
}
}
代码示例来源:origin: wildfly/wildfly
@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);
}
}
}
代码示例来源:origin: wildfly/wildfly
@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);
}
}
}
代码示例来源:origin: redisson/redisson
@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++;
}
}
}
代码示例来源:origin: java-json-tools/json-schema-validator
public static Iterator<Object[]> getSamplesExcept(
final EnumSet<NodeType> types)
{
return getSamples(EnumSet.complementOf(types));
}
代码示例来源:origin: wildfly/wildfly
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)));
}
代码示例来源:origin: wildfly/wildfly
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)));
}
}
代码示例来源:origin: prestodb/presto
@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());
}
}
}
代码示例来源:origin: cloudfoundry/uaa
@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");
}
}
代码示例来源:origin: SonarSource/sonarqube
@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;
}
内容来源于网络,如有侵权,请联系作者删除!