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:com.asakusafw.testdriver.compiler.util.DeploymentUtil.java

/**
 * Deletes the target file/directory./*  ww  w .ja  v  a 2s .com*/
 * @param target the target file/directory
 * @param options the operation options
 * @return {@code true} if the target file/directory was successfully deleted (or does not exist initially),
 *     otherwise {@code false}
 * @throws IOException if I/O error was occurred
 */
public static boolean delete(File target, DeleteOption... options) throws IOException {
    if (target.exists() == false) {
        return true;
    }
    Set<DeleteOption> opts = EnumSet.noneOf(DeleteOption.class);
    Collections.addAll(opts, options);
    if (opts.contains(DeleteOption.QUIET)) {
        return FileUtils.deleteQuietly(target);
    } else {
        FileUtils.forceDelete(target);
        return true;
    }
}

From source file:org.exoplatform.acceptance.security.CrowdGrantedAuthoritiesMapper.java

/**
 * {@inheritDoc}/*ww  w  .j a  v a2s.  c  o m*/
 * Mapping interface which can be injected into the authentication layer to convert the
 * authorities loaded from storage into those which will be used in the {@code Authentication} object.
 */
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public Collection<GrantedAuthority> mapAuthorities(Collection<? extends GrantedAuthority> authorities) {
    //empty EnumSet
    Set roles = EnumSet.noneOf(AppAuthority.class);
    LOGGER.debug("Authorities to check : {}", authorities);
    for (GrantedAuthority authority : authorities) {
        if (userRole.equals(authority.getAuthority())) {
            roles.add(AppAuthority.ROLE_USER);
        } else if (adminRole.equals(authority.getAuthority())) {
            roles.add(AppAuthority.ROLE_ADMIN);
        }
    }
    LOGGER.debug("Computed application roles : {}", roles);
    return roles;
}

From source file:org.richfaces.tests.metamer.ftest.extension.attributes.coverage.result.SimpleCoverageResult.java

private EnumSet getDefaultIgnoredValues(Class<? extends Enum> enumClass) {
    EnumSet result = EnumSet.noneOf(enumClass);
    for (String ignoredAtt : IGNORED_ATTS) {
        try {//from  w ww. j  a v a 2 s . c  o  m
            result.add(Enum.valueOf(enumClass, ignoredAtt));
        } catch (IllegalArgumentException e) {
        }
    }
    return result;
}

From source file:com.mellanox.r4h.TestHFlush.java

/**
 * The test uses//from   ww w .  j  a  v  a 2s. c  om
 * {@link #doTheJob(Configuration, String, long, short, boolean, EnumSet)} 
 * to write a file with a standard block size
 */
@Test
public void hFlush_01() throws IOException {
    doTheJob(new HdfsConfiguration(), fName, MiniDFSClusterBridge.getAppendTestUtil_BLOCK_SIZE(), (short) 2,
            false, EnumSet.noneOf(SyncFlag.class));
}

From source file:pl.psnc.synat.wrdz.zmkd.config.ZdtConfiguration.java

/**
 * Creates the configuration object form the {@value #CONFIG_FILE} file.
 *//*from ww w  . jav  a2 s .  c  o  m*/
@PostConstruct
@SuppressWarnings("unchecked")
protected void init() {
    try {
        config = new XMLConfiguration(CONFIG_FILE);

        formatsByName = new HashMap<String, Format>();
        formatsByPlugin = new HashMap<Plugin, Set<Format>>();

        List<HierarchicalConfiguration> formats = config.configurationsAt("formats.format");
        for (HierarchicalConfiguration format : formats) {
            String name = format.getString("name");
            FormatType type = FormatType.valueOf(format.getString("type").toUpperCase());
            List<String> iris = format.getList("iri");

            List<String> plugins = format.getList("supported-by.plugin");
            EnumSet<Plugin> supportedBy = EnumSet.noneOf(Plugin.class);
            for (String plugin : plugins) {
                supportedBy.add(Plugin.valueOf(plugin));
            }

            formatsByName.put(name, new Format(name, type, iris, supportedBy));
        }

        for (Format format : formatsByName.values()) {
            for (Plugin plugin : format.getSupportedBy()) {
                if (!formatsByPlugin.containsKey(plugin)) {
                    formatsByPlugin.put(plugin, new HashSet<Format>());
                }
                formatsByPlugin.get(plugin).add(format);
            }
        }

        for (Entry<Plugin, Set<Format>> entry : formatsByPlugin.entrySet()) {
            entry.setValue(Collections.unmodifiableSet(entry.getValue()));
        }

    } catch (IllegalArgumentException e) {
        logger.error("Loading the configuration failed.", e);
        throw new WrdzConfigurationError(e);
    } catch (ConfigurationException e) {
        logger.error("Loading the configuration failed.", e);
        throw new WrdzConfigurationError(e);
    }
}

From source file:com.microsoft.windowsazure.mobileservices.http.MobileServiceHttpClient.java

/**
 * Makes a request over HTTP//from   ww  w  .j ava2 s . com
 *
 * @param path           The path of the request URI
 * @param content        The byte array to send as the request body
 * @param httpMethod     The HTTP Method used to invoke the API
 * @param requestHeaders The extra headers to send in the request
 * @param parameters     The query string parameters sent in the request
 */
public ListenableFuture<ServiceFilterResponse> request(String path, byte[] content, String httpMethod,
        List<Pair<String, String>> requestHeaders, List<Pair<String, String>> parameters) {
    return this.request(path, content, httpMethod, requestHeaders, parameters,
            EnumSet.noneOf(MobileServiceFeatures.class));
}

From source file:com.tbodt.jswerve.servlet.JSwerveServlet.java

private void serviceOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException {
    EnumSet methods = EnumSet.noneOf(HttpMethod.class);
    RoutingTable routingTable = website.getRoutingTable();
    String path = extractUri(req).getPath();
    for (Route route : routingTable.getRoutes())
        if (route.matchesPath(path))
            methods.addAll(route.getMethods());

    if (!methods.isEmpty()) {
        StringBuilder allowResponse = new StringBuilder();
        Iterator i = methods.iterator();
        while (i.hasNext()) {
            allowResponse.append(i.next());
            if (i.hasNext())
                allowResponse.append(",");
        }//  ww w . j a  v a  2s.  c  o  m
        resp.setHeader("Allow", allowResponse.toString());
    }
}

From source file:com.quinsoft.zeidon.standardoe.WriteOisToJsonStream.java

@Override
public void writeToStream(SerializeOi options, Writer writer) {
    this.viewList = options.getViewList();
    this.options = options;
    if (options.getFlags() == null)
        flags = EnumSet.noneOf(WriteOiFlags.class);
    else/*from w  w w  .  j  a  va  2  s.  c om*/
        flags = options.getFlags();
    if (!flags.contains(WriteOiFlags.INCREMENTAL))
        throw new ZeidonException("This JSON stream writer intended for writing incremental.");

    // Create a set of all the OIs and turn off the record owner flag.  The record owner
    // flag will be used to determine if a linked EI has been written to the stream.
    for (View view : viewList) {
        ObjectInstance oi = ((InternalView) view).getViewImpl().getObjectInstance();
        ois.add(oi);
        for (EntityInstanceImpl ei = oi.getRootEntityInstance(); ei != null; ei = ei.getNextTwin())
            ei.setRecordOwner(false);
    }

    JsonFactory jsonF = new JsonFactory();
    try {
        jg = jsonF.createGenerator(writer);
        if (!options.isCompressed())
            jg.useDefaultPrettyPrinter(); // enable indentation just to make debug/testing easier

        jg.writeStartObject();

        // Write meta info for entire JSON object.
        jg.writeObjectFieldStart(".meta");
        jg.writeStringField("version", VERSION);
        if (options.isWriteDate())
            jg.writeStringField("datetime", new LocalDateTime().toString());
        jg.writeEndObject();

        jg.writeArrayFieldStart("OIs");

        for (View view : viewList) {
            currentView = view;
            jg.writeStartObject();
            writeOi(view);
            jg.writeEndObject();
        }
        jg.writeEndArray();
        jg.writeEndObject();
        jg.close();
    } catch (Exception e) {
        throw ZeidonException.wrapException(e);
    }
}

From source file:org.trnltk.morphology.phonetics.PhoneticsAnalyzer.java

EnumSet<PhoneticAttribute> calculatePhoneticAttributesOfPlainSequence(final TurkishSequence surface) {
    final EnumSet<PhoneticAttribute> attributes = EnumSet.noneOf(PhoneticAttribute.class);
    final TurkishChar lastVowelChar = surface.getLastVowel();
    final TurkishChar firstChar = surface.charAt(0);
    final TurkicLetter firstLetter = firstChar.getLetter();
    final TurkishChar lastChar = surface.getLastChar();
    final TurkicLetter lastLetter = lastChar.getLetter();

    if (firstLetter.isVowel())
        attributes.add(PhoneticAttribute.FirstLetterVowel);
    else//w  w  w.  j  av  a 2s  .c  o  m
        attributes.add(PhoneticAttribute.FirstLetterConsonant);

    if (lastVowelChar != null) {
        final TurkicLetter lastVowelLetter = lastVowelChar.getLetter();
        if (lastVowelLetter.isRounded())
            attributes.add(PhoneticAttribute.LastVowelRounded);
        else
            attributes.add(PhoneticAttribute.LastVowelUnrounded);

        if (lastVowelLetter.isFrontal())
            attributes.add(PhoneticAttribute.LastVowelFrontal);
        else
            attributes.add(PhoneticAttribute.LastVowelBack);
    } else {
        attributes.add(PhoneticAttribute.HasNoVowel);
    }

    if (lastLetter.isVowel())
        attributes.add(PhoneticAttribute.LastLetterVowel);
    else
        attributes.add(PhoneticAttribute.LastLetterConsonant);

    if (lastLetter.isVoiceless()) {
        attributes.add(PhoneticAttribute.LastLetterVoiceless);
        if (lastLetter.isStopConsonant() && !lastLetter.isVowel())
            attributes.add(PhoneticAttribute.LastLetterVoicelessStop);
    } else {
        attributes.add(PhoneticAttribute.LastLetterNotVoiceless);
    }

    return attributes;
}

From source file:org.bitbucket.mlopatkin.android.liblogcat.file.LogfileDataSource.java

@Override
public EnumSet<Buffer> getAvailableBuffers() {
    return EnumSet.noneOf(Buffer.class);
}