List of usage examples for java.util EnumSet allOf
public static <E extends Enum<E>> EnumSet<E> allOf(Class<E> elementType)
From source file:org.apache.hadoop.yarn.server.timeline.MapTimelineStore.java
@Override public synchronized TimelineEntities getEntities(String entityType, Long limit, Long windowStart, Long windowEnd, String fromId, Long fromTs, NameValuePair primaryFilter, Collection<NameValuePair> secondaryFilters, EnumSet<Field> fields, CheckAcl checkAcl) throws IOException { if (serviceStopped) { LOG.info("Service stopped, return null for the storage"); return null; }//w ww.jav a2 s.c o m if (limit == null) { limit = DEFAULT_LIMIT; } if (windowStart == null) { windowStart = Long.MIN_VALUE; } if (windowEnd == null) { windowEnd = Long.MAX_VALUE; } if (fields == null) { fields = EnumSet.allOf(Field.class); } Iterator<TimelineEntity> entityIterator = null; if (fromId != null) { TimelineEntity firstEntity = entities.get(new EntityIdentifier(fromId, entityType)); if (firstEntity == null) { return new TimelineEntities(); } else { entityIterator = entities.valueSetIterator(firstEntity); } } if (entityIterator == null) { entityIterator = entities.valueSetIterator(); } List<TimelineEntity> entitiesSelected = new ArrayList<TimelineEntity>(); while (entityIterator.hasNext()) { TimelineEntity entity = entityIterator.next(); if (entitiesSelected.size() >= limit) { break; } if (!entity.getEntityType().equals(entityType)) { continue; } if (entity.getStartTime() <= windowStart) { continue; } if (entity.getStartTime() > windowEnd) { continue; } if (fromTs != null && entityInsertTimes .get(new EntityIdentifier(entity.getEntityId(), entity.getEntityType())) > fromTs) { continue; } if (primaryFilter != null && !matchPrimaryFilter(entity.getPrimaryFilters(), primaryFilter)) { continue; } if (secondaryFilters != null) { // AND logic boolean flag = true; for (NameValuePair secondaryFilter : secondaryFilters) { if (secondaryFilter != null && !matchPrimaryFilter(entity.getPrimaryFilters(), secondaryFilter) && !matchFilter(entity.getOtherInfo(), secondaryFilter)) { flag = false; break; } } if (!flag) { continue; } } if (entity.getDomainId() == null) { entity.setDomainId(DEFAULT_DOMAIN_ID); } if (checkAcl == null || checkAcl.check(entity)) { entitiesSelected.add(entity); } } List<TimelineEntity> entitiesToReturn = new ArrayList<TimelineEntity>(); for (TimelineEntity entitySelected : entitiesSelected) { entitiesToReturn.add(maskFields(entitySelected, fields)); } Collections.sort(entitiesToReturn); TimelineEntities entitiesWrapper = new TimelineEntities(); entitiesWrapper.setEntities(entitiesToReturn); return entitiesWrapper; }
From source file:com.github.fge.jackson.jsonpointer.JsonPointerTest.java
@DataProvider public Iterator<Object[]> allInstanceTypes() { return SampleNodeProvider.getSamples(EnumSet.allOf(NodeType.class)); }
From source file:fr.ritaly.dungeonmaster.ai.CreatureManager.java
/** * Return the unoccupied sectors.//from ww w . java 2 s .c o m * * @return the set of unoccupied sectors. Never returns null. */ public EnumSet<Sector> getFreeSectors() { return (creatures != null) ? EnumSet.complementOf(getOccupiedSectors()) : EnumSet.allOf(Sector.class); }
From source file:com.linecorp.armeria.common.thrift.text.TTextProtocolTest.java
private TTextProtocolTestMsg testMsg() { return new TTextProtocolTestMsg().setA(12345L).setB(5).setC(sub(1, 10)) .setD(ImmutableList.of(7, 8, 9, 10, 11)) .setE(ImmutableList.of(sub(2, 100), sub(3, 200), sub(4, 300))).setF(true).setG((byte) 12) .setH(ImmutableMap.of(1, 2L, 3, 4L, 5, 6L)) .setJ(ImmutableMap.of((short) 1, ImmutableList.of(true, true, false, true), (short) 5, ImmutableList.of(false))) .setK(ImmutableSet.of(true, false, false, false, true)) .setL(base64Encoder.decode("SGVsbG8gV29ybGQ=")).setM("hello \"spherical\" world!").setN((short) 678) .setP(Letter.CHARLIE).setQ(EnumSet.allOf(Letter.class)).setR(ImmutableMap.of(sub(1, 2), 100L)) .setS(ImmutableMap.of(ImmutableMap.of(ImmutableMap.of(200L, 400L), 300L), 100L)) .setT(ImmutableList.of(Letter.ALPHA, Letter.ALPHA, Letter.CHARLIE, Letter.ALPHA, Letter.CHARLIE, Letter.ECHO))//from ww w. jav a 2 s . com .setU(ImmutableMap.of("foo", Letter.ALPHA, "bar", Letter.DELTA)).setV(Letter.BETA) .setW(TestUnion.f2(4)) .setX(ImmutableList.of(TestUnion.f2(5), TestUnion.f1(base64Encoder.decode("SGVsbG8gV29ybGQ=")))) .setY(Letter.ALPHA); }
From source file:org.ngrinder.user.controller.UserController.java
/** * Get user creation form page.//from w w w . ja va 2 s.com * * @param user current user * @param model mode * @return "user/detail" */ @RequestMapping("/new") @PreAuthorize("hasAnyRole('A') or #user.userId == #userId") public String openForm(User user, final ModelMap model) { User one = User.createNew(); model.addAttribute("user", one); model.addAttribute("allowUserIdChange", true); model.addAttribute("allowPasswordChange", true); model.addAttribute("allowRoleChange", false); model.addAttribute("newUser", true); model.addAttribute("roleSet", EnumSet.allOf(Role.class)); model.addAttribute("showPasswordByDefault", true); attachCommonAttribute(one, model); return "user/detail"; }
From source file:com.devnexus.ting.web.controller.cfp.CallForPapersController.java
private void prepareReferenceData(ModelMap model) { model.addAttribute("maxFileSize", multipartProperties.getMaxFileSize()); final Event currentEvent = businessService.getCurrentEvent(); model.addAttribute("currentEvent", currentEvent); final Set<PresentationType> presentationTypes = EnumSet.allOf(PresentationType.class); model.addAttribute("presentationTypes", presentationTypes); final Set<SkillLevel> skillLevels = EnumSet.allOf(SkillLevel.class); model.addAttribute("skillLevels", skillLevels); }
From source file:org.apache.hadoop.yarn.server.timeline.KeyValueBasedTimelineStore.java
@Override public synchronized TimelineEntities getEntities(String entityType, Long limit, Long windowStart, Long windowEnd, String fromId, Long fromTs, NameValuePair primaryFilter, Collection<NameValuePair> secondaryFilters, EnumSet<Field> fields, CheckAcl checkAcl) throws IOException { if (getServiceStopped()) { LOG.info("Service stopped, return null for the storage"); return null; }//from w w w .j av a2 s .c om if (limit == null) { limit = DEFAULT_LIMIT; } if (windowStart == null) { windowStart = Long.MIN_VALUE; } if (windowEnd == null) { windowEnd = Long.MAX_VALUE; } if (fields == null) { fields = EnumSet.allOf(Field.class); } Iterator<TimelineEntity> entityIterator = null; if (fromId != null) { TimelineEntity firstEntity = entities.get(new EntityIdentifier(fromId, entityType)); if (firstEntity == null) { return new TimelineEntities(); } else { entityIterator = entities.valueSetIterator(firstEntity); } } if (entityIterator == null) { entityIterator = entities.valueSetIterator(); } List<TimelineEntity> entitiesSelected = new ArrayList<TimelineEntity>(); while (entityIterator.hasNext()) { TimelineEntity entity = entityIterator.next(); if (entitiesSelected.size() >= limit) { break; } if (!entity.getEntityType().equals(entityType)) { continue; } if (entity.getStartTime() <= windowStart) { continue; } if (entity.getStartTime() > windowEnd) { continue; } if (fromTs != null && entityInsertTimes .get(new EntityIdentifier(entity.getEntityId(), entity.getEntityType())) > fromTs) { continue; } if (primaryFilter != null && !KeyValueBasedTimelineStoreUtils .matchPrimaryFilter(entity.getPrimaryFilters(), primaryFilter)) { continue; } if (secondaryFilters != null) { // AND logic boolean flag = true; for (NameValuePair secondaryFilter : secondaryFilters) { if (secondaryFilter != null && !KeyValueBasedTimelineStoreUtils.matchPrimaryFilter(entity.getPrimaryFilters(), secondaryFilter) && !KeyValueBasedTimelineStoreUtils.matchFilter(entity.getOtherInfo(), secondaryFilter)) { flag = false; break; } } if (!flag) { continue; } } if (entity.getDomainId() == null) { entity.setDomainId(DEFAULT_DOMAIN_ID); } if (checkAcl == null || checkAcl.check(entity)) { entitiesSelected.add(entity); } } List<TimelineEntity> entitiesToReturn = new ArrayList<TimelineEntity>(); for (TimelineEntity entitySelected : entitiesSelected) { entitiesToReturn.add(KeyValueBasedTimelineStoreUtils.maskFields(entitySelected, fields)); } Collections.sort(entitiesToReturn); TimelineEntities entitiesWrapper = new TimelineEntities(); entitiesWrapper.setEntities(entitiesToReturn); return entitiesWrapper; }
From source file:com.twitter.common.thrift.text.TTextProtocolTest.java
private TTextProtocolTestMsg testMsg() { return new TTextProtocolTestMsg().setA(12345L).setB(5).setC(sub(1, 10)) .setD(ImmutableList.of(7, 8, 9, 10, 11)) .setE(ImmutableList.of(sub(2, 100), sub(3, 200), sub(4, 300))).setF(true).setG((byte) 12) .setH(ImmutableMap.<Integer, Long>of(1, 2L, 3, 4L, 5, 6L)) .setJ(ImmutableMap.<Short, List<Boolean>>of((short) 1, ImmutableList.<Boolean>of(true, true, false, true), (short) 5, ImmutableList.<Boolean>of(false))) .setK(ImmutableSet.of(true, false, false, false, true)) .setL(base64Encoder.decode("SGVsbG8gV29ybGQ=")).setM("hello \"spherical\" world!").setN((short) 678) .setP(Letter.CHARLIE).setQ(EnumSet.allOf(Letter.class)) .setR(ImmutableMap.<Sub, Long>of(sub(1, 2), 100L)) .setS(ImmutableMap.<Map<Map<Long, Long>, Long>, Long>of( ImmutableMap.<Map<Long, Long>, Long>of(ImmutableMap.<Long, Long>of(200L, 400L), 300L), 100L));/*from w w w.j a va 2s . c o m*/ }
From source file:com.sandeep.prototypes.person.PersonApplication.java
@Override public void run(PersonConfiguration configuration, Environment environment) throws Exception { // We need CORS enabled so that swagger can access the documentation endpoint and we can // retrieve the swagger compliant json FilterRegistration.Dynamic cors = environment.servlets().addFilter(CORS_FILTER, CrossOriginFilter.class); cors.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*"); cors.setInitParameter(CrossOriginFilter.ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, "*"); cors.setInitParameter(CrossOriginFilter.ALLOWED_HEADERS_PARAM, CORS_HEADERS); cors.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, CORS_METHODS); cors.setInitParameter("allowCredentials", "true"); environment.jersey().register(new ApiListingResourceJSON()); environment.jersey().register(new ApiDeclarationProvider()); environment.jersey().register(new ResourceListingProvider()); // environment.jersey().register(new PersonResource(configuration.getMessage())); environment.getObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL); BeanConfig config = new BeanConfig(); config.setTitle(configuration.getApplicationTitle()); config.setDescription(configuration.getApplicationDescription()); config.setTermsOfServiceUrl(configuration.getApplicationTosUrl()); config.setContact(configuration.getApplicationContact()); config.setLicense(configuration.getLicense()); config.setVersion(configuration.getVersion()); config.setBasePath(configuration.getDocsPath()); config.setResourcePackage("com.sandeep.prototypes.person.resources"); config.setScan(true);/*from w w w . j a v a2 s . c o m*/ }