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:org.richfaces.tests.metamer.ftest.extension.attributes.coverage.result.SimpleCoverageResult.java

@SuppressWarnings("unchecked")
public SimpleCoverageResult(Class<? extends Enum> componentEnumClass, EnumSet covered) {
    this.componentEnumClass = componentEnumClass;
    this.covered = covered;
    this.whole = EnumSet.allOf(componentEnumClass);
    ignored = getDefaultIgnoredValues(componentEnumClass);
    ignored.removeAll(covered);//  w w w .  j a v  a2  s.  co  m
    this.notCovered = getNotCovered(covered, this.ignored);
}

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

/**
 * Creates a {@link PAPPermission} object starting from a string array,
 * like /*  w w w .  j  a v  a  2s  .  c  o m*/
 * <code>
 * String[] perms = new String[]{"POLICY_READ_LOCAL","POLICY_READ_REMOTE"};
 * </code>
 * 
 * @param perms, a string array of pap permission flags 
 * @return the {@link PAPPermission} object corresponding to the string array passed as argument
 */
public static PAPPermission fromStringArray(String[] perms) {

    PAPPermission perm = new PAPPermission();

    for (String s : perms) {

        if ("ALL".equals(s)) {

            perm.permissions.addAll(EnumSet.allOf(PermissionFlags.class));
            break;

        } else {
            try {

                PermissionFlags newPerm = PermissionFlags.valueOf(s.trim());
                perm.permissions.add(newPerm);
            } catch (IllegalArgumentException e) {

                throw new PAPAuthzException("Unknown permission passed as argument! '" + s + "'.", e);
            }

        }

    }
    return perm;

}

From source file:org.eel.kitchen.jsonschema.syntax.TypeKeywordSyntaxChecker.java

private static void validateOne(final Message.Builder msg, final List<Message> messages, final JsonNode value) {
    // Cannot happen in the event of single property validation (will
    // always be a string)
    if (value.isObject())
        return;/*from   ww w  .  java2 s.c o m*/

    // See above
    if (!value.isTextual()) {
        msg.addInfo("found", NodeType.getNodeType(value)).setMessage("array element has incorrect type")
                .addInfo("expected", VALID_TYPE_ARRAY_ELEMENTS);
        messages.add(msg.build());
        return;
    }

    // Now we can actually check that the string is a valid primitive type
    final String s = value.textValue();

    if (ANY.equals(s))
        return;

    if (NodeType.fromName(s) != null)
        return;

    msg.addInfo("possible-values", EnumSet.allOf(NodeType.class)).addInfo("found", s)
            .setMessage("unknown simple type");
    messages.add(msg.build());
}

From source file:com.example.app.profile.ui.resource.PublicResourceListing.java

/**
 * Instantiates a new Public Resource Listing
 *///from  ww w. jav  a2 s . co m
public PublicResourceListing() {
    super();
    setName(COMPONENT_NAME());
    addCategory(CmsCategory.ClientBackend);
    addClassName("public-resources");
    setIncludePublicOnly(true);
    setSortMethods(EnumSet.allOf(SortMethod.class));
}

From source file:com.olegchir.wicket_spring_security_example.init.AppInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {

    //Create webapp context
    AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); //part of spring-web
    root.register(SpringSecurityConfiguration.class); //register class by annotation. Here be all security rules.

    //Register DelegatingFilterProxy
    FilterRegistration.Dynamic springSecurityFilterChainReg = servletContext
            .addFilter("springSecurityFilterChain", DelegatingFilterProxy.class);
    springSecurityFilterChainReg/* w  w  w . j  a  va 2 s. com*/
            .addMappingForUrlPatterns(EnumSet.of(DispatcherType.ERROR, DispatcherType.REQUEST), false, "/*");

    servletContext.addListener(new ContextLoaderListener(root));

    //Register WicketFilter
    WicketFilter wicketFilter = new WicketFilter(new WicketApplication()) {
        @Override
        public void init(boolean isServlet, FilterConfig filterConfig) throws ServletException {
            setFilterPath(""); //don't use web.xml. WicketApplication.init is a custom override for it.
            super.init(isServlet, filterConfig);
        }
    };
    FilterRegistration.Dynamic wicketFilterReg = servletContext.addFilter("wicketFilter", wicketFilter);
    wicketFilterReg.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "*");
}

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

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

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

private void createPreviewInstances(PhotovaultImage img, PhotoInfo p, DAOFactory f) throws CommandException {
    long startTime = System.currentTimeMillis();
    ImageDescriptorBase thumbImage = p.getPreferredImage(EnumSet.allOf(ImageOperations.class),
            EnumSet.allOf(ImageOperations.class), 0, 0, 200, 200);

    // Preview image with no cropping, longer side 1280 pixels
    int origWidth = p.getOriginal().getWidth();
    int origHeight = p.getOriginal().getHeight();

    int copyMinWidth = Math.min(origWidth, 1280);
    int copyMinHeight = 0;
    if (origHeight > origWidth) {
        copyMinHeight = Math.min(origHeight, 1280);
        copyMinWidth = 0;/* w w  w  .j  a va  2s.  co  m*/
    }
    EnumSet<ImageOperations> previewOps = EnumSet.of(ImageOperations.RAW_CONVERSION, ImageOperations.COLOR_MAP);
    ImageDescriptorBase previewImage = p.getPreferredImage(previewOps, previewOps, copyMinWidth, copyMinHeight,
            1280, 1280);

    Volume vol = f.getVolumeDAO().getDefaultVolume();
    long previewImageTime = -1;
    if (previewImage == null) {
        long previewStart = System.currentTimeMillis();
        CreateCopyImageCommand cmd = new CreateCopyImageCommand(img, p, vol, 1280, 1280);
        cmd.setLowQualityAllowed(false);
        cmd.setOperationsToApply(previewOps);
        cmdHandler.executeCommand(cmd);
        previewImageTime = System.currentTimeMillis() - previewStart;
    }
    long thumbTime = -1;
    if (thumbImage == null) {
        long thumbStart = System.currentTimeMillis();
        CreateCopyImageCommand cmd = new CreateCopyImageCommand(img, p, vol, 200, 200);
        cmd.setLowQualityAllowed(true);
        cmdHandler.executeCommand(cmd);
        thumbTime = System.currentTimeMillis() - thumbStart;
    }
    long totalTime = System.currentTimeMillis() - startTime;
    log.debug("preview " + previewImageTime + " ms, thumb " + thumbTime + " ms, total " + totalTime + " ms");
}

From source file:org.davidmendoza.demo.config.StartUpConfig.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.register(ComponentConfig.class, DataConfig.class, MailConfig.class, WebConfig.class);
    context.setDisplayName("DemoApp");

    FilterRegistration.Dynamic sitemeshFilter = servletContext.addFilter("sitemeshFilter",
            new ConfigurableSiteMeshFilter());
    sitemeshFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");

    FilterRegistration.Dynamic characterEncodingFilter = servletContext.addFilter("characterEncodingFilter",
            new CharacterEncodingFilter());
    characterEncodingFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");
    characterEncodingFilter.setInitParameter("encoding", "UTF-8");
    characterEncodingFilter.setInitParameter("forceEncoding", "true");

    servletContext.addListener(new ContextLoaderListener(context));
    //servletContext.setInitParameter("defaultHtmlEscape", "false");

    DispatcherServlet servlet = new DispatcherServlet();
    // no explicit configuration reference here: everything is configured in the root container for simplicity
    servlet.setContextConfigLocation("");

    ServletRegistration.Dynamic appServlet = servletContext.addServlet("appServlet", servlet);
    appServlet.setLoadOnStartup(1);// ww w.j  ava  2s  .  c o m
    appServlet.setAsyncSupported(true);

    Set<String> mappingConflicts = appServlet.addMapping("/");
    if (!mappingConflicts.isEmpty()) {
        throw new IllegalStateException("'appServlet' cannot be mapped to '/' under Tomcat versions <= 7.0.14");
    }
}

From source file:org.apache.ode.store.ProcessCleanupConfImpl.java

public static void processACleanup(Set<CLEANUP_CATEGORY> categories,
        List<TCleanup.Category.Enum> categoryList) {
    if (categoryList.isEmpty()) {
        // add all categories
        categories.addAll(EnumSet.allOf(CLEANUP_CATEGORY.class));
    } else {// w  ww .j a  v  a  2  s  .  co  m
        for (TCleanup.Category.Enum aCategory : categoryList) {
            if (aCategory == TCleanup.Category.ALL) {
                // add all categories
                categories.addAll(EnumSet.allOf(CLEANUP_CATEGORY.class));
            } else {
                categories.add(CLEANUP_CATEGORY.fromString(aCategory.toString()));
            }
        }
    }
}

From source file:com.github.fge.jsonschema.syntax.checkers.helpers.DraftV3TypeKeywordSyntaxChecker.java

@Override
protected void checkValue(final Collection<JsonPointer> pointers, final ProcessingReport report,
        final SchemaTree tree) throws ProcessingException {
    final JsonNode node = tree.getNode().get(keyword);

    if (node.isTextual()) {
        if (!typeIsValid(node.textValue()))
            report.error(newMsg(tree, "incorrectPrimitiveType").put("valid", EnumSet.allOf(NodeType.class))
                    .put("found", node));
        return;/*w w w  . j  a v a  2s  . c  om*/
    }

    final int size = node.size();
    final Set<Equivalence.Wrapper<JsonNode>> set = Sets.newHashSet();

    JsonNode element;
    NodeType type;
    boolean uniqueItems = true;

    for (int index = 0; index < size; index++) {
        element = node.get(index);
        type = NodeType.getNodeType(element);
        uniqueItems = set.add(EQUIVALENCE.wrap(element));
        if (type == OBJECT) {
            pointers.add(JsonPointer.of(keyword, index));
            continue;
        }
        if (type != STRING) {
            report.error(newMsg(tree, "incorrectElementType").put("index", index)
                    .put("expected", EnumSet.of(OBJECT, STRING)).put("found", type));
            continue;
        }
        if (!typeIsValid(element.textValue()))
            report.error(newMsg(tree, "incorrectPrimitiveType").put("index", index)
                    .put("valid", EnumSet.allOf(NodeType.class)).put("found", element));
    }

    if (!uniqueItems)
        report.error(newMsg(tree, "elementsNotUnique"));
}