List of usage examples for org.apache.commons.lang3 Validate noNullElements
public static <T extends Iterable<?>> T noNullElements(final T iterable)
Validate that the specified argument iterable is neither null nor contains any elements that are null ; otherwise throwing an exception.
From source file:co.runrightfast.akka.AkkaUtils.java
/** * Concatenates the path via path separator : '/' * * * @param basePath base path/* ww w . j a v a 2 s.co m*/ * @param path appended to base path * @param paths optional additional paths * @return actor path */ static String actorPath(final String basePath, final String path, final String... paths) { notBlank(basePath, "basePath"); notBlank(path, "path"); if (paths != null) { Validate.noNullElements(paths); } final StringBuilder sb = new StringBuilder(128).append(basePath).append('/').append(path); if (paths != null) { Arrays.stream(paths).forEach(p -> sb.append('/').append(p)); } return sb.toString(); }
From source file:co.runrightfast.commons.utils.ValidationUtils.java
static void noNullElements(final Object[] values) { Validate.noNullElements(values); }
From source file:com.offbynull.voip.kademlia.model.NodeChangeSet.java
static NodeChangeSet added(Node... nodes) { Validate.notNull(nodes); Validate.noNullElements(nodes); return added(Arrays.asList(nodes)); }
From source file:com.offbynull.portmapper.common.ProcessUtils.java
/** * Run a process and dump the stdout stream to a string. * @param timeout maximum amount of time the process can take to run * @param command command/*from w ww . j ava2s .co m*/ * @param args arguments * @return stdout from the process dumped to a string * @throws IOException if the process encounters an error * @throws NullPointerException if any arguments are {@code null} or contains {@code null} * @throws IllegalArgumentException any numeric argument is negative */ public static String runProcessAndDumpOutput(long timeout, String command, String... args) throws IOException { Validate.notNull(command); Validate.noNullElements(args); Validate.inclusiveBetween(0L, Long.MAX_VALUE, timeout); String[] pbCmd = new String[args.length + 1]; pbCmd[0] = command; System.arraycopy(args, 0, pbCmd, 1, args.length); ProcessBuilder builder = new ProcessBuilder(pbCmd); final AtomicBoolean failedFlag = new AtomicBoolean(); Timer timer = new Timer("Process timeout timer", true); Process proc = null; try { proc = builder.start(); final Process finalProc = proc; timer.schedule(new TimerTask() { @Override public void run() { failedFlag.set(true); finalProc.destroy(); } }, timeout); String ret = IOUtils.toString(proc.getInputStream()); if (failedFlag.get()) { throw new IOException("Process failed"); } return ret; } finally { if (proc != null) { proc.destroy(); } timer.cancel(); timer.purge(); } }
From source file:com.offbynull.voip.kademlia.model.NodeChangeSet.java
static NodeChangeSet added(Collection<Node> nodes) { Validate.notNull(nodes);/*w w w. jav a 2 s.c o m*/ Validate.noNullElements(nodes); return new NodeChangeSet(nodes, emptyList(), emptyList()); }
From source file:com.offbynull.voip.kademlia.model.ActivityChangeSet.java
static ActivityChangeSet added(Activity... entries) { Validate.notNull(entries); Validate.noNullElements(entries); return added(Arrays.asList(entries)); }
From source file:com.offbynull.portmapper.pcp.PcpDiscovery.java
/** * Discover PCP-enabled routers./* ww w.j av a 2 s . c o m*/ * @param extraAddresses extra addresses to check * @return a collection of discovered PCP devices * @throws InterruptedException if interrupted * @throws IOException if IO error occurs * @throws NullPointerException if any argument is {@code null} or contains {@code null} */ public static Set<DiscoveredPcpDevice> discover(InetAddress... extraAddresses) throws InterruptedException, IOException { Validate.noNullElements(extraAddresses); Set<InetAddress> gateways = discoverGateways(); gateways.addAll(Arrays.asList(extraAddresses)); Map<InetAddress, InetAddress> localAddressToGatewayMap = discoverLocalAddressesToGateways(gateways); Set<DiscoveredPcpDevice> devices = new HashSet<>(); for (Entry<InetAddress, InetAddress> e : localAddressToGatewayMap.entrySet()) { devices.add(new DiscoveredPcpDevice(e.getKey(), e.getValue())); } return devices; }
From source file:com.offbynull.portmapper.natpmp.NatPmpDiscovery.java
/** * Discover NAT-PMP-enabled routers.// w ww . j av a 2 s.c o m * @param extraAddresses extra addresses to check * @return a collection of discovered PCP devices * @throws InterruptedException if interrupted * @throws IOException if IO error * @throws NullPointerException if any argument is {@code null} or contains {@code null} */ public static Set<DiscoveredNatPmpDevice> discover(InetAddress... extraAddresses) throws InterruptedException, IOException { Validate.noNullElements(extraAddresses); Set<InetAddress> gateways = discoverGateways(); gateways.addAll(Arrays.asList(extraAddresses)); Map<InetAddress, InetAddress> localAddressToGatewayMap = discoverLocalAddressesToGateways(gateways); Set<DiscoveredNatPmpDevice> devices = new HashSet<>(); for (Entry<InetAddress, InetAddress> e : localAddressToGatewayMap.entrySet()) { devices.add(new DiscoveredNatPmpDevice(e.getKey(), e.getValue())); } return devices; }
From source file:com.offbynull.voip.kademlia.model.NodeChangeSet.java
static NodeChangeSet removed(Node... nodes) { Validate.notNull(nodes); Validate.noNullElements(nodes); return removed(Arrays.asList(nodes)); }
From source file:com.offbynull.voip.kademlia.model.ActivityChangeSet.java
static ActivityChangeSet added(Collection<Activity> entries) { Validate.notNull(entries);// www . j av a 2 s .c om Validate.noNullElements(entries); return new ActivityChangeSet(entries, emptyList(), emptyList()); }