java.util.EnumSet#size ( )源码实例Demo

下面列出了java.util.EnumSet#size ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: linstor-server   文件: FlagsHelper.java
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;
}
 
@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);
    }

}
 
源代码3 项目: pixate-freestyle-android   文件: PXParserBase.java
/**
 * 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);
    }
}
 
源代码4 项目: azure-storage-android   文件: FileRequest.java
/**
 * 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;
}
 
源代码5 项目: wildfly-core   文件: HostXml_14.java
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);
}
 
源代码6 项目: android-app   文件: QueueItem.java
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();
}
 
源代码7 项目: codebuff   文件: ImmutableEnumSet.java
@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);
  }
}
 
源代码8 项目: wildfly-core   文件: HostXml_5.java
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);
}
 
源代码9 项目: lams   文件: EnumToStringConverter.java
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;
}
 
源代码10 项目: wildfly-core   文件: HostXml_8.java
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);
}
 
源代码11 项目: codebuff   文件: ImmutableEnumSet.java
@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);
  }
}
 
源代码12 项目: wildfly-core   文件: HostXml_10.java
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);
}
 
源代码13 项目: sync-android   文件: CreateWithHistoryTest.java
/**
 * 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;
}
 
源代码14 项目: wildfly-core   文件: VaultXml.java
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);
}
 
源代码15 项目: wildfly-core   文件: HostXml_7.java
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);
}
 
源代码16 项目: wildfly-core   文件: HostXml_12.java
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);
}
 
源代码17 项目: activemq-artemis   文件: AddressControlImpl.java
@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;
}
 
源代码18 项目: batfish   文件: HeaderQuestion.java
@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;
}
 
源代码19 项目: aeron   文件: DriverLoggingAgentTest.java
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);
    }
}
 
源代码20 项目: big-c   文件: EnumSetWritable.java
/**
 * 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;
  }
}