Example usage for java.util EnumSet noneOf

List of usage examples for java.util EnumSet noneOf

Introduction

In this page you can find the example usage for java.util EnumSet noneOf.

Prototype

public static <E extends Enum<E>> EnumSet<E> noneOf(Class<E> elementType) 

Source Link

Document

Creates an empty enum set with the specified element type.

Usage

From source file:de.otto.jsonhome.generator.SpringHintsGenerator.java

/**
 * Analyses the method with a RequestMapping and returns a list of allowed http methods (GET, PUT, etc.).
 * <p/>/*from w w w.  j  a v  a 2s. co m*/
 * If the RequestMapping does not specify the allowed HTTP methods, "GET" is returned in a singleton list.
 *
 * @return list of allowed HTTP methods.
 * @throws NullPointerException if method is not annotated with @RequestMapping.
 */
@Override
protected Set<Allow> allowedHttpMethodsOf(final Method method) {
    final RequestMapping methodRequestMapping = findAnnotation(method, RequestMapping.class);
    final Set<Allow> allows = EnumSet.noneOf(Allow.class);
    for (Object o : methodRequestMapping.method()) {
        allows.add(Allow.valueOf(o.toString()));
    }
    if (allows.isEmpty()) {
        return of(GET);
    } else {
        return allows;
    }
}

From source file:com.github.fge.ftpfs.io.commonsnetimpl.CommonsNetFtpFileView.java

@Override
public Collection<AccessMode> getAccess() {
    final EnumSet<AccessMode> ret = EnumSet.noneOf(AccessMode.class);
    next: for (final int type : ACCESS_TYPES)
        for (final Map.Entry<Integer, AccessMode> entry : ACCESS_MAP.entrySet())
            if (ftpFile.hasPermission(type, entry.getKey())) {
                ret.add(entry.getValue());
                continue next;
            }/*from  w w  w.j  a  va2 s  . c om*/

    return EnumSet.copyOf(ret);
}

From source file:org.nuxeo.ecm.blob.azure.AzureGarbageCollector.java

@Override
public Set<String> getUnmarkedBlobs() {
    Set<String> unmarked = new HashSet<>();
    ResultContinuation continuationToken = null;
    ResultSegment<ListBlobItem> lbs;
    do {//from www. j  ava 2s  .com
        try {
            lbs = binaryManager.container.listBlobsSegmented(null, false,
                    EnumSet.noneOf(BlobListingDetails.class), null, continuationToken, null, null);
        } catch (StorageException e) {
            throw new RuntimeException(e);
        }

        for (ListBlobItem item : lbs.getResults()) {

            if (!(item instanceof CloudBlockBlob)) {
                // ignore wrong blob type
                continue;
            }

            CloudBlockBlob blob = (CloudBlockBlob) item;

            String digest;
            try {
                digest = blob.getName();
            } catch (URISyntaxException e) {
                // Should never happends
                // @see com.microsoft.azure.storage.blob.CloudBlob.getName()
                continue;
            }

            if (!isMD5(digest)) {
                // ignore files that cannot be MD5 digests for
                // safety
                continue;
            }

            long length = blob.getProperties().getLength();
            if (marked.contains(digest)) {
                status.numBinaries++;
                status.sizeBinaries += length;
                marked.remove(digest); // optimize memory
            } else {
                status.numBinariesGC++;
                status.sizeBinariesGC += length;
                // record file to delete
                unmarked.add(digest);
            }
        }

        continuationToken = lbs.getContinuationToken();
    } while (lbs.getHasMoreResults());
    marked = null; // help GC

    return unmarked;
}

From source file:io.swagger.inflector.config.DirectionDeserializerTest.java

@DataProvider(name = BOOLEAN)
private Object[][] listFilesWithBoolean() {
    return new Object[][] { { "validation-as-false.yaml", EnumSet.noneOf(Configuration.Direction.class) },
            { "validation-as-true.yaml", EnumSet.allOf(Configuration.Direction.class) } };
}

From source file:org.jscep.transport.response.GetCaCapsResponseHandler.java

/**
 * {@inheritDoc}//from  w w  w .jav a 2 s. c o m
 * 
 * @throws InvalidContentTypeException
 */
@Override
public Capabilities getResponse(final byte[] content, final String mimeType) throws ContentException {
    if (mimeType == null || !mimeType.startsWith(TEXT_PLAIN)) {
        LOGGER.warn("Content-Type mismatch: was '{}', expected 'text/plain'", mimeType);
    }

    final EnumSet<Capability> caps = EnumSet.noneOf(Capability.class);

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("CA capabilities:");
    }
    BufferedReader reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(content),
            Charset.forName(Charsets.US_ASCII.name())));
    Set<String> caCaps = new HashSet<String>();
    String capability;
    try {
        while ((capability = reader.readLine()) != null) {
            caCaps.add(capability);
        }
    } catch (IOException e) {
        throw new InvalidContentTypeException(e);
    } finally {
        try {
            reader.close();
        } catch (IOException e) {
            LOGGER.error("Error closing reader", e);
        }
    }

    for (Capability enumValue : Capability.values()) {
        if (caCaps.contains(enumValue.toString())) {
            LOGGER.debug("[\u2713] {}", enumValue.getDescription());
            caps.add(enumValue);
        } else {
            LOGGER.debug("[\u2717] {}", enumValue.getDescription());
        }
    }

    return new Capabilities(caps.toArray(new Capability[caps.size()]));
}

From source file:org.apache.james.mailbox.store.ImmutableMailboxMessageTest.java

@Before
public void setup() {
    MailboxManager mailboxManager = mock(MailboxManager.class);
    when(mailboxManager.getSupportedMessageCapabilities())
            .thenReturn(EnumSet.noneOf(MessageCapabilities.class));

    messageFactory = new ImmutableMailboxMessage.Factory();
}

From source file:org.glite.authz.pap.authz.PAPPermission.java

/**
 * Initializes the permissions as empty.
 */
protected PAPPermission() {

    permissions = EnumSet.noneOf(PermissionFlags.class);

}

From source file:eu.itesla_project.modules.histo.tools.HistoDbListAttributesTool.java

@Override
public void run(CommandLine line) throws Exception {
    OfflineConfig config = OfflineConfig.load();
    Set<HistoDbAttr> types = null;
    if (line.hasOption("attribute-types")) {
        types = EnumSet.noneOf(HistoDbAttr.class);
        for (String str : line.getOptionValue("attribute-types").split(",")) {
            types.add(HistoDbAttr.valueOf(str));
        }/*from   w w w  . java  2  s  . co m*/
    }
    try (HistoDbClient histoDbClient = config.getHistoDbClientFactoryClass().newInstance().create()) {
        for (HistoDbAttributeId attributeId : histoDbClient.listAttributes()) {
            if (types == null || (attributeId instanceof HistoDbNetworkAttributeId
                    && types.contains(((HistoDbNetworkAttributeId) attributeId).getAttributeType()))) {
                System.out.println(attributeId);
            }
        }
    }
}

From source file:com.silverpeas.accesscontrol.AbstractAccessController.java

/**
 * Gets the user roles about the aimed object and by taking in account the context of the access.
 * After a first call, user role are cached (REQUEST live time) in order to increase the
 * performances in case of several call on the same user and object.
 * @param context/*from   ww w .j ava  2  s.  c om*/
 * @param userId
 * @param object
 * @return
 */
@SuppressWarnings("unchecked")
public Set<SilverpeasRole> getUserRoles(AccessControlContext context, String userId, T object) {
    String cacheKey = buildUserRoleCacheKey(userId, object);
    Set<SilverpeasRole> userRoles = CacheServiceFactory.getRequestCacheService().get(cacheKey, Set.class);
    if (userRoles == null) {
        userRoles = EnumSet.noneOf(SilverpeasRole.class);
        fillUserRoles(userRoles, context, userId, object);
        CacheServiceFactory.getRequestCacheService().put(cacheKey, userRoles);
    }
    return userRoles;
}

From source file:com.navercorp.pinpoint.web.service.AgentEventServiceImpl.java

@Override
public List<AgentEvent> getAgentEvents(String agentId, Range range, int... excludeEventTypeCodes) {
    if (agentId == null) {
        throw new NullPointerException("agentId must not be null");
    }/*from   w w w . j a  v  a2  s.  c  om*/
    Set<AgentEventType> excludeEventTypes = EnumSet.noneOf(AgentEventType.class);
    for (int excludeEventTypeCode : excludeEventTypeCodes) {
        AgentEventType excludeEventType = AgentEventType.getTypeByCode(excludeEventTypeCode);
        if (excludeEventType != null) {
            excludeEventTypes.add(excludeEventType);
        }
    }
    List<AgentEventBo> agentEventBos = this.agentEventDao.getAgentEvents(agentId, range, excludeEventTypes);
    List<AgentEvent> agentEvents = createAgentEvents(agentEventBos);
    agentEvents.sort(AgentEvent.EVENT_TIMESTAMP_ASC_COMPARATOR);
    return agentEvents;
}