Java Code Examples for java.util.EnumSet#noneOf()
The following examples show how to use
java.util.EnumSet#noneOf() .
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: AggregateReduceFunctionsRule.java From Quicksql with MIT License | 6 votes |
/** * Creates an AggregateReduceFunctionsRule with client * provided information on which specific functions will * be reduced by this rule * @param aggregateClass aggregate class * @param relBuilderFactory builder for relational expressions * @param functionsToReduce client provided information * on which specific functions * will be reduced by this rule */ public AggregateReduceFunctionsRule(Class<? extends Aggregate> aggregateClass, RelBuilderFactory relBuilderFactory, EnumSet<SqlKind> functionsToReduce) { super(operand(aggregateClass, any()), relBuilderFactory, null); Objects.requireNonNull(functionsToReduce, "Expecting a valid handle for AggregateFunctionsToReduce"); this.functionsToReduce = EnumSet.noneOf(SqlKind.class); for (SqlKind function : functionsToReduce) { if (SqlKind.AVG_AGG_FUNCTIONS.contains(function) || SqlKind.COVAR_AVG_AGG_FUNCTIONS.contains(function) || function == SqlKind.SUM) { this.functionsToReduce.add(function); } else { throw new IllegalArgumentException( "AggregateReduceFunctionsRule doesn't support function: " + function.sql); } } }
Example 2
Source File: ClusterState.java From Elasticsearch with Apache License 2.0 | 6 votes |
public static EnumSet<Metric> parseString(String param, boolean ignoreUnknown) { String[] metrics = Strings.splitStringByCommaToArray(param); EnumSet<Metric> result = EnumSet.noneOf(Metric.class); for (String metric : metrics) { if ("_all".equals(metric)) { result = EnumSet.allOf(Metric.class); break; } Metric m = valueToEnum.get(metric); if (m == null) { if (!ignoreUnknown) { throw new IllegalArgumentException("Unknown metric [" + metric + "]"); } } else { result.add(m); } } return result; }
Example 3
Source File: CompositeValueClass.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override protected EnumSet<OperandFlag> getFlags(Field field) { EnumSet<OperandFlag> result = EnumSet.noneOf(OperandFlag.class); if (field.isAnnotationPresent(CompositeValue.Component.class)) { result.addAll(Arrays.asList(field.getAnnotation(CompositeValue.Component.class).value())); } else { GraalError.shouldNotReachHere(); } return result; }
Example 4
Source File: TimeZoneFormat.java From fitnotifications with Apache License 2.0 | 5 votes |
/** * Returns the default parse options used by this <code>TimeZoneFormat</code> instance. * @return the default parse options. * @see ParseOption * @stable ICU 49 */ public EnumSet<ParseOption> getDefaultParseOptions() { if (_parseAllStyles && _parseTZDBNames) { return EnumSet.of(ParseOption.ALL_STYLES, ParseOption.TZ_DATABASE_ABBREVIATIONS); } else if (_parseAllStyles) { return EnumSet.of(ParseOption.ALL_STYLES); } else if (_parseTZDBNames) { return EnumSet.of(ParseOption.TZ_DATABASE_ABBREVIATIONS); } return EnumSet.noneOf(ParseOption.class); }
Example 5
Source File: DataflowProjectCreator.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
/** * Returns all of the validation failures in this {@code DataflowProject}. */ private Collection<DataflowProjectValidationStatus> failedValidations() { Collection<DataflowProjectValidationStatus> statuses = EnumSet.noneOf(DataflowProjectValidationStatus.class); statuses.add(validateProjectName()); statuses.add(validateProjectLocation()); statuses.add(validateMavenGroupId()); statuses.add(validateMavenArtifactId()); statuses.add(validatePackage()); // Must be last: Remove OK so the set contains only failed validations. statuses.remove(DataflowProjectValidationStatus.OK); return statuses; }
Example 6
Source File: RichDiagnosticFormatter.java From hottub with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("fallthrough") public RichConfiguration(Options options, AbstractDiagnosticFormatter formatter) { super(formatter.getConfiguration()); features = formatter.isRaw() ? EnumSet.noneOf(RichFormatterFeature.class) : EnumSet.of(RichFormatterFeature.SIMPLE_NAMES, RichFormatterFeature.WHERE_CLAUSES, RichFormatterFeature.UNIQUE_TYPEVAR_NAMES); String diagOpts = options.get("diags"); if (diagOpts != null) { for (String args: diagOpts.split(",")) { if (args.equals("-where")) { features.remove(RichFormatterFeature.WHERE_CLAUSES); } else if (args.equals("where")) { features.add(RichFormatterFeature.WHERE_CLAUSES); } if (args.equals("-simpleNames")) { features.remove(RichFormatterFeature.SIMPLE_NAMES); } else if (args.equals("simpleNames")) { features.add(RichFormatterFeature.SIMPLE_NAMES); } if (args.equals("-disambiguateTvars")) { features.remove(RichFormatterFeature.UNIQUE_TYPEVAR_NAMES); } else if (args.equals("disambiguateTvars")) { features.add(RichFormatterFeature.UNIQUE_TYPEVAR_NAMES); } } } }
Example 7
Source File: VIEW_TABLE_FORMAT.java From org.openntf.domino with Apache License 2.0 | 5 votes |
public static Set<Flag> valuesOf(final short flags) { Set<Flag> result = EnumSet.noneOf(Flag.class); for (Flag flag : values()) { if ((flag.getValue() & flags) > 0) { result.add(flag); } } return result; }
Example 8
Source File: IVerrechenbar.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
/** * Get an EnumSet of {@link VatInfo} from a String representation produced with * {@link VatInfo#encodeAsString(EnumSet)}. * * @param code * @return */ public static EnumSet<VatInfo> decodeFromString(String code){ String[] names = code.split(","); EnumSet<VatInfo> ret = EnumSet.noneOf(VatInfo.class); for (int i = 0; i < names.length; i++) { ret.add(VatInfo.valueOf(names[i])); } return ret; }
Example 9
Source File: Sets.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
/** * Returns a new, <i>mutable</i> {@code EnumSet} instance containing the given elements in their * natural order. This method behaves identically to {@link EnumSet#copyOf(Collection)}, but also * accepts non-{@code Collection} iterables and empty iterables. */ public static <E extends Enum<E>> EnumSet<E> newEnumSet( Iterable<E> iterable, Class<E> elementType) { EnumSet<E> set = EnumSet.noneOf(elementType); Iterables.addAll(set, iterable); return set; }
Example 10
Source File: BoxPermission.java From box-android-sdk with Apache License 2.0 | 5 votes |
EnumSet<BoxItem.Permission> getPermissions() { EnumSet<BoxItem.Permission> permissions = EnumSet.noneOf(BoxItem.Permission.class); for (String key : getPropertiesKeySet()){ Boolean value = getPropertyAsBoolean(key); if (value == null || value == false) { continue; } if (key.equals(BoxItem.Permission.CAN_DOWNLOAD.toString())) { permissions.add(BoxItem.Permission.CAN_DOWNLOAD); } else if (key.equals(BoxItem.Permission.CAN_UPLOAD.toString())) { permissions.add(BoxItem.Permission.CAN_UPLOAD); } else if (key.equals(BoxItem.Permission.CAN_RENAME.toString())) { permissions.add(BoxItem.Permission.CAN_RENAME); } else if (key.equals(BoxItem.Permission.CAN_DELETE.toString())) { permissions.add(BoxItem.Permission.CAN_DELETE); } else if (key.equals(BoxItem.Permission.CAN_SHARE.toString())) { permissions.add(BoxItem.Permission.CAN_SHARE); } else if (key.equals(BoxItem.Permission.CAN_SET_SHARE_ACCESS.toString())) { permissions.add(BoxItem.Permission.CAN_SET_SHARE_ACCESS); } else if (key.equals(BoxItem.Permission.CAN_PREVIEW.toString())) { permissions.add(BoxItem.Permission.CAN_PREVIEW); } else if (key.equals(BoxItem.Permission.CAN_COMMENT.toString())) { permissions.add(BoxItem.Permission.CAN_COMMENT); } else if (key.equals(BoxItem.Permission.CAN_INVITE_COLLABORATOR.toString())) { permissions.add(BoxItem.Permission.CAN_INVITE_COLLABORATOR); } } return permissions; }
Example 11
Source File: SimpleDocTreeVisitorTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
void run() throws Exception { List<File> files = new ArrayList<File>(); File testSrc = new File(System.getProperty("test.src")); for (File f: testSrc.listFiles()) { if (f.isFile() && f.getName().endsWith(".java")) files.add(f); } JavacTool javac = JavacTool.create(); StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null); Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files); JavacTask t = javac.getTask(null, fm, null, null, null, fos); DocTrees trees = DocTrees.instance(t); Iterable<? extends CompilationUnitTree> units = t.parse(); Set<DocTree.Kind> found = EnumSet.noneOf(DocTree.Kind.class); DeclScanner ds = new DeclScanner(trees, found); for (CompilationUnitTree unit: units) { ds.scan(unit, null); } for (DocTree.Kind k: DocTree.Kind.values()) { if (!found.contains(k) && k != DocTree.Kind.OTHER) error("not found: " + k); } if (errors > 0) throw new Exception(errors + " errors occurred"); }
Example 12
Source File: Flags.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static EnumSet<Flag> asFlagSet(long flags) { EnumSet<Flag> flagSet = EnumSet.noneOf(Flag.class); for (Flag flag : Flag.values()) { if ((flags & flag.value) != 0) { flagSet.add(flag); flags &= ~flag.value; } } Assert.check(flags == 0); return flagSet; }
Example 13
Source File: OperationHeaders.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static OperationHeaders fromOperation(ModelNode operation) throws OperationFailedException { final EnumSet<OperationContextImpl.ContextFlag> contextFlags; Integer blockingTimeout = null; String warningLevel = null; String domainUUID = null; AccessMechanism accessMechanism = null; if (operation.hasDefined(OPERATION_HEADERS)) { final ModelNode headers = operation.get(OPERATION_HEADERS).clone(); final boolean rollbackOnFailure = ROLLBACK.resolveModelAttribute(ExpressionResolver.REJECTING, headers).asBoolean(); final boolean restartResourceServices = RESTART.resolveModelAttribute(ExpressionResolver.REJECTING, headers).asBoolean(); contextFlags = rollbackOnFailure ? EnumSet.of(AbstractOperationContext.ContextFlag.ROLLBACK_ON_FAIL) : EnumSet.noneOf(OperationContextImpl.ContextFlag.class); if (restartResourceServices) { contextFlags.add(AbstractOperationContext.ContextFlag.ALLOW_RESOURCE_SERVICE_RESTART); } final ModelNode blockingTimeoutConfig = BLOCKING.resolveModelAttribute(ExpressionResolver.REJECTING, headers); if (blockingTimeoutConfig.isDefined()) { blockingTimeout = blockingTimeoutConfig.asInt(); // Check the value is positive. We could use a ParameterValidator on the AttributeDefinition to do this but since // in the past we used this particular failure message, let's stick with it just to not change things. // Note that failure message compatibility has never been a requirement though, so we could change this. if (blockingTimeout < 1) { throw ControllerLogger.MGMT_OP_LOGGER.invalidBlockingTimeout(blockingTimeout.longValue(), BLOCKING_TIMEOUT); } } warningLevel = headers.hasDefined(WARNING_LEVEL) ? headers.get(WARNING_LEVEL).asString() : null; domainUUID = headers.hasDefined(DOMAIN_UUID) ? headers.get(DOMAIN_UUID).asString() : null; accessMechanism = headers.hasDefined(ACCESS_MECHANISM) ? AccessMechanism.valueOf(headers.get(ACCESS_MECHANISM).asString()) : null; } else { contextFlags = EnumSet.of(AbstractOperationContext.ContextFlag.ROLLBACK_ON_FAIL); } return new OperationHeaders(contextFlags, blockingTimeout, warningLevel, domainUUID, accessMechanism); }
Example 14
Source File: JsonPathUtils.java From vividus with Apache License 2.0 | 4 votes |
@Override public Set<Option> options() { return EnumSet.noneOf(Option.class); }
Example 15
Source File: java_util_RegularEnumSet.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
protected Set<EnumPublic> getAnotherObject() { Set<EnumPublic> set = EnumSet.noneOf(EnumPublic.class); set.add(EnumPublic.A); set.add(EnumPublic.Z); return set; }
Example 16
Source File: GenericData.java From google-http-java-client with Apache License 2.0 | 4 votes |
/** Constructs with case-insensitive keys. */ public GenericData() { this(EnumSet.noneOf(Flags.class)); }
Example 17
Source File: CollectionFactoryTests.java From java-technology-stack with MIT License | 4 votes |
@Test // SPR-17619 public void createsEnumSetSubclass() { EnumSet<Color> enumSet = EnumSet.noneOf(Color.class); assertThat(createCollection(enumSet.getClass(), Color.class, 0), is(instanceOf(enumSet.getClass()))); }
Example 18
Source File: LoggingSubsystemParser_1_2.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Override void parseSizeRotatingHandlerElement(final XMLExtendedStreamReader reader, final PathAddress address, final List<ModelNode> operations, final Set<String> names) throws XMLStreamException { final ModelNode operation = Util.createAddOperation(); // Attributes String name = null; final EnumSet<Attribute> required = EnumSet.of(Attribute.NAME); final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); required.remove(attribute); switch (attribute) { case NAME: { name = value; break; } case AUTOFLUSH: { AUTOFLUSH.parseAndSetParameter(value, operation, reader); break; } case ENABLED: { ENABLED.parseAndSetParameter(value, operation, reader); break; } default: throw unexpectedAttribute(reader, i); } } if (!required.isEmpty()) { throw missingRequired(reader, required); } if (!names.add(name)) { throw duplicateNamedElement(reader, name); } // Setup the operation address addOperationAddress(operation, address, SizeRotatingHandlerResourceDefinition.NAME, name); final EnumSet<Element> requiredElem = EnumSet.of(Element.FILE); final EnumSet<Element> encountered = EnumSet.noneOf(Element.class); while (reader.nextTag() != END_ELEMENT) { final Element element = Element.forName(reader.getLocalName()); if (!encountered.add(element)) { throw unexpectedElement(reader); } requiredElem.remove(element); switch (element) { case LEVEL: { LEVEL.parseAndSetParameter(readNameAttribute(reader), operation, reader); break; } case ENCODING: { ENCODING.parseAndSetParameter(readValueAttribute(reader), operation, reader); break; } case FILTER_SPEC: { SizeRotatingHandlerResourceDefinition.FILTER_SPEC.parseAndSetParameter(readValueAttribute(reader), operation, reader); break; } case FORMATTER: { parseHandlerFormatterElement(reader, operation); break; } case FILE: { parseFileElement(operation.get(FILE.getName()), reader); break; } case APPEND: { APPEND.parseAndSetParameter(readValueAttribute(reader), operation, reader); break; } case ROTATE_SIZE: { ROTATE_SIZE.parseAndSetParameter(readValueAttribute(reader), operation, reader); break; } case MAX_BACKUP_INDEX: { MAX_BACKUP_INDEX.parseAndSetParameter(readValueAttribute(reader), operation, reader); break; } default: { throw unexpectedElement(reader); } } } operations.add(operation); }
Example 19
Source File: YogaFacts.java From Astrosoft with GNU General Public License v2.0 | 3 votes |
public void setPowerfulPlanets(Map<Planet, Double> strengthPercent){ powerfulPlanets = EnumSet.noneOf(Planet.class); for(Entry<Planet,Double> entry : strengthPercent.entrySet()){ if (entry.getValue().doubleValue() >= POWERFUL_PLANET_THRESHOLD){ powerfulPlanets.add(entry.getKey()); } } log.fine(powerfulPlanets.toString()); }
Example 20
Source File: EnumUtils.java From astor with GNU General Public License v2.0 | 3 votes |
/** * <p>Creates a bit vector representation of the given subset of an Enum using as many {@code long}s as needed.</p> * * <p>This generates a value that is usable by {@link EnumUtils#processBitVectors}.</p> * * <p>Use this method if you have more than 64 values in your Enum.</p> * * @param enumClass the class of the enum we are working with, not {@code null} * @param values the values we want to convert, not {@code null}, neither containing {@code null} * @param <E> the type of the enumeration * @return a long[] whose values provide a binary representation of the given set of enum values * with least significant digits rightmost. * @throws NullPointerException if {@code enumClass} or {@code values} is {@code null} * @throws IllegalArgumentException if {@code enumClass} is not an enum class, or if any {@code values} {@code null} * @since 3.2 */ public static <E extends Enum<E>> long[] generateBitVectors(Class<E> enumClass, E... values) { asEnum(enumClass); Validate.noNullElements(values); final EnumSet<E> condensed = EnumSet.noneOf(enumClass); Collections.addAll(condensed, values); final long[] result = new long[(enumClass.getEnumConstants().length - 1) / Long.SIZE + 1]; for (E value : condensed) { result[value.ordinal() / Long.SIZE] |= 1 << (value.ordinal() % Long.SIZE); } ArrayUtils.reverse(result); return result; }