List of usage examples for java.util EnumSet allOf
public static <E extends Enum<E>> EnumSet<E> allOf(Class<E> elementType)
From source file:com.devnexus.ting.web.controller.admin.PresentationController.java
private void prepareReferenceData(ModelMap model, Event event) { final Set<PresentationType> presentationTypes = EnumSet.allOf(PresentationType.class); model.addAttribute("presentationTypes", presentationTypes); final Set<SkillLevel> skillLevels = EnumSet.allOf(SkillLevel.class); model.addAttribute("skillLevels", skillLevels); final List<Track> tracks = businessService.getTracksForEvent(event.getId()); model.addAttribute("tracks", tracks); }
From source file:com.janrain.backplane.server.BackplaneMessage.java
@Override public Set<? extends MessageField> getFields() { return EnumSet.allOf(Field.class); }
From source file:com.coffeebeans.services.config.initializer.WebAppInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(AppConfig.class); servletContext.addListener(new ContextLoaderListener(rootContext)); AnnotationConfigWebApplicationContext dispatcherServlet = new AnnotationConfigWebApplicationContext(); dispatcherServlet.register(MvcConfig.class); ServletRegistration.Dynamic dispatcher = servletContext.addServlet(MVC_DISPATCHER_NAME, new DispatcherServlet(dispatcherServlet)); dispatcher.setLoadOnStartup(1);//w ww. j a v a2 s . co m dispatcher.addMapping("/1/*"); dispatcher.addMapping("/oauth/token"); FilterRegistration charEncodingFilterReg = servletContext.addFilter("CharacterEncodingFilter", CharacterEncodingFilter.class); charEncodingFilterReg.setInitParameter("encoding", "UTF-8"); charEncodingFilterReg.setInitParameter("forceEncoding", "true"); charEncodingFilterReg.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "/*"); }
From source file:eu.itesla_project.modules.histo.tools.HistoDbPrintForecastDiffTool.java
@Override public void run(CommandLine line) throws Exception { OfflineConfig config = OfflineConfig.load(); try (HistoDbClient histoDbClient = config.getHistoDbClientFactoryClass().newInstance().create()) { Interval interval = Interval.parse(line.getOptionValue("interval")); try (Reader reader = new InputStreamReader(histoDbClient.queryCsv(HistoQueryType.forecastDiff, EnumSet.allOf(Country.class), EnumSet.of(HistoDbEquip.loads, HistoDbEquip.gen), EnumSet.of(HistoDbAttr.P), interval, HistoDbHorizon.DACF, false, false))) { CharStreams.copy(reader, System.out); }/*from w w w . jav a2s . c om*/ } }
From source file:com.eucalyptus.ws.server.QueryPipeline.java
protected QueryPipeline(final String name, final String servicePathPrefix, final Set<TemporaryKeyType> allowedTemporaryCredentials) { this(name, ImmutableSet.of(servicePathPrefix), allowedTemporaryCredentials, EnumSet.allOf(RequiredQueryParams.class)); }
From source file:com.devnexus.ting.web.controller.admin.AcceptCfpController.java
private void prepareReferenceData(ModelMap model) { final Event currentEvent = businessService.getCurrentEvent(); model.addAttribute("currentEvent", currentEvent); final Set<CfpSubmissionStatusType> cfpSubmissionStatusTypes = EnumSet.allOf(CfpSubmissionStatusType.class); model.addAttribute("cfpSubmissionStatusTypes", cfpSubmissionStatusTypes); final List<Speaker> allSpeakers = businessService.getAllSpeakersOrderedByName(); model.addAttribute("allSpeakers", allSpeakers); }
From source file:de.grobox.liberario.trips.TripsLoader.java
@Nullable @Override/*www. ja v a 2 s . c o m*/ public QueryTripsResult loadInBackground() { TransportNetwork network = manager.getTransportNetwork(); if (network == null) return null; // TODO expose via TransportNetworkManager Optimize optimize = TransportrUtils.getOptimize(getContext()); WalkSpeed walkSpeed = TransportrUtils.getWalkSpeed(getContext()); EnumSet<Product> products = EnumSet.allOf(Product.class); Log.i(TAG, "From: " + from); Log.i(TAG, "Via: " + via); Log.i(TAG, "To: " + to); Log.i(TAG, "Date: " + date); Log.i(TAG, "Departure: " + departure); Log.i(TAG, "Products: " + products); Log.i(TAG, "Optimize for: " + optimize); Log.i(TAG, "Walk Speed: " + walkSpeed); try { NetworkProvider np = network.getNetworkProvider(); return np.queryTrips(from, via, to, date, departure, products, optimize, walkSpeed, null, null); } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:org.apache.sentry.policy.solr.TestSolrAuthorizationProviderSpecialCases.java
@Test public void testDuplicateEntries() throws Exception { Subject user1 = new Subject("user1"); Collection collection1 = new Collection("collection1"); Set<? extends Action> actions = EnumSet.allOf(SolrModelAction.class); policyFile.addGroupsToUser(user1.getName(), true, "group1", "group1") .addRolesToGroup("group1", true, "role1", "role1").addPermissionsToRole("role1", true, "collection=" + collection1.getName(), "collection=" + collection1.getName()); policyFile.write(iniFile);// w w w. j av a 2s.com PolicyEngine policy = SolrPolicyTestUtil.createPolicyEngineForTest(initResource); authzProvider = new LocalGroupResourceAuthorizationProvider(initResource, policy, SolrPrivilegeModel.getInstance()); List<? extends Authorizable> authorizableHierarchy = ImmutableList.of(collection1); Assert.assertTrue(authorizableHierarchy.toString(), authzProvider.hasAccess(user1, authorizableHierarchy, actions, ActiveRoleSet.ALL)); }
From source file:org.apache.sentry.policy.solr.TestSearchAuthorizationProviderSpecialCases.java
@Test public void testDuplicateEntries() throws Exception { Subject user1 = new Subject("user1"); Collection collection1 = new Collection("collection1"); Set<? extends Action> actions = EnumSet.allOf(SearchModelAction.class); policyFile.addGroupsToUser(user1.getName(), true, "group1", "group1") .addRolesToGroup("group1", true, "role1", "role1").addPermissionsToRole("role1", true, "collection=" + collection1.getName(), "collection=" + collection1.getName()); policyFile.write(iniFile);// ww w. j av a 2s . c o m PolicyEngine policy = SearchPolicyTestUtil.createPolicyEngineForTest(initResource); authzProvider = new LocalGroupResourceAuthorizationProvider(initResource, policy, SearchPrivilegeModel.getInstance()); List<? extends Authorizable> authorizableHierarchy = ImmutableList.of(collection1); Assert.assertTrue(authorizableHierarchy.toString(), authzProvider.hasAccess(user1, authorizableHierarchy, actions, ActiveRoleSet.ALL)); }
From source file:com.baasbox.configuration.PropertiesConfigurationHelper.java
/*** * * Returns a json representation of the Enumerator * The Enumerator must implements the IProperties interface * @param en the Enumerator to serialize. It must implements the IProperties interface * @return the representation of the Enumerator *//*from w w w . j av a2 s .c o m*/ @SuppressWarnings("unchecked") public static String dumpConfigurationAsJson(String section) { Class en = CONFIGURATION_SECTIONS.get(section); try { JsonFactory jfactory = new JsonFactory(); StringWriter sw = new StringWriter(); String enumDescription = ""; JsonGenerator gen = jfactory.createJsonGenerator(sw); Method getEnumDescription = en.getMethod("getEnumDescription"); if (getEnumDescription != null && getEnumDescription.getReturnType() == String.class && Modifier.isStatic(getEnumDescription.getModifiers())) enumDescription = (String) getEnumDescription.invoke(null); gen.writeStartObject(); //{ gen.writeStringField("section", section); // "configuration":"EnumName" gen.writeStringField("description", enumDescription); // ,"description": "EnumDescription" gen.writeFieldName("sub sections"); // ,"sections": gen.writeStartObject(); // { String lastSection = ""; EnumSet values = EnumSet.allOf(en); for (Object v : values) { String key = (String) (en.getMethod("getKey")).invoke(v); boolean isVisible = (Boolean) (en.getMethod("isVisible")).invoke(v); String valueAsString; if (isVisible) valueAsString = (String) (en.getMethod("getValueAsString")).invoke(v); else valueAsString = "--HIDDEN--"; boolean isEditable = (Boolean) (en.getMethod("isEditable")).invoke(v); String valueDescription = (String) (en.getMethod("getValueDescription")).invoke(v); Class type = (Class) en.getMethod("getType").invoke(v); String subsection = key.substring(0, key.indexOf('.')); if (!lastSection.equals(subsection)) { if (gen.getOutputContext().inArray()) gen.writeEndArray(); gen.writeFieldName(subsection); // "sectionName": gen.writeStartArray(); // [ lastSection = subsection; } boolean isOverridden = (Boolean) (en.getMethod("isOverridden")).invoke(v); gen.writeStartObject(); // { gen.writeStringField(key, valueAsString); // "key": "value" gen.writeStringField("description", valueDescription); // ,"description":"description" gen.writeStringField("type", type.getSimpleName()); // ,"type":"type" gen.writeBooleanField("editable", isEditable); // ,"editable":"true|false" gen.writeBooleanField("visible", isVisible); // ,"visible":"true|false" gen.writeBooleanField("overridden", isOverridden); // ,"overridden":"true|false" gen.writeEndObject(); // } } if (gen.getOutputContext().inArray()) gen.writeEndArray(); // ] gen.writeEndObject(); // } gen.writeEndObject(); //} gen.close(); return sw.toString(); } catch (Exception e) { BaasBoxLogger.error("Cannot generate a json for " + en.getSimpleName() + " Enum. Is it an Enum that implements the IProperties interface?", e); } return "{}"; }