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:net.iaeste.iws.core.services.ExchangeCSVFetchService.java

private String findSharedOffers(final Authentication authentication, final FetchOffersRequest request) {
    final List<String> offerIds = request.getIdentifiers();
    final Page page = request.getPage();
    final Integer exchangeYear = request.getExchangeYear();
    final Set<OfferState> states = EnumSet.allOf(OfferState.class);
    states.remove(OfferState.DELETED);//from w  w w. j  av a  2s . com

    final List<SharedOfferView> found;
    if (offerIds.isEmpty()) {
        //paging could make a problem here if it returns only some offers
        found = viewsDao.findSharedOffers(authentication, exchangeYear, states, false, page);
    } else {
        found = viewsDao.findSharedOffersByOfferIds(authentication, exchangeYear, offerIds);
    }

    return convertOffersToCsv(found, OfferFields.Type.FOREIGN);
}

From source file:SheetResourcesIT.java

public void testCreateUpdateRequest() throws SmartsheetException, IOException {
    ////from  w  w w  . ja v  a2  s.c  o m
    //create sheet
    Sheet sheet = smartsheet.sheetResources().createSheet(createSheetObject());

    //get column
    PaginationParameters parameters = new PaginationParameters.PaginationParametersBuilder().setIncludeAll(true)
            .build();
    PagedResult<Column> wrapper = smartsheet.sheetResources().columnResources().listColumns(sheet.getId(),
            EnumSet.allOf(ColumnInclusion.class), parameters);

    Column addedColumn1 = wrapper.getData().get(0);
    Column addedColumn2 = wrapper.getData().get(1);

    // Specify cell values for first row.
    List<Cell> cellsA = new Cell.AddRowCellsBuilder().addCell(addedColumn1.getId(), true)
            .addCell(addedColumn2.getId(), "New status").build();

    // Specify contents of first row.
    Row row = new Row.AddRowBuilder().setCells(cellsA).setToBottom(true).build();

    // Specify cell values for second row.
    List<Cell> cellsB = new Cell.AddRowCellsBuilder().addCell(addedColumn1.getId(), true)
            .addCell(addedColumn2.getId(), "New status").build();

    // Specify contents of first row.
    Row rowA = new Row.AddRowBuilder().setCells(cellsB).setToBottom(true).build();

    List<Row> newRows = smartsheet.sheetResources().rowResources().addRows(sheet.getId(),
            Arrays.asList(row, rowA));

    List<Column> columns = wrapper.getData();
    Column addedColumn = columns.get(1);
    //

    RecipientEmail recipientEmail = new RecipientEmail.AddRecipientEmailBuilder()
            .setEmail("aditi.nioding@smartsheet.com").setEmail("john.doe@smartsheet.com").build();

    List<Recipient> recipients = new ArrayList<Recipient>();
    recipients.add(recipientEmail);

    MultiRowEmail multiRowEmail = new MultiRowEmail.AddMultiRowEmailBuilder().setSendTo(recipients)
            .setSubject("some subject").setMessage("some message").setCcMe(false)
            .setRowIds(Arrays.asList(newRows.get(0).getId())).setColumnIds(Arrays.asList(addedColumn.getId()))
            .setIncludeAttachments(false).setIncludeDiscussions(false).build();

    smartsheet.sheetResources().createUpdateRequest(sheet.getId(), multiRowEmail);

    deleteSheet(sheet.getId());
}

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

private void createTables(TableOperations tops, String tableName)
        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  www.ja  v 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
        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:com.vmware.upgrade.progress.DefaultExecutionStateAggregatorTest.java

private List<Mapping<List<ExecutionState>>> computeDepthTwoPairWithStableTransitionStates() {
    Map<ExecutionState, Set<ExecutionState>> stateTransitions = computeAllStateTransitions();
    Set<ExecutionState> states = EnumSet.allOf(ExecutionState.class);

    List<Mapping<List<ExecutionState>>> depthTwoTransitions = new ArrayList<Mapping<List<ExecutionState>>>();

    for (Map.Entry<ExecutionState, Set<ExecutionState>> stateTransition : stateTransitions.entrySet()) {
        ExecutionState initialState = stateTransition.getKey();
        Set<ExecutionState> finalStates = stateTransition.getValue();
        for (ExecutionState finalState : finalStates) {
            for (ExecutionState stableState : states) {
                List<ExecutionState> depthTwoInitialStates = Arrays
                        .asList(new ExecutionState[] { initialState, stableState });
                List<ExecutionState> depthTwoFinalStates = Arrays
                        .asList(new ExecutionState[] { finalState, stableState });
                depthTwoTransitions// w w w. j  av a2s  .  com
                        .add(new Mapping<List<ExecutionState>>(depthTwoInitialStates, depthTwoFinalStates));
            }
        }
    }

    return depthTwoTransitions;
}

From source file:org.rhq.plugins.iis.IISResponseTimeDelegate.java

public IISResponseTimeDelegate(String logDirectory, String logFormat,
        ResponseTimeConfiguration responseTimeConfiguration/*, boolean isAbsoluteTime*/) {
    if (logDirectory == null) {
        throw new IllegalArgumentException("logDirectory can not be null");
    }/*ww w .ja v a  2s  .  c o m*/
    this.logDirectory = new File(logDirectory);

    // IIS always logs in UTC, even if the "Use local time for file naming and rollover" option is selected
    this.isAbsoluteTime = true;

    this.responseTimeConfiguration = responseTimeConfiguration;

    logTokenPositions = new HashMap<LogFormatToken, Integer>();
    String[] logFormatTokens = logFormat.split(" ");
    EnumSet<LogFormatToken> foundTokens = EnumSet.noneOf(LogFormatToken.class);
    for (int i = 0; i < logFormatTokens.length; i++) {
        String nextLiteral = logFormatTokens[i];
        LogFormatToken nextToken = LogFormatToken.getViaTokenLiteral(nextLiteral);
        if (nextToken != null) {
            if (foundTokens.contains(nextToken)) {
                // weird, but I suppose it's possible possible
                log.warn("Token '" + nextLiteral + "' was specified more than once");
            } else {
                log.debug("Required token found '" + nextLiteral + "' at position " + i);
                foundTokens.add(nextToken);
                logTokenPositions.put(nextToken, i);
            }
        } else {
            log.debug("Extra token found '" + nextLiteral + "' at position " + i);
        }
    }
    if (!foundTokens.containsAll(EnumSet.allOf(LogFormatToken.class))) {
        log.error(
                "Log format '" + logFormat + "' needs to include: " + LogFormatToken.getRequiredTokenString());
    }
}

From source file:com.googlecode.jmxtrans.model.output.InfluxDbWriterFactory.java

private ImmutableSet<ResultAttribute> initResultAttributesToWriteAsTags(List<String> resultTags) {
    EnumSet<ResultAttribute> resultAttributes = EnumSet.noneOf(ResultAttribute.class);
    if (resultTags != null) {
        for (String resultTag : resultTags) {
            resultAttributes.add(ResultAttribute.fromAttribute(resultTag));
        }/*from  w w  w.  ja v  a 2s  . com*/
    } else {
        resultAttributes = EnumSet.allOf(ResultAttribute.class);
    }

    ImmutableSet<ResultAttribute> result = immutableEnumSet(resultAttributes);
    LOG.debug("Result Tags to write set to: {}", result);
    return result;
}

From source file:com.github.rolecraftdev.guild.Guild.java

/**
 * Create a new {@link Guild}, automatically generating a semi-random
 * {@link UUID}; and the leader and default {@link GuildRank}s. When the
 * given {@link GuildManager} is {@code null}, all fields will be assigned
 * {@code null}./*w w w . j a v  a  2  s  .co m*/
 *
 * @param guildManager the {@link GuildManager} this {@link Guild} will be
 *        registered to
 * @since 0.0.5
 */
public Guild(final GuildManager guildManager) {
    if (guildManager == null) {
        this.guildManager = null;
        plugin = null;
        members = null;
        ranks = null;
        guildId = null;
        channel = null;
        return;
    }

    plugin = guildManager.getPlugin();
    this.guildManager = guildManager;
    guildId = UUID.randomUUID();
    members = new HashSet<UUID>();
    ranks = new HashSet<GuildRank>();

    ranks.add(new GuildRank(plugin.getMessage(Messages.GUILD_LEADER_RANK), EnumSet.allOf(GuildAction.class),
            new HashSet<UUID>()));
    ranks.add(new GuildRank(plugin.getMessage(Messages.GUILD_DEFAULT_RANK), EnumSet.noneOf(GuildAction.class),
            new HashSet<UUID>()));
    channel = new DefaultChannel(new DefaultChannelConfig().setOption(ChannelOption.PREFIX, "[GC] "));
}

From source file:fr.avianey.androidsvgdrawable.SvgDrawablePlugin.java

public void execute() {
    // validating target densities specified in pom.xml
    // untargetted densities will be ignored except for the fallback density if specified
    final Set<Density> targetDensities = new HashSet<>(Arrays.asList(parameters.getTargetedDensities()));
    if (targetDensities.isEmpty()) {
        targetDensities.addAll(EnumSet.allOf(Density.class));
    }/*from  www  .j  a  va2s .  co  m*/
    getLog().info("Targeted densities : " + Joiner.on(", ").join(targetDensities));

    /********************************
     * Load NinePatch configuration *
     ********************************/

    NinePatchMap ninePatchMap = new NinePatchMap();
    if (parameters.getNinePatchConfig() != null && parameters.getNinePatchConfig().isFile()) {
        getLog().info(
                "Loading NinePatch configuration file " + parameters.getNinePatchConfig().getAbsolutePath());
        try (final Reader reader = new FileReader(parameters.getNinePatchConfig())) {
            Type t = new TypeToken<Set<NinePatch>>() {
            }.getType();
            Set<NinePatch> ninePathSet = (Set<NinePatch>) (new GsonBuilder().create().fromJson(reader, t));
            ninePatchMap = NinePatch.init(ninePathSet);
        } catch (IOException e) {
            getLog().error(e);
        }
    } else {
        getLog().info("No NinePatch configuration file specified");
    }

    /*****************************
     * List input svg to convert *
     *****************************/

    getLog().info("Listing SVG files in " + parameters.getFrom().getAbsolutePath());
    final Collection<QualifiedResource> svgToConvert = listQualifiedResources(parameters.getFrom(), "svg");
    getLog().info("SVG files : " + Joiner.on(", ").join(svgToConvert));

    /*****************************
     * List input svgmask to use *
     *****************************/

    File svgMaskDirectory = parameters.getSvgMaskDirectory();
    File svgMaskResourcesDirectory = parameters.getSvgMaskResourcesDirectory();
    if (svgMaskDirectory == null) {
        svgMaskDirectory = parameters.getFrom();
    }
    if (svgMaskResourcesDirectory == null) {
        svgMaskResourcesDirectory = svgMaskDirectory;
    }
    getLog().info("Listing SVGMASK files in " + svgMaskDirectory.getAbsolutePath());
    final Collection<QualifiedResource> svgMasks = listQualifiedResources(svgMaskDirectory, "svgmask");
    final Collection<QualifiedResource> svgMaskResources = new ArrayList<>();
    getLog().info("SVGMASK files : " + Joiner.on(", ").join(svgMasks));
    if (!svgMasks.isEmpty()) {
        // list masked resources
        if (svgMaskResourcesDirectory.equals(parameters.getFrom())) {
            svgMaskResources.addAll(svgToConvert);
        } else {
            svgMaskResources.addAll(listQualifiedResources(svgMaskResourcesDirectory, "svg"));
        }
        getLog().info("SVG files to mask : " + Joiner.on(", ").join(svgMaskResources));
        // generate masked svg
        for (QualifiedResource maskFile : svgMasks) {
            getLog().info("Generating masked files for " + maskFile);
            try {
                Collection<QualifiedResource> generatedResources = new SvgMask(maskFile)
                        .generatesMaskedResources(parameters.getSvgMaskedSvgOutputDirectory(), svgMaskResources,
                                parameters.isUseSameSvgOnlyOnceInMask(), parameters.getOverrideMode());
                getLog().debug("+ " + Joiner.on(", ").join(generatedResources));
                svgToConvert.addAll(generatedResources);
            } catch (XPathExpressionException | TransformerException | ParserConfigurationException
                    | SAXException | IOException e) {
                getLog().error(e);
            }
        }
    } else {
        getLog().info("No SVGMASK file found.");
    }

    QualifiedResource highResIcon = null;

    /*********************************
     * Create svg in res/* folder(s) *
     *********************************/

    for (QualifiedResource svg : svgToConvert) {
        try {
            getLog().info(
                    "Transcoding " + FilenameUtils.getName(svg.getAbsolutePath()) + " to targeted densities");
            Rectangle bounds = extractSVGBounds(svg);
            if (getLog().isDebugEnabled()) {
                getLog().debug("+ source dimensions [width=" + bounds.getWidth() + " - height="
                        + bounds.getHeight() + "]");
            }
            if (parameters.getHighResIcon() != null && parameters.getHighResIcon().equals(svg.getName())) {
                highResIcon = svg;
            }
            // for each target density :
            // - find matching destinations :
            //   - matches all extra qualifiers
            //   - no other output with a qualifiers set that is a subset of this output
            // - if no match, create required directories
            for (Density d : targetDensities) {
                NinePatch ninePatch = ninePatchMap.getBestMatch(svg);
                File destination = svg.getOutputFor(d, parameters.getTo(),
                        ninePatch == null ? parameters.getOutputType() : OutputType.drawable);
                if (!destination.exists() && parameters.isCreateMissingDirectories()) {
                    destination.mkdirs();
                }
                if (destination.exists()) {
                    getLog().debug("Transcoding " + svg.getName() + " to " + destination.getName());
                    transcode(svg, d, bounds, destination, ninePatch);
                } else {
                    getLog().info("Qualified output " + destination.getName() + " does not exists. "
                            + "Set 'createMissingDirectories' to true if you want it to be created if missing...");
                }
            }
        } catch (IOException | TranscoderException | InstantiationException | IllegalAccessException e) {
            getLog().error("Error while converting " + svg, e);
        }
    }

    /******************************************
     * Generates the play store high res icon *
     ******************************************/

    if (highResIcon != null) {
        try {
            // TODO : add a garbage density (NO_DENSITY) for the highResIcon
            // TODO : make highResIcon size configurable
            // TODO : generates other play store assets
            // TODO : parameterized SIZE
            getLog().info("Generating high resolution icon");
            transcode(highResIcon, Density.mdpi, new File("."), 512, 512, null);
        } catch (IOException | TranscoderException | InstantiationException | IllegalAccessException e) {
            getLog().error("Error while converting " + highResIcon, e);
        }
    }
}

From source file:org.ngrinder.user.controller.UserController.java

/**
 * Get user detail page.//from  w  w w .j  a  va  2 s . co  m
 *
 * @param model  mode
 * @param userId user to get
 * @return "user/detail"
 */
@RequestMapping("/{userId}")
@PreAuthorize("hasAnyRole('A')")
public String getOne(@PathVariable final String userId, ModelMap model) {
    User one = userService.getOne(userId);
    model.addAttribute("user", one);
    model.addAttribute("allowPasswordChange", true);
    model.addAttribute("allowRoleChange", true);
    model.addAttribute("roleSet", EnumSet.allOf(Role.class));
    model.addAttribute("showPasswordByDefault", false);
    attachCommonAttribute(one, model);
    return "user/detail";
}

From source file:org.apache.accumulo.shell.commands.SetIterCommandTest.java

@Test
public void addColumnAgeOffFilter() throws Exception {
    AccumuloClient client = EasyMock.createMock(AccumuloClient.class);
    CommandLine cli = EasyMock.createMock(CommandLine.class);
    Shell shellState = EasyMock.createMock(Shell.class);
    ConsoleReader reader = EasyMock.createMock(ConsoleReader.class);
    Writer out = EasyMock.createMock(PrintWriter.class);
    TableOperations tableOperations = EasyMock.createMock(TableOperations.class);

    // Command line parsing
    EasyMock.expect(cli.hasOption("all")).andReturn(true);
    EasyMock.expect(cli.hasOption("all")).andReturn(true);
    EasyMock.expect(cli.hasOption("all")).andReturn(true);
    EasyMock.expect(cli.hasOption("t")).andReturn(true);
    EasyMock.expect(cli.hasOption("t")).andReturn(true);
    EasyMock.expect(cli.getOptionValue("t")).andReturn("foo");
    EasyMock.expect(cli.hasOption("ns")).andReturn(false);
    EasyMock.expect(cli.getOptionValue("p")).andReturn("21");
    EasyMock.expect(cli.getOptionValue("class"))
            .andReturn("org.apache.accumulo.core.iterators.user.ColumnAgeOffFilter");
    EasyMock.expect(cli.hasOption("ageoff")).andReturn(false);
    EasyMock.expect(cli.hasOption("regex")).andReturn(false);
    EasyMock.expect(cli.hasOption("reqvis")).andReturn(false);
    EasyMock.expect(cli.hasOption("vers")).andReturn(false);
    EasyMock.expect(cli.getOptionValue("n", null)).andReturn(null);

    // Loading the class
    EasyMock.expect(shellState.getClassLoader(cli, shellState))
            .andReturn(AccumuloVFSClassLoader.getClassLoader());

    // Set the output object
    Field field = reader.getClass().getSuperclass().getDeclaredField("out");
    field.setAccessible(true);//  ww w  .j  av a2 s  .c  o m
    field.set(reader, out);

    // Parsing iterator options
    reader.flush();
    EasyMock.expectLastCall().times(3);

    EasyMock.expect(shellState.getReader()).andReturn(reader);

    // Shell asking for negate option, we pass in an empty string to pickup the default value of
    // 'false'
    EasyMock.expect(reader.readLine(EasyMock.anyObject(String.class))).andReturn("");

    // Shell asking for the unnamed option for the column (a:a) and the TTL (1)
    EasyMock.expect(reader.readLine(EasyMock.anyObject(String.class))).andReturn("a:a 1");

    // Shell asking for another unnamed option; we pass in an empty string to signal that we are
    // done adding options
    EasyMock.expect(reader.readLine(EasyMock.anyObject(String.class))).andReturn("");
    EasyMock.expect(shellState.getAccumuloClient()).andReturn(client);

    // Table exists
    EasyMock.expect(client.tableOperations()).andReturn(tableOperations);
    EasyMock.expect(tableOperations.exists("foo")).andReturn(true);

    // Testing class load
    EasyMock.expect(shellState.getAccumuloClient()).andReturn(client);
    EasyMock.expect(client.tableOperations()).andReturn(tableOperations);
    EasyMock.expect(
            tableOperations.testClassLoad("foo", "org.apache.accumulo.core.iterators.user.ColumnAgeOffFilter",
                    SortedKeyValueIterator.class.getName()))
            .andReturn(true);

    // Attach iterator
    EasyMock.expect(shellState.getAccumuloClient()).andReturn(client);
    EasyMock.expect(client.tableOperations()).andReturn(tableOperations);
    tableOperations.attachIterator(EasyMock.eq("foo"), EasyMock.anyObject(IteratorSetting.class),
            EasyMock.eq(EnumSet.allOf(IteratorScope.class)));
    EasyMock.expectLastCall().once();

    EasyMock.replay(client, cli, shellState, reader, tableOperations);

    cmd.execute(
            "setiter -all -p 21 -t foo" + " -class org.apache.accumulo.core.iterators.user.ColumnAgeOffFilter",
            cli, shellState);

    EasyMock.verify(client, cli, shellState, reader, tableOperations);
}