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.dal.unity.Config.java
public Set<TestType> getTestTypes() { Set<TestType> result = EnumSet.allOf(TestType.class); if (!maxTests) { result.remove(TestType.Max);//from www . j av a2 s. c o m } if (!minTests) { result.remove(TestType.Min); } if (!nullTests) { result.remove(TestType.Nulls); } return result; }
From source file:SheetResourcesIT.java
public void testCreateSheetInWorkspaceFromTemplate() throws SmartsheetException, IOException { Sheet sheet = new Sheet.CreateFromTemplateOrSheetBuilder().setFromId(newSheetHome.getId()) .setName("New test sheet in workspace from template").build(); Sheet newSheetFromTemplate = smartsheet.sheetResources().createSheetInWorkspaceFromTemplate( workspace.getId(), sheet, EnumSet.allOf(SheetTemplateInclusion.class)); if (newSheetFromTemplate.getId().toString().isEmpty() || newSheetFromTemplate.getAccessLevel() != AccessLevel.OWNER || newSheetFromTemplate.getPermalink().toString().isEmpty()) { fail("Sheet not correctly copied"); }//from w w w . ja v a 2s . c o m }
From source file:org.apache.hadoop.yarn.server.applicationhistoryservice.timeline.HBaseTimelineStore.java
@Override public TimelineEntities getEntities(String entityType, Long limit, Long starttime, Long endtime, String fromId, Long fromTs, NameValuePair primaryFilter, Collection<NameValuePair> secondaryFilters, EnumSet<Field> fieldsToRetrieve) throws IOException { //TODO: fromId and fromTs not implemented if (endtime == null) { // if end time is null, place no restriction on end time endtime = Long.MAX_VALUE; }//from w w w . ja va2 s .com // using end time, construct a first key that will be seeked to byte[] firstRow = HBaseTimelineStoreUtil.createEntityStartOrEndRow(entityType, writeReverseOrderedLong(endtime)); byte[] lastRow = HBaseTimelineStoreUtil.createEntityTypeEndRow(entityType); if (starttime != null) { // if start time is not null, set a last key that will not be // iterated past lastRow = HBaseTimelineStoreUtil.createEntityStartOrEndRow(entityType, writeReverseOrderedLong(starttime)); } if (limit == null) { // if limit is not specified, use the default limit = DEFAULT_LIMIT; } int entityOffset = 0; HTableInterface table = null; ResultScanner rs = null; try { if (primaryFilter == null) { table = getTable(ENTITY_TABLE); } else { table = getTable(INDEX_TABLE); entityOffset = firstRow.length; firstRow = HBaseTimelineStoreUtil.createIndexRow(primaryFilter.getName(), primaryFilter.getValue(), firstRow); entityOffset = firstRow.length - entityOffset; lastRow = HBaseTimelineStoreUtil.createIndexRow(primaryFilter.getName(), primaryFilter.getValue(), lastRow); } Scan scan = new Scan(firstRow, lastRow); if (fieldsToRetrieve == null) { fieldsToRetrieve = EnumSet.allOf(Field.class); } if (fieldsToRetrieve.contains(Field.EVENTS) || fieldsToRetrieve.contains(Field.LAST_EVENT_ONLY)) { scan.addFamily(EVENTS_COLUMN); } if (fieldsToRetrieve.contains(Field.RELATED_ENTITIES)) { scan.addFamily(RELATED_ENTITIES_COLUMN); } if (secondaryFilters != null || fieldsToRetrieve.contains(Field.PRIMARY_FILTERS)) { scan.addFamily(PRIMARY_FILTERS_COLUMN); } if (secondaryFilters != null || fieldsToRetrieve.contains(Field.OTHER_INFO)) { scan.addFamily(OTHER_INFO_COLUMN); } /* //TODO: server-side filtering not implemented if (secondaryFilters != null) { FilterList filterList = null; if (secondaryFilters.size() == 1) { for (NameValuePair filter : secondaryFilters) { filterList = buildFilter(filter); } } else { filterList = new FilterList(Operator.MUST_PASS_ALL); for (NameValuePair filter : secondaryFilters) { filterList.addFilter(buildFilter(filter)); } } System.out.println("filter list "+filterList); scan.setFilter(filterList); } */ TimelineEntities entities = new TimelineEntities(); rs = table.getScanner(scan); for (Result result = rs.next(); result != null; result = rs.next()) { byte[] row = result.getRow(); TimelineEntity entity = HBaseTimelineStoreUtil.parseEntityRow(row, entityOffset, row.length - entityOffset); if (getEntityFromResult(entity, result, fieldsToRetrieve)) { //TODO: remove client-side filtering once server-side is working // determine if the retrieved entity matches the provided secondary // filters, and if so add it to the list of entities to return boolean filterPassed = true; if (secondaryFilters != null) { for (NameValuePair filter : secondaryFilters) { // check other info for filtered field Object v = entity.getOtherInfo().get(filter.getName()); if (v == null) { // if field is not found in other info, check in primary filters Set<Object> vs = entity.getPrimaryFilters().get(filter.getName()); if (vs == null || !vs.contains(filter.getValue())) { // if field is not found in primary filters, or if it is found // with a different value, do not return the entity filterPassed = false; break; } } else if (!v.equals(filter.getValue())) { // if field is found in other info with a different value, // do not return the entity filterPassed = false; break; } } } if (filterPassed) { entities.addEntity(entity); } } if (entities.getEntities().size() >= limit) { break; } } return entities; } finally { IOUtils.cleanup(LOG, rs, table); } }
From source file:com.smartsheet.api.internal.SheetResourcesImplTest.java
@Test public void testCreateSheetInFolderFromTemplate() throws SmartsheetException, IOException { server.setResponseBody(new File("src/test/resources/createSheetFromExisting.json")); Sheet sheet = new Sheet(); sheet.setFromId(2906571706525572L);/*from w ww. ja v a 2s .c o m*/ Sheet newSheet = sheetResource.createSheetInFolderFromTemplate(1234L, sheet, EnumSet.allOf(SheetTemplateInclusion.class)); if (newSheet.getId().toString().isEmpty() || newSheet.getAccessLevel() != AccessLevel.OWNER || newSheet.getPermalink().toString().isEmpty()) { fail("Sheet not correctly copied"); } newSheet = sheetResource.createSheetInFolderFromTemplate(1234L, sheet, null); }
From source file:com.gtwm.pb.servlets.AppController.java
public static void carryOutSessionActions(HttpServletRequest request, SessionDataInfo sessionData, DatabaseInfo databaseDefn, Context context, HttpSession session, List<FileItem> multipartItems) throws SQLException, AgileBaseException { // Set any new values for the session variables before carrying out main // app actions EnumSet<SessionAction> sessionActions = EnumSet.allOf(SessionAction.class); for (SessionAction sessionAction : sessionActions) { String sessionActionParam = request.getParameter(sessionAction.toString().toLowerCase()); if (sessionActionParam != null) { switch (sessionAction) { case PRESET_ROW_ID: ServletSessionMethods.setRowId(sessionData, request, sessionActionParam, databaseDefn, sessionAction);/*from w w w. j av a2s. co m*/ break; case SET_TABLE: ServletSessionMethods.setTable(sessionData, request, sessionActionParam, databaseDefn); break; case SET_REPORT: ServletSessionMethods.setReport(request, sessionData, sessionActionParam, databaseDefn); break; case SET_ROW_ID: ServletSessionMethods.setRowId(sessionData, request, sessionActionParam, databaseDefn, sessionAction); break; case SET_REPORT_ROW_LIMIT: sessionData.setReportRowLimit(Integer.parseInt(sessionActionParam)); break; case SET_REPORT_FILTER_VALUE: ServletSessionMethods.setReportFilterValue(sessionData, request, databaseDefn); break; case CLEAR_ALL_REPORT_FILTER_VALUES: ServletSessionMethods.clearAllReportFilterValues(sessionData); break; case SET_GLOBAL_REPORT_FILTER_STRING: ServletSessionMethods.setReportGlobalFilterString(sessionData, request, databaseDefn); break; case SET_REPORT_SORT: ServletSessionMethods.setReportSort(sessionData, request, databaseDefn); break; case CLEAR_REPORT_SORT: ServletSessionMethods.clearReportSort(sessionData, request, databaseDefn); break; case CLEAR_ALL_REPORT_SORTS: ServletSessionMethods.clearAllReportSorts(sessionData); break; case SET_USER: ServletSessionMethods.setUser(sessionData, request, sessionActionParam, databaseDefn); break; case SET_ROLE: AppRoleInfo role = databaseDefn.getAuthManager().getRoleByInternalName(sessionActionParam); sessionData.setRole(role); break; case SET_CONTEXT: SessionContext sessionContext = SessionContext.valueOf(sessionActionParam.toUpperCase()); sessionData.setContext(sessionContext); break; case SET_CUSTOM_VARIABLE: case SET_CUSTOM_STRING: // SET_CUSTOM_VARIABLE is deprecated in favour of // SET_CUSTOM_STRING ServletSessionMethods.setCustomString(sessionData, request); break; case SET_CUSTOM_INTEGER: ServletSessionMethods.setCustomInteger(sessionData, request); break; case SET_CUSTOM_LONG: ServletSessionMethods.setCustomLong(sessionData, request); break; case SET_CUSTOM_BOOLEAN: ServletSessionMethods.setCustomBoolean(sessionData, request); break; case SET_CUSTOM_TABLE: ServletSessionMethods.setCustomTable(sessionData, request, true, databaseDefn); break; case SET_CUSTOM_REPORT: ServletSessionMethods.setCustomReport(sessionData, request, true, databaseDefn); break; case SET_CUSTOM_FIELD: ServletSessionMethods.setCustomField(sessionData, request, databaseDefn); break; case CLEAR_CUSTOM_VARIABLE: sessionData.clearCustomVariable(sessionActionParam); break; case SET_MODULE: ServletSessionMethods.setModule(sessionData, request, sessionActionParam, databaseDefn); break; case SET_LOCK_OVERRIDE: ServletSessionMethods.setLockOverride(sessionData, request, databaseDefn); break; case LOGOUT: logout(request); break; } } } }
From source file:com.srotya.tau.api.ApplicationManager.java
@Override public void run(AppConfig configuration, Environment environment) throws Exception { this.configuration = configuration; init(configuration);/*from www. j av a 2 s .co m*/ environment.jersey().property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, false); environment.jersey().register(ValidationFeature.class); if (configuration.isEnableAuthorization()) { environment.jersey().register(new BapiAuthorizationFilter()); environment.jersey().register(RolesAllowedDynamicFeature.class); } configureIgnite(configuration, environment); perfMonitor = new PerformanceMonitor(this); environment.lifecycle().manage(perfMonitor); alertReceiver = new EventViewer(this); environment.lifecycle().manage(alertReceiver); environment.jersey().register(new RulesEndpoint(this)); environment.jersey().register(new RuleGroupEndpoint(this)); environment.jersey().register(new TemplateEndpoint(this)); environment.jersey().register(new RestReceiver(this)); environment.jersey().register(new PerfMonEndpoint(this)); environment.healthChecks().register("dbHC", new DBHealthCheck(this)); FilterRegistration.Dynamic cors = environment.servlets().addFilter("CORS", CrossOriginFilter.class); // Configure CORS parameters cors.setInitParameter("allowedOrigins", "*"); cors.setInitParameter("allowedHeaders", "X-Requested-With,Content-Type,Accept,Origin"); cors.setInitParameter("allowedMethods", "OPTIONS,GET,PUT,POST,DELETE,HEAD"); // Add URL mapping cors.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*"); }
From source file:jat.core.ephemeris.DE405Plus.java
public void update_posvel_and_frame(Time t) throws IOException { update_planetary_ephemeris(t);/*from w ww . ja v a 2 s . com*/ // Default frame is ICRF for (body q : EnumSet.allOf(body.class)) { int bodyNumber = q.ordinal(); posUserFrame[bodyNumber] = posICRF[bodyNumber]; velUserFrame[bodyNumber] = velICRF[bodyNumber]; // System.out.println("[DE405Plus bodyNumber]" + bodyNumber); } // transform pos and vel to desired reference frame switch (ephFrame) { case ICRF: break; case HEE: ReferenceFrame.ICRFtoHEE(this); break; case ECI: ReferenceFrame.ICRFtoECI(this); break; case MEOP: ReferenceFrame.ICRFtoMEOP(this); break; default: // posUserFrame[bodyNumber] = posICRF[bodyNumber]; // velUserFrame[bodyNumber] = velICRF[bodyNumber]; break; } }
From source file:nl.strohalm.cyclos.services.elements.BrokeringServiceImpl.java
@Override public Collection<Status> listPossibleStatuses(BrokerGroup brokerGroup) { brokerGroup = fetchService.fetch(brokerGroup, BrokerGroup.Relationships.POSSIBLE_INITIAL_GROUPS); boolean hasInactive = false; Collection<MemberGroup> possibleInitialGroups = brokerGroup.getPossibleInitialGroups(); for (MemberGroup group : possibleInitialGroups) { if (!group.isActive()) { hasInactive = true;//from w ww .ja v a 2 s.c om break; } } return hasInactive ? EnumSet.allOf(BrokeringQuery.Status.class) : EnumSet.complementOf(EnumSet.of(BrokeringQuery.Status.PENDING)); }
From source file:org.apache.stanbol.enhancer.nlp.model.AnalysedTextTest.java
@Test public void testAnalysedTextaddSpanMethods() { Collection<Span> spans = new HashSet<Span>(); //add some span of different types spans.add(at.addToken(4, 11));//from ww w . j av a 2s .c o m spans.add(at.addChunk(4, 19)); spans.add(at.addSentence(0, 91)); Set<Span> atSpans = AnalysedTextUtils.asSet(at.getEnclosed(EnumSet.allOf(SpanTypeEnum.class))); Assert.assertTrue(spans.containsAll(atSpans)); Assert.assertTrue(atSpans.containsAll(spans)); }
From source file:org.syphr.prom.PropertiesManagerTest.java
@Test public void testKeySet() { Assert.assertTrue("Default keys were not discovered properly", test1Manager.keySet().containsAll(EnumSet.allOf(Key1.class))); }