Example usage for java.util EnumSet allOf

List of usage examples for java.util EnumSet allOf

Introduction

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

Prototype

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

Source Link

Document

Creates an enum set containing all of the elements in the specified element type.

Usage

From source file:com.synopsys.integration.blackduck.service.model.ComponentVersionStatusCount.java

public ComponentVersionStatusCount(final NameValuePairView nameValuePair) {
    final Set<PolicySummaryStatusType> policyStatusTypes = EnumSet.allOf(PolicySummaryStatusType.class);
    final Set<String> policyStatusTypeValues = policyStatusTypes.stream().map(Object::toString)
            .collect(Collectors.toSet());
    if (policyStatusTypeValues.contains(nameValuePair.getName())) {
        name = PolicySummaryStatusType.valueOf(nameValuePair.getName());
    }// ww w .ja v a 2 s .co  m

    if (nameValuePair.getValue() != null) {
        final String valueString = nameValuePair.getValue().toString();
        if (NumberUtils.isCreatable(valueString)) {
            value = NumberUtils.createNumber(valueString).intValue();
        }
    }
}

From source file:com.synopsys.integration.blackduck.service.model.ComponentVersionPolicyViolationCount.java

public ComponentVersionPolicyViolationCount(final NameValuePairView nameValuePair) {
    final Set<PolicySeverityType> policySeverityTypes = EnumSet.allOf(PolicySeverityType.class);
    final Set<String> policyStatusTypeValues = policySeverityTypes.stream().map(Object::toString)
            .collect(Collectors.toSet());
    if (policyStatusTypeValues.contains(nameValuePair.getName())) {
        name = PolicySeverityType.valueOf(nameValuePair.getName());
    }// ww  w.  j a va  2s.c  om

    if (nameValuePair.getValue() != null) {
        final String valueString = nameValuePair.getValue().toString();
        if (NumberUtils.isCreatable(valueString)) {
            value = NumberUtils.createNumber(valueString).intValue();
        }
    }
}

From source file:com.janrain.oauth2.AuthorizationRequest.java

public AuthorizationRequest(String cookie, Map parameterMap) throws SimpleDBException {
    Map<String, String> data = new LinkedHashMap<String, String>();
    for (Field f : EnumSet.allOf(Field.class)) {
        Object value = parameterMap.get(f.getFieldName().toLowerCase());
        if (value != null && ((String[]) value).length > 0 && StringUtils.isNotEmpty(((String[]) value)[0])) {
            data.put(f.getFieldName(), ((String[]) value)[0]);
        }//from www. ja v a 2 s.c o m
    }
    data.put(Field.COOKIE.getFieldName(), cookie);
    data.put(Field.EXPIRES.getFieldName(), DateTimeUtils.ISO8601.get()
            .format(new Date(System.currentTimeMillis() + AUTH_REQUEST_TIMEOUT_SECONDS * 1000)));
    super.init(cookie, data);
}

From source file:com.janrain.backplane2.server.Grant.java

@Override
public Set<? extends MessageField> getFields() {
    return EnumSet.allOf(GrantField.class);
}

From source file:gov.nih.nci.caarray.plugins.illumina.AbstractCsvDesignHelper.java

/**
 * init headerIndex by looking at the order of the headers row.
 *//*from ww w  .  ja  v a2  s.  c o  m*/
@SuppressWarnings("unchecked")
void initHeaderIndex(List<String> headerValues) {
    EnumSet<? extends Enum> headers = EnumSet.allOf(headerEnumClass);
    headerIndex = new int[headers.size()];
    for (int i = 0; i < headerValues.size(); i++) {
        Enum h = Enum.valueOf(headerEnumClass, headerValues.get(i).toUpperCase(Locale.getDefault()));
        headerIndex[h.ordinal()] = i;
    }
}

From source file:com.local.ask.controller.WebAppInitializer.java

@Override
public void onStartup(ServletContext container) {

    CharacterEncodingFilter encodingFilter = new org.springframework.web.filter.CharacterEncodingFilter();
    encodingFilter.setEncoding("UTF-8");
    encodingFilter.setForceEncoding(false);
    FilterRegistration.Dynamic encodingFilterDinamic = container.addFilter("charEncodingFilter",
            encodingFilter);//  w  ww .  j  a  v  a2  s .com
    encodingFilterDinamic.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");

    // Create the 'root' Spring application context
    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(WebConfig.class);
    rootContext.register(SecurityConfig.class);

    // Manage the lifecycle of the root application context
    container.addListener(new ContextLoaderListener(rootContext));

    // Create the dispatcher servlet's Spring application context
    AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext();
    dispatcherContext.register(HomeController.class);
    dispatcherContext.register(LoginController.class);
    dispatcherContext.register(PostController.class);
    dispatcherContext.register(SignUpController.class);
    dispatcherContext.register(ContactUsController.class);

    // Register and map the dispatcher servlet
    ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher",
            new DispatcherServlet(dispatcherContext));
    dispatcher.setLoadOnStartup(1);
    dispatcher.addMapping("/");

    DelegatingFilterProxy filterProxy = new DelegatingFilterProxy();
    filterProxy.setTargetFilterLifecycle(true);
    container.addFilter("shiroFilter", filterProxy).addMappingForUrlPatterns(null, false, "/*");

    // encoding filter
}

From source file:com.synopsys.integration.log.BufferedIntLogger.java

public void resetAllLogs() {
    EnumSet.allOf(LogLevel.class).forEach(logLevel -> resetLogs(logLevel));
}

From source file:org.jamocha.logging.TypedFilter.java

public void watchAll() {
    EnumSet.allOf(MarkerType.class)
            .forEach(mt -> this.markerToInExClusionList.put(mt, Pair.of(Boolean.TRUE, new ArrayList<>())));
}

From source file:com.github.fge.jsonschema.keyword.digest.helpers.DraftV3TypeKeywordDigester.java

private static void putType(final EnumSet<NodeType> types, final String s) {
    if (ANY.equals(s)) {
        types.addAll(EnumSet.allOf(NodeType.class));
        return;//from   w w w  .  j av a2  s .co  m
    }

    final NodeType type = NodeType.fromName(s);
    types.add(type);

    if (type == NodeType.NUMBER)
        types.add(NodeType.INTEGER);
}

From source file:com.admc.jcreole.JCreole.java

/**
 * Run this method with no parameters to see syntax requirements and the
 * available parameters./*from w ww.ja  va  2 s  .  c  o m*/
 *
 * N.b. do not call this method from a persistent program, because it
 * may call System.exit!
 * <p>
 * Any long-running program should use the lower-level methods in this
 * class instead (or directly use CreoleParser and CreoleScanner
 * instances).
 * </p> <p>
 * This method executes with all JCreole privileges.
 * </p> <p>
 * This method sets up the following htmlExpander mappings (therefore you
 * can reference these in both Creole and boilerplate text).<p>
 * <ul>
 *   <li>sys|*: mappings for Java system properties
 *   <li>isoDateTime
 *   <li>isoDate
 *   <li>pageTitle: Value derived from the specified Creole file name.
 * </ul>
 *
 * @throws IOException for any I/O problem that makes it impossible to
 *         satisfy the request.
 * @throws CreoleParseException
 *         if can not generate output, or if the run generates 0 output.
 *         If the problem is due to input formatting, in most cases you
 *         will get a CreoleParseException, which is a RuntimException, and
 *         CreoleParseException has getters for locations in the source
 *         data (though they will be offset for \r's in the provided
 *         Creole source, if any).
 */
public static void main(String[] sa) throws IOException {
    String bpResPath = null;
    String bpFsPath = null;
    String outPath = null;
    String inPath = null;
    boolean debugs = false;
    boolean troubleshoot = false;
    boolean noBp = false;
    int param = -1;
    try {
        while (++param < sa.length) {
            if (sa[param].equals("-d")) {
                debugs = true;
                continue;
            }
            if (sa[param].equals("-t")) {
                troubleshoot = true;
                continue;
            }
            if (sa[param].equals("-r") && param + 1 < sa.length) {
                if (bpFsPath != null || bpResPath != null || noBp)
                    throw new IllegalArgumentException();
                bpResPath = sa[++param];
                continue;
            }
            if (sa[param].equals("-f") && param + 1 < sa.length) {
                if (bpResPath != null || bpFsPath != null || noBp)
                    throw new IllegalArgumentException();
                bpFsPath = sa[++param];
                continue;
            }
            if (sa[param].equals("-")) {
                if (noBp || bpFsPath != null || bpResPath != null)
                    throw new IllegalArgumentException();
                noBp = true;
                continue;
            }
            if (sa[param].equals("-o") && param + 1 < sa.length) {
                if (outPath != null)
                    throw new IllegalArgumentException();
                outPath = sa[++param];
                continue;
            }
            if (inPath != null)
                throw new IllegalArgumentException();
            inPath = sa[param];
        }
        if (inPath == null)
            throw new IllegalArgumentException();
    } catch (IllegalArgumentException iae) {
        System.err.println(SYNTAX_MSG);
        System.exit(1);
    }
    if (!noBp && bpResPath == null && bpFsPath == null)
        bpResPath = DEFAULT_BP_RES_PATH;
    String rawBoilerPlate = null;
    if (bpResPath != null) {
        if (bpResPath.length() > 0 && bpResPath.charAt(0) == '/')
            // Classloader lookups are ALWAYS relative to CLASSPATH roots,
            // and will abort if you specify a beginning "/".
            bpResPath = bpResPath.substring(1);
        InputStream iStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(bpResPath);
        if (iStream == null)
            throw new IOException("Boilerplate inaccessible: " + bpResPath);
        rawBoilerPlate = IOUtil.toString(iStream);
    } else if (bpFsPath != null) {
        rawBoilerPlate = IOUtil.toString(new File(bpFsPath));
    }
    String creoleResPath = (inPath.length() > 0 && inPath.charAt(0) == '/') ? inPath.substring(1) : inPath;
    // Classloader lookups are ALWAYS relative to CLASSPATH roots,
    // and will abort if you specify a beginning "/".
    InputStream creoleStream = Thread.currentThread().getContextClassLoader()
            .getResourceAsStream(creoleResPath);
    File inFile = (creoleStream == null) ? new File(inPath) : null;
    JCreole jCreole = (rawBoilerPlate == null) ? (new JCreole()) : (new JCreole(rawBoilerPlate));
    if (debugs) {
        jCreole.setInterWikiMapper(new InterWikiMapper() {
            // This InterWikiMapper is just for prototyping.
            // Use wiki name of "nil" to force lookup failure for path.
            // Use wiki page of "nil" to force lookup failure for label.
            public String toPath(String wikiName, String wikiPage) {
                if (wikiName != null && wikiName.equals("nil"))
                    return null;
                return "{WIKI-LINK to: " + wikiName + '|' + wikiPage + '}';
            }

            public String toLabel(String wikiName, String wikiPage) {
                if (wikiPage == null)
                    throw new RuntimeException("Null page name sent to InterWikiMapper");
                if (wikiPage.equals("nil"))
                    return null;
                return "{LABEL for: " + wikiName + '|' + wikiPage + '}';
            }
        });
        Expander creoleExpander = new Expander(Expander.PairedDelims.RECTANGULAR);
        creoleExpander.put("testMacro",
                "\n\n<<prettyPrint>>\n{{{\n" + "!/bin/bash -p\n\ncp /etc/inittab /tmp\n}}}\n");
        jCreole.setCreoleExpander(creoleExpander);
    }
    jCreole.setPrivileges(EnumSet.allOf(JCreolePrivilege.class));
    Expander exp = jCreole.getHtmlExpander();
    Date now = new Date();
    exp.putAll("sys", System.getProperties(), false);
    exp.put("isoDateTime", isoDateTimeFormatter.format(now), false);
    exp.put("isoDate", isoDateFormatter.format(now), false);
    exp.put("pageTitle",
            (inFile == null) ? creoleResPath.replaceFirst("[.][^.]*$", "").replaceFirst(".*[/\\\\.]", "")
                    : inFile.getName().replaceFirst("[.][^.]*$", ""));
    if (troubleshoot) {
        // We don't write any HMTL output here.
        // Goal is just to output diagnostics.
        StringBuilder builder = (creoleStream == null) ? IOUtil.toStringBuilder(inFile)
                : IOUtil.toStringBuilder(creoleStream);
        int newlineCount = 0;
        int lastOffset = -1;
        int offset = builder.indexOf("\n");
        for (; offset >= 0; offset = builder.indexOf("\n", offset + 1)) {
            lastOffset = offset;
            newlineCount++;
        }
        // Accommodate input files with no terminating newline:
        if (builder.length() > lastOffset + 1)
            newlineCount++;
        System.out.println("Input lines:  " + newlineCount);
        Exception lastException = null;
        while (true) {
            try {
                jCreole.parseCreole(builder);
                break;
            } catch (Exception e) {
                lastException = e;
            }
            if (builder.charAt(builder.length() - 1) == '\n')
                builder.setLength(builder.length() - 1);
            offset = builder.lastIndexOf("\n");
            if (offset < 1)
                break;
            newlineCount--;
            builder.setLength(builder.lastIndexOf("\n"));
        }
        System.out.println((lastException == null) ? "Input validates"
                : String.format("Error around input line %d:  %s", newlineCount, lastException.getMessage()));
        return;
    }
    String generatedHtml = (creoleStream == null) ? jCreole.parseCreole(inFile)
            : jCreole.parseCreole(IOUtil.toStringBuilder(creoleStream));
    String html = jCreole.postProcess(generatedHtml, SystemUtils.LINE_SEPARATOR);
    if (outPath == null) {
        System.out.print(html);
    } else {
        FileUtils.writeStringToFile(new File(outPath), html, "UTF-8");
    }
}