List of usage examples for java.util EnumSet noneOf
public static <E extends Enum<E>> EnumSet<E> noneOf(Class<E> elementType)
From source file:com.github.fge.jsonschema.keyword.digest.helpers.DraftV3TypeKeywordDigester.java
@Override public JsonNode digest(final JsonNode schema) { final ObjectNode ret = FACTORY.objectNode(); final ArrayNode simpleTypes = FACTORY.arrayNode(); ret.put(keyword, simpleTypes);/*from www . j av a2 s . c o m*/ final ArrayNode schemas = FACTORY.arrayNode(); ret.put("schemas", schemas); final JsonNode node = schema.get(keyword); final EnumSet<NodeType> set = EnumSet.noneOf(NodeType.class); if (node.isTextual()) // Single type putType(set, node.textValue()); else { // More than one type, and possibly schemas final int size = node.size(); JsonNode element; for (int index = 0; index < size; index++) { element = node.get(index); if (element.isTextual()) putType(set, element.textValue()); else schemas.add(index); } } /* * If all types are there, no need to collect schemas */ if (EnumSet.complementOf(set).isEmpty()) schemas.removeAll(); /* * Note that as this is an enumset, order is guaranteed */ for (final NodeType type : set) simpleTypes.add(type.toString()); return ret; }
From source file:com.github.fge.jsonschema.keyword.digest.draftv4.DraftV4TypeDigester.java
@Override public JsonNode digest(final JsonNode schema) { final ObjectNode ret = FACTORY.objectNode(); final ArrayNode allowedTypes = FACTORY.arrayNode(); ret.put(keyword, allowedTypes);//www . j av a2 s . c o m final JsonNode node = schema.get(keyword); final EnumSet<NodeType> typeSet = EnumSet.noneOf(NodeType.class); if (node.isTextual()) // Single type typeSet.add(NodeType.fromName(node.textValue())); else // More than one type for (final JsonNode element : node) typeSet.add(NodeType.fromName(element.textValue())); if (typeSet.contains(NodeType.NUMBER)) typeSet.add(NodeType.INTEGER); /* * Note that as this is an enumset, order is guaranteed */ for (final NodeType type : typeSet) allowedTypes.add(type.toString()); return ret; }
From source file:org.midonet.util.process.ProcessHelper.java
public static RunnerConfiguration newProcess(final String commandLine) { return new RunnerConfiguration() { DrainTarget drainTarget;//from ww w .j a v a2s . c om String procCommandLine = commandLine; Map<String, String> envVars = new HashMap<>(); EnumSet<OutputStreams> streamsToLog = EnumSet.allOf(OutputStreams.class); final List<Runnable> exitHandlers = new ArrayList<>(1); @Override public RunnerConfiguration logOutput(Logger log, String marker, OutputStreams... streams) { streamsToLog.clear(); if (streams.length == 0) { streamsToLog = EnumSet.of(OutputStreams.StdOutput); } else { streamsToLog = EnumSet.noneOf(OutputStreams.class); Collections.addAll(streamsToLog, streams); } drainTarget = DrainTargets.slf4jTarget(log, marker); return this; } public RunnerConfiguration setDrainTarget(DrainTarget drainTarget) { this.drainTarget = drainTarget; return this; } @Override public RunnerConfiguration setEnvVariables(Map<String, String> vars) { this.envVars.putAll(vars); return this; } @Override public RunnerConfiguration setEnvVariable(String var, String value) { this.envVars.put(var, value); return this; } @Override public RunnerConfiguration addExitHandler(Runnable handler) { synchronized (exitHandlers) { exitHandlers.add(handler); } return this; } @Override public int runAndWait() { Process p = createProcess(true); String processName = procCommandLine; try { if (p != null) { p.waitFor(); IOUtils.closeQuietly(p.getInputStream()); IOUtils.closeQuietly(p.getErrorStream()); IOUtils.closeQuietly(p.getOutputStream()); if (p.exitValue() == 0) { log.trace("Process \"{}\" exited with code: {}", processName, p.exitValue()); } else { log.debug("Process \"{}\" exited with non zero code: {}", processName, p.exitValue()); } return p.exitValue(); } } catch (InterruptedException e) { log.error(String.format("Error while launching command: \"%s\"", processName), e); } return -1; } public Process run() { return createProcess(false); } @Override public RunnerConfiguration withSudo() { procCommandLine = "sudo " + procCommandLine; return this; } private Process createProcess(boolean wait) { try { final Process process = launchProcess(); if (drainTarget == null) { drainTarget = DrainTargets.noneTarget(); } Runnable exitHandler = new Runnable() { @Override public void run() { try { process.waitFor(); } catch (InterruptedException e) { } synchronized (exitHandlers) { for (Runnable handler : exitHandlers) { handler.run(); } } } }; ProcessOutputDrainer outputDrainer; if (streamsToLog.contains(OutputStreams.StdError)) { outputDrainer = new ProcessOutputDrainer(process, true); } else { outputDrainer = new ProcessOutputDrainer(process); } outputDrainer.drainOutput(drainTarget, wait, exitHandler); return process; } catch (IOException e) { log.error("Error while executing command: \"{}\"", commandLine, e); } return null; } private Process launchProcess() throws IOException { if (envVars.isEmpty()) { return Runtime.getRuntime().exec(procCommandLine); } else { List<String> param = new ArrayList<>(); for (Map.Entry<String, String> var : envVars.entrySet()) { param.add(var.getKey() + "=" + var.getValue()); } return Runtime.getRuntime().exec(procCommandLine, param.toArray(new String[param.size()])); } } }; }
From source file:com.autentia.web.rest.wadl.builder.impl.springframework.SpringMethodContext.java
@Override protected Set<HttpMethod> getHttpMethods() { final Set<HttpMethod> httpMethods = EnumSet.noneOf(HttpMethod.class); for (RequestMethod requestMethod : mappingInfo.getMethodsCondition().getMethods()) { httpMethods.add(HttpMethod.valueOf(requestMethod.name())); }// w w w. j av a 2 s .com return httpMethods; }
From source file:org.apache.sshd.server.shell.ProcessShellFactory.java
public ProcessShellFactory(String[] command) { this(command, EnumSet.noneOf(TtyOptions.class)); }
From source file:org.apereo.portal.xml.stream.IndentingXMLEventWriter.java
public IndentingXMLEventWriter(XMLEventWriter out) { super(out);//from w ww . j a va 2s . c om xmlEventFactory = XMLEventFactory.newFactory(); scopeState.add(EnumSet.noneOf(StackState.class)); }
From source file:com.jxt.web.service.AgentEventServiceImpl.java
@Override public List<AgentEvent> getAgentEvents(String agentId, Range range, int... excludeEventTypeCodes) { if (agentId == null) { throw new NullPointerException("agentId must not be null"); }//from w ww . j a va 2 s . c om final boolean includeEventMessage = false; Set<AgentEventType> excludeEventTypes = EnumSet.noneOf(AgentEventType.class); for (int excludeEventTypeCode : excludeEventTypeCodes) { AgentEventType excludeEventType = AgentEventType.getTypeByCode(excludeEventTypeCode); if (excludeEventType != null) { excludeEventTypes.add(excludeEventType); } } List<AgentEventBo> agentEventBos = this.agentEventDao.getAgentEvents(agentId, range, excludeEventTypes); List<AgentEvent> agentEvents = createAgentEvents(agentEventBos, includeEventMessage); Collections.sort(agentEvents, AgentEvent.EVENT_TIMESTAMP_ASC_COMPARATOR); return agentEvents; }
From source file:org.apache.james.mailbox.model.MailboxACL.java
private static EnumSet<Right> copyOf(Collection<Right> collection) { if (collection.isEmpty()) { return EnumSet.noneOf(Right.class); }/*from w w w .ja v a 2 s. c o m*/ return EnumSet.copyOf(collection); }
From source file:org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidEntityException.java
/** * Constructs a singleton map of violations from given parameters. * * @param entityClass class of invalid entity * @param entityViolationType type of violation found * @param message message to be associated to the violation *///from ww w .j a va 2 s. c om public InvalidEntityException(final Class<?> entityClass, final EntityViolationType entityViolationType, final String message) { super(); this.entityClassSimpleName = entityClass.getSimpleName(); entityViolationType.setMessage(message.trim()); this.violations.put(entityClass, EnumSet.noneOf(EntityViolationType.class)); this.violations.get(entityClass).add(entityViolationType); }
From source file:org.eel.kitchen.jsonschema.validator.ValidationContext.java
/** * Create a validation context with an empty feature set * * @param cache the validator cache to use *///from ww w . ja va 2 s.c om public ValidationContext(final JsonValidatorCache cache) { this(cache, EnumSet.noneOf(ValidationFeature.class)); }