Java Code Examples for java.util.EnumSet#size()
The following examples show how to use
java.util.EnumSet#size() .
These examples are extracted from open source projects.
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 Project: linstor-server File: FlagsHelper.java License: GNU General Public License v3.0 | 6 votes |
public static <E extends Enum<E> & Flags> List<String> toStringList( Class<E> enumClass, long rscFlags ) { EnumSet<E> values = EnumSet.allOf(enumClass); List<String> strList = new ArrayList<>(values.size()); for (E en : values) { if ((rscFlags & en.getFlagValue()) == en.getFlagValue()) { strList.add(en.toString()); } } return strList; }
Example 2
Source Project: arcusandroid File: IrrigationScheduleCommandEditorFragment.java License: Apache License 2.0 | 5 votes |
@Override public void onSaveEvent(EnumSet selectedDays, TimeOfDay timeOfDay) { int selectedHour = timeOfDay.getHours(); int selectedMinute = timeOfDay.getMinutes(); if(selectedDays.size() > 1 && isEditMode()) { confirmUpdateAllDays(selectedDays, selectedHour, selectedMinute); } else { saveEvent(selectedDays, selectedHour, selectedMinute, false); } }
Example 3
Source Project: pixate-freestyle-android File: PXParserBase.java License: Apache License 2.0 | 5 votes |
/** * Assert that the current lexeme matches one of the types in the specified * set. If it does not match, then throw an exception. * * @param types An set containing a collection of types to match against */ public void assertTypeInSet(EnumSet<T> types) { if (!isInTypeSet(types)) { List<String> typeNames = new ArrayList<String>(types.size()); for (Enum<T> s : types) { typeNames.add(s.toString()); } errorWithMessage("Expected a token of one of these types: " + typeNames); } }
Example 4
Source Project: azure-storage-android File: FileRequest.java License: Apache License 2.0 | 5 votes |
/** * Constructs a request to return a listing of all shares in this storage account. Sign with no length * specified. * * @param uri * A <code>java.net.URI</code> object that specifies the absolute URI. * @param fileOptions * A {@link FileRequestOptions} object that specifies execution options such as retry policy and timeout * settings for the operation. Specify <code>null</code> to use the request options specified on the * {@link CloudFileClient}. * @param opContext * An {@link OperationContext} object that represents the context for the current operation. This object * is used to track requests to the storage service, and to provide additional runtime information about * the operation. * @param listingContext * A set of parameters for the listing operation. * @param detailsIncluded * A <code>java.util.EnumSet</code> object that contains {@link ShareListingDetails} values that indicate * whether share snapshots and/or metadata will be returned. * @return a HttpURLConnection configured for the operation. * @throws IOException * @throws URISyntaxException * @throws StorageException * @throws IllegalArgumentException */ public static HttpURLConnection listShares(final URI uri, final FileRequestOptions fileOptions, final OperationContext opContext, final ListingContext listingContext, final EnumSet<ShareListingDetails> detailsIncluded) throws URISyntaxException, IOException, StorageException { final UriQueryBuilder builder = BaseRequest.getListUriQueryBuilder(listingContext); if (detailsIncluded != null && detailsIncluded.size() > 0) { final StringBuilder sb = new StringBuilder(); boolean started = false; if (detailsIncluded.contains(ShareListingDetails.SNAPSHOTS)) { started = true; sb.append(SNAPSHOTS_QUERY_ELEMENT_NAME); } if (detailsIncluded.contains(ShareListingDetails.METADATA)) { if (started) { sb.append(","); } sb.append(Constants.QueryConstants.METADATA); } builder.add(Constants.QueryConstants.INCLUDE, sb.toString()); } final HttpURLConnection request = BaseRequest.createURLConnection(uri, fileOptions, builder, opContext); request.setRequestMethod(Constants.HTTP_GET); return request; }
Example 5
Source Project: wildfly-core File: HostXml_14.java License: GNU Lesser General Public License v2.1 | 5 votes |
protected void parseDiscoveryOptionProperty(XMLExtendedStreamReader reader, ModelNode discoveryOptionProperties) throws XMLStreamException { String propertyName = null; String propertyValue = null; EnumSet<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.VALUE); 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: { propertyName = value; break; } case VALUE: { propertyValue = value; break; } default: throw unexpectedAttribute(reader, i); } } if (required.size() > 0) { throw missingRequired(reader, required); } discoveryOptionProperties.add(propertyName, propertyValue); requireNoContent(reader); }
Example 6
Source Project: android-app File: QueueItem.java License: GNU General Public License v3.0 | 5 votes |
public static String enumSetToString(EnumSet<ArticleChangeType> enumSet) { if(enumSet.isEmpty()) return ""; if(enumSet.size() == 1) return enumSet.iterator().next().name(); Iterator<ArticleChangeType> it = enumSet.iterator(); StringBuilder sb = new StringBuilder(it.next().name()); while(it.hasNext()) { sb.append(STRING_DELIMITER).append(it.next().name()); } return sb.toString(); }
Example 7
Source Project: codebuff File: ImmutableEnumSet.java License: BSD 2-Clause "Simplified" License | 5 votes |
@SuppressWarnings("rawtypes") // necessary to compile against Java 8 static ImmutableSet asImmutable(EnumSet set) { switch (set.size()) { case 0: return ImmutableSet.of(); case 1: return ImmutableSet.of(Iterables.getOnlyElement(set)); default: return new ImmutableEnumSet(set); } }
Example 8
Source Project: wildfly-core File: HostXml_5.java License: GNU Lesser General Public License v2.1 | 5 votes |
private void parseDiscoveryOptionProperty(XMLExtendedStreamReader reader, ModelNode discoveryOptionProperties) throws XMLStreamException { String propertyName = null; String propertyValue = null; EnumSet<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.VALUE); 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: { propertyName = value; break; } case VALUE: { propertyValue = value; break; } default: throw unexpectedAttribute(reader, i); } } if (required.size() > 0) { throw missingRequired(reader, required); } discoveryOptionProperties.add(propertyName, propertyValue); requireNoContent(reader); }
Example 9
Source Project: lams File: EnumToStringConverter.java License: GNU General Public License v2.0 | 5 votes |
private static <T extends Enum<T>> Map<String, T> extractStringMap(Class<T> type) { checkType(type); EnumSet<T> values = EnumSet.allOf(type); Map<String, T> strings = new HashMap<String, T>(values.size()); for (T value : values) { if (strings.put(value.toString(), value) != null) { throw new InitializationException("Enum type " + type.getName() + " does not have unique string representations for its values"); } } return strings; }
Example 10
Source Project: wildfly-core File: HostXml_8.java License: GNU Lesser General Public License v2.1 | 5 votes |
protected void parseDiscoveryOptionProperty(XMLExtendedStreamReader reader, ModelNode discoveryOptionProperties) throws XMLStreamException { String propertyName = null; String propertyValue = null; EnumSet<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.VALUE); 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: { propertyName = value; break; } case VALUE: { propertyValue = value; break; } default: throw unexpectedAttribute(reader, i); } } if (required.size() > 0) { throw missingRequired(reader, required); } discoveryOptionProperties.add(propertyName, propertyValue); requireNoContent(reader); }
Example 11
Source Project: codebuff File: ImmutableEnumSet.java License: BSD 2-Clause "Simplified" License | 5 votes |
@SuppressWarnings("rawtypes") // necessary to compile against Java 8 static ImmutableSet asImmutable(EnumSet set) { switch (set.size()) { case 0: return ImmutableSet.of(); case 1: return ImmutableSet.of(Iterables.getOnlyElement(set)); default: return new ImmutableEnumSet(set); } }
Example 12
Source Project: wildfly-core File: HostXml_10.java License: GNU Lesser General Public License v2.1 | 5 votes |
protected void parseDiscoveryOptionProperty(XMLExtendedStreamReader reader, ModelNode discoveryOptionProperties) throws XMLStreamException { String propertyName = null; String propertyValue = null; EnumSet<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.VALUE); 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: { propertyName = value; break; } case VALUE: { propertyValue = value; break; } default: throw unexpectedAttribute(reader, i); } } if (required.size() > 0) { throw missingRequired(reader, required); } discoveryOptionProperties.add(propertyName, propertyValue); requireNoContent(reader); }
Example 13
Source Project: sync-android File: CreateWithHistoryTest.java License: Apache License 2.0 | 5 votes |
/** * Converts a TestDoc enum set into a collection of revisions * * @param testDocs set of TestDoc revisions in ascending order * @return */ private List<DocumentRevision> toRevisionCollection(EnumSet<TestDoc> testDocs) { List<DocumentRevision> revisions = new ArrayList<DocumentRevision>(testDocs.size()); for (TestDoc testDoc : testDocs) { revisions.add(testDoc.revision); } return revisions; }
Example 14
Source Project: wildfly-core File: VaultXml.java License: GNU Lesser General Public License v2.1 | 5 votes |
private void parseModuleOption(XMLExtendedStreamReader reader, ModelNode moduleOptions) throws XMLStreamException { String name = null; String val = null; EnumSet<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.VALUE); 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 VALUE: { val = value; break; } default: throw unexpectedAttribute(reader, i); } } if (required.size() > 0) { throw missingRequired(reader, required); } moduleOptions.add(name, val); requireNoContent(reader); }
Example 15
Source Project: wildfly-core File: HostXml_7.java License: GNU Lesser General Public License v2.1 | 5 votes |
protected void parseDiscoveryOptionProperty(XMLExtendedStreamReader reader, ModelNode discoveryOptionProperties) throws XMLStreamException { String propertyName = null; String propertyValue = null; EnumSet<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.VALUE); 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: { propertyName = value; break; } case VALUE: { propertyValue = value; break; } default: throw unexpectedAttribute(reader, i); } } if (required.size() > 0) { throw missingRequired(reader, required); } discoveryOptionProperties.add(propertyName, propertyValue); requireNoContent(reader); }
Example 16
Source Project: wildfly-core File: HostXml_12.java License: GNU Lesser General Public License v2.1 | 5 votes |
protected void parseDiscoveryOptionProperty(XMLExtendedStreamReader reader, ModelNode discoveryOptionProperties) throws XMLStreamException { String propertyName = null; String propertyValue = null; EnumSet<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.VALUE); 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: { propertyName = value; break; } case VALUE: { propertyValue = value; break; } default: throw unexpectedAttribute(reader, i); } } if (required.size() > 0) { throw missingRequired(reader, required); } discoveryOptionProperties.add(propertyName, propertyValue); requireNoContent(reader); }
Example 17
Source Project: activemq-artemis File: AddressControlImpl.java License: Apache License 2.0 | 5 votes |
@Override public String[] getRoutingTypes() { if (AuditLogger.isEnabled()) { AuditLogger.getRoutingTypes(this.addressInfo); } EnumSet<RoutingType> routingTypes = addressInfo.getRoutingTypes(); String[] result = new String[routingTypes.size()]; int i = 0; for (RoutingType routingType : routingTypes) { result[i++] = routingType.toString(); } return result; }
Example 18
Source Project: batfish File: HeaderQuestion.java License: Apache License 2.0 | 5 votes |
@JsonProperty(PROP_BGP_RANKING) public void setBgpRanking(List<BgpDecisionVariable> r) { EnumSet<BgpDecisionVariable> rset = EnumSet.noneOf(BgpDecisionVariable.class); rset.addAll(r); if (rset.size() != r.size()) { throw new BatfishException("Duplicate BGP decision variable in question"); } _bgpRanking = r; }
Example 19
Source Project: aeron File: DriverLoggingAgentTest.java License: Apache License 2.0 | 5 votes |
private void before(final String enabledEvents, final EnumSet<DriverEventCode> expectedEvents) { System.setProperty(EventLogAgent.READER_CLASSNAME_PROP_NAME, StubEventLogReaderAgent.class.getName()); System.setProperty(EventConfiguration.ENABLED_EVENT_CODES_PROP_NAME, enabledEvents); AgentTests.beforeAgent(); latch = new CountDownLatch(expectedEvents.size()); WAIT_LIST.addAll(expectedEvents.stream().map(DriverEventCode::id).collect(toSet())); testDir = Paths.get(IoUtil.tmpDirName(), "driver-test").toFile(); if (testDir.exists()) { IoUtil.delete(testDir, false); } }
Example 20
Source Project: big-c File: EnumSetWritable.java License: Apache License 2.0 | 5 votes |
/** * reset the EnumSetWritable with specified * <tt>value</value> and <tt>elementType</tt>. If the <tt>value</tt> argument * is null or its size is zero, the <tt>elementType</tt> argument must not be * null. If the argument <tt>value</tt>'s size is bigger than zero, the * argument <tt>elementType</tt> is not be used. * * @param value * @param elementType */ public void set(EnumSet<E> value, Class<E> elementType) { if ((value == null || value.size() == 0) && (this.elementType == null && elementType == null)) { throw new IllegalArgumentException( "The EnumSet argument is null, or is an empty set but with no elementType provided."); } this.value = value; if (value != null && value.size() > 0) { Iterator<E> iterator = value.iterator(); this.elementType = iterator.next().getDeclaringClass(); } else if (elementType != null) { this.elementType = elementType; } }