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.facebook.presto.accumulo.tools.RewriteMetricsTask.java
private void reconfigureIterators(Connector connector, AccumuloTable table) throws Exception { String tableName = table.getIndexTableName() + "_metrics"; LOG.info("Reconfiguring iterators for " + tableName); IteratorSetting sumSetting = connector.tableOperations().getIteratorSetting(tableName, "SummingCombiner", IteratorScope.majc);/*from ww w. j a v a2 s. co m*/ if (sumSetting == null) { sumSetting = connector.tableOperations().getIteratorSetting(tableName, "sum", IteratorScope.majc); } sumSetting.setPriority(21); connector.tableOperations().removeIterator(tableName, "sum", EnumSet.allOf(IteratorScope.class)); connector.tableOperations().removeIterator(tableName, "SummingCombiner", EnumSet.allOf(IteratorScope.class)); connector.tableOperations().attachIterator(tableName, sumSetting); IteratorSetting versSetting = connector.tableOperations().getIteratorSetting(tableName, "vers", IteratorScope.majc); VersioningIterator.setMaxVersions(versSetting, Integer.MAX_VALUE); connector.tableOperations().removeIterator(tableName, versSetting.getName(), EnumSet.allOf(IteratorScope.class)); connector.tableOperations().attachIterator(tableName, versSetting); }
From source file:org.jboss.as.test.integration.logging.handlers.SocketHandlerTestCase.java
@Test public void testUdpSocket() throws Exception { // Create a UDP server and start it try (JsonLogServer server = JsonLogServer.createUdpServer(PORT)) { server.start(DFT_TIMEOUT); final ModelNode socketHandlerAddress = addSocketHandler("test-log-server", null, "UDP"); checkLevelsLogged(server, EnumSet.allOf(Logger.Level.class), "Test UPD all levels."); // Change to only allowing INFO and higher messages executeOperation(Operations.createWriteAttributeOperation(socketHandlerAddress, "level", "INFO")); checkLevelsLogged(server,//ww w . j a v a2 s .co m EnumSet.of(Logger.Level.INFO, Logger.Level.WARN, Logger.Level.ERROR, Logger.Level.FATAL), "Test UDP INFO and higher."); } }
From source file:org.squashtest.tm.web.internal.model.json.JsonChartWizardData.java
private <E extends Enum<E> & Level> void addLevelEnum(String name, Class<E> clazz) { levelEnums.put(name, EnumSet.allOf(clazz)); }
From source file:org.apache.kylin.rest.service.BasicService.java
protected List<CubingJob> listAllCubingJobs(final String cubeName, final String projectName) { return listAllCubingJobs(cubeName, projectName, EnumSet.allOf(ExecutableState.class)); }
From source file:com.baasbox.configuration.PropertiesConfigurationHelper.java
public static String dumpConfigurationSectionAsFlatJson(String section) { Class en = CONFIGURATION_SECTIONS.get(section); try {//w w w .ja va 2 s. c o m JsonFactory jfactory = new JsonFactory(); StringWriter sw = new StringWriter(); String enumDescription = ""; JsonGenerator gen = jfactory.createJsonGenerator(sw); gen.writeStartArray(); 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); boolean isOverridden = (Boolean) (en.getMethod("isOverridden")).invoke(v); String valueDescription = (String) (en.getMethod("getValueDescription")).invoke(v); Class type = (Class) en.getMethod("getType").invoke(v); gen.writeStartObject(); // { gen.writeStringField("key", key); gen.writeStringField("value", valueAsString); gen.writeStringField("description", valueDescription); // ,"description":"description" gen.writeStringField("type", type.getSimpleName()); // ,"type":"type" gen.writeBooleanField("editable", isEditable); gen.writeBooleanField("overridden", isOverridden); gen.writeEndObject(); // } } if (gen.getOutputContext().inArray()) gen.writeEndArray(); // ] 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 "{}"; }
From source file:com.hortonworks.streamline.streams.service.UDFCatalogResource.java
/** * Add a new UDF./*from w w w.j a va 2s . co m*/ * <p> * curl -X POST 'http://localhost:8080/api/v1/catalog/udfs' -F udfJarFile=/tmp/foo-function.jar * -F udfConfig='{"name":"Foo", "description": "testing", "type":"FUNCTION", "className":"com.test.Foo"};type=application/json' * </p> */ @Timed @POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Path("/udfs") public Response addUDF(@FormDataParam("udfJarFile") final InputStream inputStream, @FormDataParam("udfJarFile") final FormDataContentDisposition contentDispositionHeader, @FormDataParam("udfConfig") final FormDataBodyPart udfConfig, @FormDataParam("builtin") final boolean builtin, @Context SecurityContext securityContext) throws Exception { SecurityUtil.checkRole(authorizer, securityContext, Roles.ROLE_UDF_ADMIN); MediaType mediaType = udfConfig.getMediaType(); LOG.debug("Media type {}", mediaType); if (!mediaType.equals(MediaType.APPLICATION_JSON_TYPE)) { throw new UnsupportedMediaTypeException(mediaType.toString()); } UDF udf = udfConfig.getValueAs(UDF.class); processUdf(inputStream, udf, true, builtin); UDF createdUdf = catalogService.addUDF(udf); SecurityUtil.addAcl(authorizer, securityContext, UDF.NAMESPACE, createdUdf.getId(), EnumSet.allOf(Permission.class)); return WSUtils.respondEntity(createdUdf, CREATED); }
From source file:com.gtwm.pb.servlets.AppController.java
/** * Optionally return application/xml or other content rather than the * default text/html//ww w .j a v a 2s .c om * * This can be useful when using AJAX interfaces with XMLHttpRequest in the * browser */ public static ResponseReturnType setReturnType(HttpServletRequest request, HttpServletResponse response, List<FileItem> multipartItems) { String returnType = ServletUtilMethods.getParameter(request, "returntype", multipartItems); ResponseReturnType responseReturnType = null; if (returnType != null) { try { responseReturnType = ResponseReturnType.valueOf(returnType.toUpperCase()); response.setContentType(responseReturnType.getResponseType()); if (responseReturnType.equals(ResponseReturnType.DOWNLOAD)) { String filename = ServletUtilMethods.getParameter(request, "returnfilename", multipartItems); response.setHeader("Content-Disposition", "attachment;filename=\"" + filename + "\""); } } catch (IllegalArgumentException iaex) { EnumSet<ResponseReturnType> allReturnTypes = EnumSet.allOf(ResponseReturnType.class); ServletUtilMethods.logException(iaex, request, "Unknown returntype specified: " + returnType + " - must be one of " + allReturnTypes); } } return responseReturnType; }
From source file:com.omertron.themoviedbapi.tools.MethodSub.java
/** * Convert a string into an Enum type/*from www .jav a2 s.c om*/ * * @param value * @return */ public static MethodSub fromString(String value) { if (StringUtils.isNotBlank(value)) { for (final MethodSub method : EnumSet.allOf(MethodSub.class)) { if (value.equalsIgnoreCase(method.value)) { return method; } } } // We've not found the type! throw new IllegalArgumentException("Method '" + value + "' not recognised"); }
From source file:org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryManagerOnTimelineStore.java
@Override public ContainerReport getContainer(ContainerId containerId) throws YarnException, IOException { ApplicationReportExt app = getApplication(containerId.getApplicationAttemptId().getApplicationId(), ApplicationReportField.USER_AND_ACLS); checkAccess(app);//from w ww .j a va2s . c o m TimelineEntity entity = timelineDataManager.getEntity(ContainerMetricsConstants.ENTITY_TYPE, containerId.toString(), EnumSet.allOf(Field.class), UserGroupInformation.getLoginUser()); if (entity == null) { throw new ContainerNotFoundException( "The entity for container " + containerId + " doesn't exist in the timeline store"); } else { return convertToContainerReport(entity, serverHttpAddress, app.appReport.getUser()); } }
From source file:com.rjuarez.webapp.tools.TheMovieDatabaseQueries.java
public static TheMovieDatabaseQueries fromString(final String value) { if (StringUtils.isNotBlank(value)) { for (final TheMovieDatabaseQueries param : EnumSet.allOf(TheMovieDatabaseQueries.class)) { if (value.equalsIgnoreCase(param.value)) { return param; }/*from w w w . j a v a 2s . c o m*/ } } // We've not found the type! throw new IllegalArgumentException("Value '" + value + "' not recognised"); }