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.conwet.silbops.model.ConstraintTest.java

@Test
@SuppressWarnings("unchecked")
public void shouldJSONise() {

    // Exist constraint
    JSONObject json = new JSONObject();
    json.put(EXISTS.toJSON(), "");

    assertThat(Constraint.EXIST.toJSON()).isEqualTo(json);
    assertThat(Constraint.EXIST.toJSONString()).isEqualTo(json.toJSONString());

    // verify Exist constraint is instantiated only once
    assertThat(Constraint.fromJSON(json)).isSameAs(Constraint.EXIST);

    // all others
    EnumSet<Operator> remaining = EnumSet.allOf(Operator.class);
    remaining.remove(EXISTS);/*from   ww w  . j a  v  a 2 s  .  c  o m*/

    for (Operator operator : remaining) {

        json = new JSONObject();
        json.put(operator.toJSON(), oneString.toJSON());

        Constraint cons = new Constraint(operator, oneString);
        assertThat(cons.toJSON()).isEqualTo(json);
        assertThat(cons.toJSONString()).isEqualTo(json.toJSONString());
        assertThat(Constraint.fromJSON(json)).isEqualTo(cons);
    }
}

From source file:com.github.fge.jsonschema.processors.digest.SchemaDigesterTest.java

@DataProvider
public Iterator<Object[]> sampleData() {
    return SampleNodeProvider.getSamples(EnumSet.allOf(NodeType.class));
}

From source file:com.github.pjungermann.config.specification.constraint.inetAddress.InetAddressConstraint.java

@Nullable
protected EnumSet<InetAddressType> configureAllowedVersions(@Nullable final Object expectation) {
    if (expectation == null) {
        return null;
    }//from   www  . j  a  v  a 2s .  c o  m

    if (expectation instanceof Boolean) {
        boolean allowed = (boolean) expectation;

        return allowed ? EnumSet.allOf(InetAddressType.class) : EnumSet.noneOf(InetAddressType.class);
    }

    if (expectation instanceof CharSequence) {
        return asCheckedEnumSet(singleton(expectation.toString()));
    }

    if (expectation instanceof Collection) {
        return asCheckedEnumSet((Collection) expectation);
    }

    return null;
}

From source file:com.tcloud.bee.key.server.jetty.config.WebAppInitializer.java

private void configureEncodingFilter(ServletContext servletContext) {

    CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter();
    encodingFilter.setEncoding("UTF-8");
    encodingFilter.setForceEncoding(false);
    FilterRegistration.Dynamic encodingFilterDinamic = servletContext.addFilter("charEncodingFilter",
            encodingFilter);/*from   w  ww.  java2s  .c  o m*/
    encodingFilterDinamic.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");

}

From source file:org.apache.accumulo.examples.wikisearch.ingest.WikipediaIngester.java

public static void createTables(TableOperations tops, String tableName, boolean configureLocalityGroups)
        throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException {
    // Create the shard table
    String indexTableName = tableName + "Index";
    String reverseIndexTableName = tableName + "ReverseIndex";
    String metadataTableName = tableName + "Metadata";

    // create the shard table
    if (!tops.exists(tableName)) {
        // Set a text index combiner on the given field names. No combiner is set if the option is not supplied
        String textIndexFamilies = WikipediaMapper.TOKENS_FIELD_NAME;

        tops.create(tableName);//from   w  ww.  j  av  a 2  s. c  o m
        if (textIndexFamilies.length() > 0) {
            System.out.println("Adding content combiner on the fields: " + textIndexFamilies);

            IteratorSetting setting = new IteratorSetting(10, TextIndexCombiner.class);
            List<Column> columns = new ArrayList<Column>();
            for (String family : StringUtils.split(textIndexFamilies, ',')) {
                columns.add(new Column("fi\0" + family));
            }
            TextIndexCombiner.setColumns(setting, columns);
            TextIndexCombiner.setLossyness(setting, true);

            tops.attachIterator(tableName, setting, EnumSet.allOf(IteratorScope.class));
        }

        // Set the locality group for the full content column family
        if (configureLocalityGroups)
            tops.setLocalityGroups(tableName, Collections.singletonMap("WikipediaDocuments",
                    Collections.singleton(new Text(WikipediaMapper.DOCUMENT_COLUMN_FAMILY))));

    }

    if (!tops.exists(indexTableName)) {
        tops.create(indexTableName);
        // Add the UID combiner
        IteratorSetting setting = new IteratorSetting(19, "UIDAggregator", GlobalIndexUidCombiner.class);
        GlobalIndexUidCombiner.setCombineAllColumns(setting, true);
        GlobalIndexUidCombiner.setLossyness(setting, true);
        tops.attachIterator(indexTableName, setting, EnumSet.allOf(IteratorScope.class));
    }

    if (!tops.exists(reverseIndexTableName)) {
        tops.create(reverseIndexTableName);
        // Add the UID combiner
        IteratorSetting setting = new IteratorSetting(19, "UIDAggregator", GlobalIndexUidCombiner.class);
        GlobalIndexUidCombiner.setCombineAllColumns(setting, true);
        GlobalIndexUidCombiner.setLossyness(setting, true);
        tops.attachIterator(reverseIndexTableName, setting, EnumSet.allOf(IteratorScope.class));
    }

    if (!tops.exists(metadataTableName)) {
        // Add the SummingCombiner with VARLEN encoding for the frequency column
        tops.create(metadataTableName);
        IteratorSetting setting = new IteratorSetting(10, SummingCombiner.class);
        SummingCombiner.setColumns(setting, Collections.singletonList(new Column("f")));
        SummingCombiner.setEncodingType(setting, SummingCombiner.Type.VARLEN);
        tops.attachIterator(metadataTableName, setting, EnumSet.allOf(IteratorScope.class));
    }
}

From source file:org.apache.whirr.command.AbstractClusterCommand.java

public AbstractClusterCommand(String name, String description, ClusterControllerFactory factory,
        ClusterStateStoreFactory stateStoreFactory) {
    super(name, description);

    configOption = parser//from   w  ww .  j a v a2s .c  o  m
            .accepts("config",
                    "Note that Whirr properties specified in " + "this file  should all have a whirr. prefix.")
            .withRequiredArg().describedAs("config.properties").ofType(String.class);

    parser.accepts("quiet", "Be less verbose");

    this.factory = factory;
    this.stateStoreFactory = stateStoreFactory;

    optionSpecs = Maps.newHashMap();
    for (Property property : EnumSet.allOf(Property.class)) {
        ArgumentAcceptingOptionSpec<?> spec = parser
                .accepts(property.getSimpleName(), property.getDescription()).withRequiredArg()
                .ofType(property.getType());
        if (property.hasMultipleArguments()) {
            spec.withValuesSeparatedBy(',');
        }
        optionSpecs.put(property, spec);
    }
}

From source file:au.org.ala.biocache.util.MimeType.java

/**
 * Retrieve a list of all mime types./*  www.  j  ava 2s  .  com*/
 *
 * @return
 */
public static List<String> getAllMimeTypes() {
    List<String> allMimeTypes = new ArrayList<String>();
    for (MimeType mt : EnumSet.allOf(MimeType.class)) {
        allMimeTypes.add(mt.getMimeType());
    }
    return allMimeTypes;
}

From source file:com.google.code.linkedinapi.client.examples.ProfileApiExample.java

/**
 * Process command line options and call the service. 
 */// w  ww  .  java2s.c o  m
private static void processCommandLine(CommandLine line, Options options) {
    if (line.hasOption(HELP_OPTION)) {
        printHelp(options);
    } else if (line.hasOption(CONSUMER_KEY_OPTION) && line.hasOption(CONSUMER_SECRET_OPTION)
            && line.hasOption(ACCESS_TOKEN_OPTION) && line.hasOption(ACCESS_TOKEN_SECRET_OPTION)) {
        final String consumerKeyValue = line.getOptionValue(CONSUMER_KEY_OPTION);
        final String consumerSecretValue = line.getOptionValue(CONSUMER_SECRET_OPTION);
        final String accessTokenValue = line.getOptionValue(ACCESS_TOKEN_OPTION);
        final String tokenSecretValue = line.getOptionValue(ACCESS_TOKEN_SECRET_OPTION);

        final LinkedInApiClientFactory factory = LinkedInApiClientFactory.newInstance(consumerKeyValue,
                consumerSecretValue);
        final LinkedInApiClient client = factory.createLinkedInApiClient(accessTokenValue, tokenSecretValue);

        ProfileType profileType = ProfileType.STANDARD;
        if (line.hasOption(TYPE_OPTION)) {
            profileType = ProfileType.valueOf(line.getOptionValue(TYPE_OPTION));
        }

        if (line.hasOption(ID_OPTION)) {
            String idValue = line.getOptionValue(ID_OPTION);
            System.out.println("Fetching profile for user with id:" + idValue);
            Person profile = client.getProfileById(idValue);
            printResult(profile);
        } else if (line.hasOption(URL_OPTION)) {
            String urlValue = line.getOptionValue(URL_OPTION);
            System.out.println("Fetching profile for user with url:" + urlValue);
            Person profile = client.getProfileByUrl(urlValue, profileType);
            printResult(profile);
        } else {
            System.out.println("Fetching profile for current user.");
            Person profile = client.getProfileForCurrentUser(EnumSet.allOf(ProfileField.class));
            printResult(profile);
        }
    } else {
        printHelp(options);
    }
}

From source file:io.wcm.wcm.commons.util.Template.java

/**
 * Lookup a template by the given template path.
 * @param templatePath Path of template//from w  w w  .  j  av  a  2  s  . c  o m
 * @return The {@link TemplatePathInfo} instance or null for unknown template paths
 */
@SafeVarargs
public static <E extends Enum<E> & TemplatePathInfo> TemplatePathInfo forTemplatePath(String templatePath,
        Class<E>... templateEnums) {
    if (templatePath == null || templateEnums == null) {
        return null;
    }
    for (Class<E> templateEnum : templateEnums) {
        for (E template : EnumSet.allOf(templateEnum)) {
            if (StringUtils.equals(template.getTemplatePath(), templatePath)) {
                return template;
            }
        }
    }
    return null;
}