Java Code Examples for java.util.EnumSet#size()
The following examples show how to use
java.util.EnumSet#size() .
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: FlagsHelper.java From linstor-server with 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 File: ImmutableEnumSet.java From codebuff with 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 3
Source File: EnumSetWritable.java From big-c with 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; } }
Example 4
Source File: DriverLoggingAgentTest.java From aeron with 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 5
Source File: HeaderQuestion.java From batfish with 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 6
Source File: AddressControlImpl.java From activemq-artemis with 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 7
Source File: HostXml_12.java From wildfly-core with 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 8
Source File: HostXml_7.java From wildfly-core with 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 9
Source File: VaultXml.java From wildfly-core with 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 10
Source File: CreateWithHistoryTest.java From sync-android with 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 11
Source File: HostXml_10.java From wildfly-core with 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 12
Source File: IrrigationScheduleCommandEditorFragment.java From arcusandroid with 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 13
Source File: HostXml_8.java From wildfly-core with 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 14
Source File: EnumToStringConverter.java From lams with 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 15
Source File: HostXml_5.java From wildfly-core with 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 16
Source File: ImmutableEnumSet.java From codebuff with 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 17
Source File: QueueItem.java From android-app with 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 18
Source File: HostXml_14.java From wildfly-core with 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 19
Source File: FileRequest.java From azure-storage-android with 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 20
Source File: PXParserBase.java From pixate-freestyle-android with 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); } }