Example usage for java.util EnumSet of

List of usage examples for java.util EnumSet of

Introduction

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

Prototype

@SafeVarargs
public static <E extends Enum<E>> EnumSet<E> of(E first, E... rest) 

Source Link

Document

Creates an enum set initially containing the specified elements.

Usage

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/*from   www  . ja v a  2s  .  c  o m*/
            .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:net.lmxm.ute.gui.components.MavenArtifactsTableModel.java

/**
 * Instantiates a new Maven artifacts table model.
 *
 * @param artifacts the list of MavenArtifact objects
 *//*from w w w.j a  v  a2  s.  c  o  m*/
public MavenArtifactsTableModel(final List<MavenArtifact> artifacts) {
    super(EnumSet.of(TableColumnResourceType.MAVEN_ARTIFACT_COORDINATES,
            TableColumnResourceType.TARGET_FILE_NAME));

    this.artifacts = artifacts;

    cleanRowData();
}

From source file:rashjz.info.com.az.config.MyWebInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext();
    appContext.register(SpringWebConfig.class);

    DispatcherServlet dispatcherServlet = new DispatcherServlet(appContext);
    dispatcherServlet.setThrowExceptionIfNoHandlerFound(true);
    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("SpringDispatcher", dispatcherServlet);
    dispatcher.setLoadOnStartup(1);/*from   ww w  .j  a v  a  2 s.c  om*/
    dispatcher.addMapping("/");

    CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
    characterEncodingFilter.setEncoding("UTF-8");
    characterEncodingFilter.setForceEncoding(true);

    EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD);
    FilterRegistration.Dynamic characterEncoding = servletContext.addFilter("characterEncoding",
            characterEncodingFilter);
    characterEncoding.addMappingForUrlPatterns(dispatcherTypes, true, "/*");
}

From source file:com.opengamma.engine.fudgemsg.ExecutionLogFudgeBuilderTest.java

@Test
public void roundTrip() {
    MutableExecutionLog log = new MutableExecutionLog(ExecutionLogMode.FULL);
    LogEvent errorEvent = new SimpleLogEvent(LogLevel.ERROR, "error msg");
    LogEvent infoEvent1 = new SimpleLogEvent(LogLevel.INFO, "info msg");
    LogEvent infoEvent2 = new SimpleLogEvent(LogLevel.INFO, "info msg2");
    log.add(errorEvent);//from w w  w.  jav a 2s  .  c om
    log.add(infoEvent1);
    log.add(infoEvent2);
    String execptionMsg = "exception msg";
    assertEquals(log.getLogLevels(), EnumSet.of(LogLevel.ERROR, LogLevel.INFO));
    log.setException(new OpenGammaRuntimeException(execptionMsg));
    assertEquals(log.getLogLevels(), EnumSet.of(LogLevel.ERROR, LogLevel.INFO, LogLevel.WARN));
    FudgeSerializer serializer = new FudgeSerializer(OpenGammaFudgeContext.getInstance());
    ExecutionLogFudgeBuilder builder = new ExecutionLogFudgeBuilder();
    FudgeMsg msg = builder.buildMessage(serializer, log);

    FudgeDeserializer deserializer = new FudgeDeserializer(OpenGammaFudgeContext.getInstance());
    ExecutionLog executionLog = builder.buildObject(deserializer, msg);
    assertEquals(EnumSet.<LogLevel>of(LogLevel.ERROR, LogLevel.INFO, LogLevel.WARN),
            executionLog.getLogLevels());
    List<LogEvent> events = executionLog.getEvents();
    assertTrue(events.contains(errorEvent));
    assertTrue(events.contains(infoEvent1));
    assertTrue(events.contains(infoEvent2));
    assertEquals("com.opengamma.OpenGammaRuntimeException", executionLog.getExceptionClass());
    assertEquals(execptionMsg, executionLog.getExceptionMessage());
    assertFalse(StringUtils.isEmpty(executionLog.getExceptionStackTrace()));
}

From source file:com.github.fge.jackson.SampleNodeProvider.java

public static Iterator<Object[]> getSamples(final NodeType first, final NodeType... other) {
    return getSamples(EnumSet.of(first, other));
}

From source file:net.lmxm.ute.gui.components.RenameFilesTableModel.java

/**
 * Instantiates a new rename files table model.
 * //w w w  . j av a2s  .  com
 * @param renameFilesTask the rename files task
 */
public RenameFilesTableModel(final RenameFilesTask renameFilesTask) {
    super(EnumSet.of(TableColumnResourceType.FILE_NAME, TableColumnResourceType.TARGET_FILE_NAME));

    rowData = renameFilesTask.getFiles();

    cleanRowData();
}

From source file:net.lmxm.ute.gui.components.FindReplacePatternsTableModel.java

/**
 * Instantiates a new find replace patterns table model.
 * /*www  .  ja v a 2  s  .  co m*/
 * @param findReplaceTask the find replace task
 */
public FindReplacePatternsTableModel(final FindReplaceTask findReplaceTask) {
    super(EnumSet.of(TableColumnResourceType.FIND, TableColumnResourceType.REPLACEMENT));

    rowData = findReplaceTask.getPatterns();

    cleanRowData();
}

From source file:com.google.code.stackexchange.client.examples.QueryApiExample.java

/**
 * Process command line./*from  ww  w  . ja v a2 s.  com*/
 * 
 * @param line the line
 * @param options the options
 */
private static void processCommandLine(CommandLine line, Options options) {
    if (line.hasOption(HELP_OPTION)) {
        printHelp(options);
    } else if (line.hasOption(APPLICATION_KEY_OPTION)) {
        final String keyValue = line.getOptionValue(APPLICATION_KEY_OPTION);

        final StackExchangeApiQueryFactory factory = StackExchangeApiQueryFactory.newInstance(keyValue);
        final QuestionApiQuery query = factory.newQuestionApiQuery();

        List<Question> questions = query
                .withFetchOptions(EnumSet.of(FilterOption.INCLUDE_BODY, FilterOption.INCLUDE_COMMENTS))
                .withSort(Question.SortOrder.HOT).list();
        for (Question question : questions) {
            printResult(question);
        }
    } else {
        printHelp(options);
    }
}

From source file:joinery.impl.Display.java

public static <C extends Container, V> C draw(final DataFrame<V> df, final C container, final PlotType type) {
    final List<XChartPanel> panels = new LinkedList<>();
    final DataFrame<Number> numeric = df.numeric().fillna(0);
    final int rows = (int) Math.ceil(Math.sqrt(numeric.size()));
    final int cols = numeric.size() / rows + 1;

    final List<Object> xdata = new ArrayList<>(df.length());
    final Iterator<Object> it = df.index().iterator();
    for (int i = 0; i < df.length(); i++) {
        final Object value = it.hasNext() ? it.next() : i;
        if (value instanceof Number || value instanceof Date) {
            xdata.add(value);//  www . j a  va  2  s . com
        } else if (PlotType.BAR.equals(type)) {
            xdata.add(String.valueOf(value));
        } else {
            xdata.add(i);
        }
    }

    if (EnumSet.of(PlotType.GRID, PlotType.GRID_WITH_TREND).contains(type)) {
        for (final Object col : numeric.columns()) {
            final Chart chart = new ChartBuilder().chartType(chartType(type)).width(800 / cols)
                    .height(800 / cols).title(String.valueOf(col)).build();
            final Series series = chart.addSeries(String.valueOf(col), xdata, numeric.col(col));
            if (type == PlotType.GRID_WITH_TREND) {
                addTrend(chart, series, xdata);
                series.setLineStyle(SeriesLineStyle.NONE);
            }
            chart.getStyleManager().setLegendVisible(false);
            chart.getStyleManager().setDatePattern(dateFormat(xdata));
            panels.add(new XChartPanel(chart));
        }
    } else {
        final Chart chart = new ChartBuilder().chartType(chartType(type)).build();

        chart.getStyleManager().setDatePattern(dateFormat(xdata));
        switch (type) {
        case SCATTER:
        case SCATTER_WITH_TREND:
        case LINE_AND_POINTS:
            break;
        default:
            chart.getStyleManager().setMarkerSize(0);
            break;
        }

        for (final Object col : numeric.columns()) {
            final Series series = chart.addSeries(String.valueOf(col), xdata, numeric.col(col));
            if (type == PlotType.SCATTER_WITH_TREND) {
                addTrend(chart, series, xdata);
                series.setLineStyle(SeriesLineStyle.NONE);
            }
        }

        panels.add(new XChartPanel(chart));
    }

    if (panels.size() > 1) {
        container.setLayout(new GridLayout(rows, cols));
    }
    for (final XChartPanel p : panels) {
        container.add(p);
    }

    return container;
}

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

protected AbstractDigesterTest(final Dictionary<Digester> dict, final String prefix, final String keyword,
        final NodeType first, final NodeType... other) throws IOException {
    digester = dict.entries().get(keyword);
    types = EnumSet.of(first, other);
    this.keyword = keyword;
    final String resourceName = String.format("/keyword/digest/%s/%s.json", prefix, keyword);
    data = JsonLoader.fromResource(resourceName);
}