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:org.apache.hadoop.hdfs.DFSOutputStream.java

@Override
public void hsync() throws IOException {
    TraceScope scope = dfsClient.newPathTraceScope("hsync", src);
    try {/* w ww . j  a  v a  2s.c om*/
        flushOrSync(true, EnumSet.noneOf(SyncFlag.class));
    } finally {
        scope.close();
    }
}

From source file:org.photovault.imginfo.PhotoInfo.java

/**
 Creates thumbnail & preview instances in given volume. The preview instance 
 is created only if one does not exist currently or it is out of date.
 TODO: Thiuis chould be refactored into a more generic and configurable 
 framework for creating needed instances.
 *//*from   w w  w  . j  a  va  2  s.  c om*/
protected void createThumbnail(VolumeBase volume) {
    boolean recreatePreview = true;
    EnumSet<ImageOperations> previewOps = EnumSet.of(ImageOperations.COLOR_MAP, ImageOperations.RAW_CONVERSION);
    ImageDescriptorBase previewImage = this.getPreferredImage(EnumSet.noneOf(ImageOperations.class), previewOps,
            1024, 1024, 2048, 2048);
    if (previewImage != null) {
        recreatePreview = false;
    }
    createThumbnail(volume, recreatePreview);
}

From source file:com.netflix.genie.web.controllers.CommandRestController.java

/**
 * Get all the clusters this command is associated with.
 *
 * @param id       The id of the command to get the clusters for. Not
 *                 NULL/empty/blank.//w  w  w.ja  va 2  s  .c o  m
 * @param statuses The statuses of the clusters to get
 * @return The list of clusters.
 * @throws GenieException For any error
 */
@GetMapping(value = "/{id}/clusters", produces = MediaTypes.HAL_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public Set<ClusterResource> getClustersForCommand(@PathVariable("id") final String id,
        @RequestParam(value = "status", required = false) final Set<String> statuses) throws GenieException {
    log.debug("Called with id {} and statuses {}", id, statuses);

    Set<ClusterStatus> enumStatuses = null;
    if (statuses != null) {
        enumStatuses = EnumSet.noneOf(ClusterStatus.class);
        for (final String status : statuses) {
            enumStatuses.add(ClusterStatus.parse(status));
        }
    }

    return this.commandService.getClustersForCommand(id, enumStatuses).stream()
            .map(this.clusterResourceAssembler::toResource).collect(Collectors.toSet());
}

From source file:com.moviejukebox.scanner.artwork.ArtworkScanner.java

/**
 * Return a list of the required artwork types
 *
 * @return/* w  ww .  j  a v a2s  .c om*/
 */
public static Set<ArtworkType> getRequiredArtworkTypes() {
    Set<ArtworkType> artworkTypeRequired = EnumSet.noneOf(ArtworkType.class);
    for (ArtworkType artworkType : EnumSet.allOf(ArtworkType.class)) {
        if (isRequired(artworkType)) {
            artworkTypeRequired.add(artworkType);
        }
    }
    return artworkTypeRequired;
}

From source file:ru.codeinside.adm.AdminServiceImpl.java

@Override
public UserItem getUserItem(String login) {
    final Employee employee = em.find(Employee.class, login);
    final UserItem userItem = new UserItem();
    userItem.setFio(employee.getFio());// ww  w  .  j  a  v a 2 s  . c om
    userItem.setRoles(
            employee.getRoles().isEmpty() ? EnumSet.noneOf(Role.class) : EnumSet.copyOf(employee.getRoles()));
    final Set<String> current = new TreeSet<String>();
    for (Group group : employee.getGroups()) {
        current.add(group.getName());
    }
    userItem.setGroups(current);
    final Set<String> employeeGroups = new TreeSet<String>();
    for (Group group : employee.getEmployeeGroups()) {
        employeeGroups.add(group.getName());
    }
    userItem.setEmployeeGroups(employeeGroups);
    final Set<String> organizationGroups = new TreeSet<String>();
    for (Group group : employee.getOrganizationGroups()) {
        organizationGroups.add(group.getName());
    }
    userItem.setOrganizationGroups(organizationGroups);
    userItem.setAllSocialGroups(selectGroupNamesBySocial(true));
    userItem.setLocked(employee.isLocked());
    if (employee.getCertificate() != null) {
        userItem.setX509(employee.getCertificate().getX509());
    }
    return userItem;
}

From source file:com.pinterest.hdfsbackup.distcp.DistCp.java

@Deprecated
public static void copy(Configuration conf, String srcPath, String destPath, Path logPath, boolean srcAsList,
        boolean ignoreReadFailures) throws IOException {
    final Path src = new Path(srcPath);
    List<Path> tmp = new ArrayList<Path>();
    if (srcAsList) {
        tmp.addAll(fetchFileList(conf, src));
    } else {//from www  .ja  v a2 s . c o  m
        tmp.add(src);
    }
    EnumSet<Options> flags = ignoreReadFailures ? EnumSet.of(Options.IGNORE_READ_FAILURES)
            : EnumSet.noneOf(Options.class);

    final Path dst = new Path(destPath);
    copy(conf, new Arguments(tmp, dst, logPath, flags, null, Long.MAX_VALUE, Long.MAX_VALUE, null));
}

From source file:ome.services.graphs.GraphPolicyRule.java

/**
 * Parse a term match from a textual representation.
 * @param graphPathBean the graph path bean
 * @param term some text//from  w ww . ja  v a2  s  .  c o m
 * @return the term match parsed from the text
 * @throws GraphException if the parse failed
 */
private static TermMatch parseTermMatch(GraphPathBean graphPathBean, String term) throws GraphException {
    /* determine if new or existing term */

    final Matcher existingTermMatcher = EXISTING_TERM_PATTERN.matcher(term);

    if (existingTermMatcher.matches()) {
        return new ExistingTermMatch(existingTermMatcher.group(1));
    }

    final Matcher newTermMatcher = NEW_TERM_PATTERN.matcher(term);
    if (!newTermMatcher.matches()) {
        throw new GraphException("failed to parse match term " + term);
    }

    /* note parse results */

    final String termName;
    final Class<? extends IObject> requiredClass;
    final Class<? extends IObject> prohibitedClass;
    final Collection<GraphPolicy.Action> permittedActions;
    final Collection<GraphPolicy.Orphan> permittedOrphans;
    final Collection<GraphPolicy.Ability> requiredAbilities;
    final Collection<GraphPolicy.Ability> prohibitedAbilities;
    Boolean isCheckPermissions = null;
    final Map<String, String> predicateArguments;

    /* parse term name, if any */

    final String termNameGroup = newTermMatcher.group(1);
    if (termNameGroup == null) {
        termName = null;
    } else {
        termName = termNameGroup.substring(0, termNameGroup.length() - 1);
    }

    /* parse class name, if any */

    final String classNameGroup = newTermMatcher.group(2);
    if (classNameGroup == null) {
        requiredClass = null;
        prohibitedClass = null;
    } else if (classNameGroup.charAt(0) == '!') {
        requiredClass = null;
        prohibitedClass = graphPathBean.getClassForSimpleName(classNameGroup.substring(1));
        if (prohibitedClass == null) {
            throw new GraphException("unknown class named in " + term);
        }
    } else {
        requiredClass = graphPathBean.getClassForSimpleName(classNameGroup);
        prohibitedClass = null;
        if (requiredClass == null) {
            throw new GraphException("unknown class named in " + term);
        }
    }

    /* parse actions, if any */

    final String actionGroup = newTermMatcher.group(3);
    if (actionGroup == null) {
        permittedActions = null;
    } else {
        final EnumSet<GraphPolicy.Action> actions = EnumSet.noneOf(GraphPolicy.Action.class);
        boolean invert = false;
        for (final char action : actionGroup.toCharArray()) {
            if (action == 'E') {
                actions.add(GraphPolicy.Action.EXCLUDE);
            } else if (action == 'D') {
                actions.add(GraphPolicy.Action.DELETE);
            } else if (action == 'I') {
                actions.add(GraphPolicy.Action.INCLUDE);
            } else if (action == 'O') {
                actions.add(GraphPolicy.Action.OUTSIDE);
            } else if (action == '!') {
                invert = true;
            }
        }
        permittedActions = invert ? EnumSet.complementOf(actions) : actions;
    }

    /* parse orphans, if any */

    final String orphanGroup = newTermMatcher.group(4);
    if (orphanGroup == null) {
        permittedOrphans = null;
    } else {
        final EnumSet<GraphPolicy.Orphan> orphans = EnumSet.noneOf(GraphPolicy.Orphan.class);
        boolean invert = false;
        for (final char orphan : orphanGroup.toCharArray()) {
            if (orphan == 'i') {
                orphans.add(GraphPolicy.Orphan.IRRELEVANT);
            } else if (orphan == 'r') {
                orphans.add(GraphPolicy.Orphan.RELEVANT);
            } else if (orphan == 'o') {
                orphans.add(GraphPolicy.Orphan.IS_LAST);
            } else if (orphan == 'a') {
                orphans.add(GraphPolicy.Orphan.IS_NOT_LAST);
            } else if (orphan == '!') {
                invert = true;
            }
        }
        permittedOrphans = invert ? EnumSet.complementOf(orphans) : orphans;
    }

    /* parse abilities, if any; also permissions checking */

    final String abilityGroup = newTermMatcher.group(5);
    if (abilityGroup == null) {
        requiredAbilities = null;
        prohibitedAbilities = null;
    } else {
        final EnumSet<GraphPolicy.Ability> abilities = EnumSet.noneOf(GraphPolicy.Ability.class);
        boolean required = true;
        for (final char ability : abilityGroup.toCharArray()) {
            if (ability == 'u') {
                abilities.add(GraphPolicy.Ability.UPDATE);
            } else if (ability == 'd') {
                abilities.add(GraphPolicy.Ability.DELETE);
            } else if (ability == 'o') {
                abilities.add(GraphPolicy.Ability.OWN);
            } else if (ability == 'n') {
                isCheckPermissions = !required;
            } else if (ability == '!') {
                required = false;
            }
        }
        if (required) {
            requiredAbilities = abilities;
            prohibitedAbilities = null;
        } else {
            requiredAbilities = null;
            prohibitedAbilities = abilities;
        }
    }

    /* parse named predicate arguments, if any */

    if (newTermMatcher.group(6) == null) {
        predicateArguments = null;
    } else {
        predicateArguments = new HashMap<String, String>();
        String remainingPredicates = newTermMatcher.group(6);
        while (remainingPredicates != null) {
            final Matcher predicateMatcher = PREDICATE_PATTERN.matcher(remainingPredicates);
            if (!predicateMatcher.matches()) {
                throw new GraphException("failed to parse predicates suffixing match term " + term);
            }
            predicateArguments.put(predicateMatcher.group(1), predicateMatcher.group(2));
            remainingPredicates = predicateMatcher.group(3);
        }
    }

    /* construct new term match */

    return new NewTermMatch(termName, requiredClass, prohibitedClass, permittedActions, permittedOrphans,
            requiredAbilities, prohibitedAbilities, isCheckPermissions, predicateArguments);

}

From source file:org.apache.hadoop.yarn.client.api.impl.YarnClientImpl.java

@Override
public List<NodeReport> getNodeReports(NodeState... states) throws YarnException, IOException {
    EnumSet<NodeState> statesSet = (states.length == 0) ? EnumSet.allOf(NodeState.class)
            : EnumSet.noneOf(NodeState.class);
    for (NodeState state : states) {
        statesSet.add(state);//from  ww w .j  av  a 2 s.  c  o  m
    }
    GetClusterNodesRequest request = GetClusterNodesRequest.newInstance(statesSet);
    GetClusterNodesResponse response = rmClient.getClusterNodes(request);
    return response.getNodeReports();
}

From source file:cz.dasnet.dasik.Dasik.java

@Override
public void onJoin(String channel, String sender, String login, String hostname) {
    // handle auths
    if (sender.equals(getNick())) {
        if (!activeChannels.containsKey(channel)) {
            Channel c = new Channel(channel);
            activeChannels.put(channel, c);
        }/*from  w ww .j  av  a  2  s . c om*/
    } else {
        sendWhoOnUser(sender);
    }

    Channel c = activeChannels.get(channel);
    c.addUser(new ChannelUser(sender, EnumSet.noneOf(ChannelAccess.class)));

    for (ChannelEventListener cl : channelListeners.values()) {
        cl.onJoin(channel, sender, login, hostname, this);
    }
}

From source file:com.itude.mobile.mobbl.core.controller.MBViewManager.java

/***
 * /*from w w w . j  av  a 2s .  c o m*/
 * @param showFirst
 * 
 * @deprecated please use {@link #invalidateActionBar(EnumSet)}
 */
@Deprecated
public void invalidateActionBar(boolean showFirst) {
    EnumSet<MBActionBarInvalidationOption> options = EnumSet.noneOf(MBActionBarInvalidationOption.class);
    if (showFirst) {
        options.add(MBActionBarInvalidationOption.SHOW_FIRST);
    }

    invalidateActionBar(options);
}