List of usage examples for com.google.common.base Preconditions checkNotNull
public static <T> T checkNotNull(T reference)
From source file:org.apache.james.mdn.fields.Text.java
public static Text fromRawText(String rawText) { Preconditions.checkNotNull(rawText); String trimmedText = rawText.trim(); Preconditions.checkArgument(!trimmedText.isEmpty(), "Text should not be empty"); return new Text(replaceLineBreaksByContinuation(trimmedText)); }
From source file:org.opendaylight.mdsal.model.ietf.util.IpClass.java
public IpClass(final String value) { this._value = Preconditions.checkNotNull(value); }
From source file:com.cloudera.oryx.als.computation.ALSJobStepConfig.java
public static ALSJobStepConfig fromArgsArray(String... args) { Preconditions.checkNotNull(args); Preconditions.checkArgument(args.length >= 5); return new ALSJobStepConfig(args[0], Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3]), Boolean.parseBoolean(args[4])); }
From source file:com.davidbracewell.wordnet.WordNetPOS.java
/** * From string./* w w w .j a v a2 s . c o m*/ * * @param string the string * @return the word net pOS */ public static WordNetPOS fromString(String string) { Preconditions.checkNotNull(string); if (string.equalsIgnoreCase("S")) { return ADJECTIVE; } for (WordNetPOS pos : values()) { if (pos.shortForm.equalsIgnoreCase(string) || pos.tag == Character.toLowerCase(string.charAt(0))) { return pos; } } return WordNetPOS.valueOf(string); }
From source file:org.opendaylight.mdsal.model.ietf.util.MacClass.java
public MacClass(final String value) { this._value = Preconditions.checkNotNull(value); }
From source file:org.cloudifysource.cosmo.orchestrator.workflow.RuoteWorkflow.java
public static RuoteWorkflow createFromResource(String resourceName, RuoteRuntime runtime) { Preconditions.checkNotNull(resourceName); Preconditions.checkNotNull(runtime); try {// w w w .java 2 s . co m final URL url = Resources.getResource(resourceName); final String workflow = Resources.toString(url, Charsets.UTF_8); return new RuoteWorkflow(workflow, runtime); } catch (IOException e) { throw Throwables.propagate(e); } }
From source file:org.opendaylight.ocpplugin.api.ocp.device.Xid.java
public Xid(final Long value) { this.value = Preconditions.checkNotNull(value); }
From source file:com.gradleware.tooling.testing.Combinations.java
/** * Returns all combinations for the given lists. * * @param lists the lists whose elements to combine, must not be null * @return all the combinations, never null *//*from w w w .j a v a 2 s . co m*/ public static ImmutableList<List<Object>> getCombinations(List<?>... lists) { Preconditions.checkNotNull(lists); if (lists.length == 0) { return ImmutableList.of(); } ImmutableMap.Builder<Integer, List<?>> listsMappedByDepth = ImmutableMap.builder(); for (int i = 0; i < lists.length; i++) { listsMappedByDepth.put(i, lists[i]); } return getCombinationsRecursive(listsMappedByDepth.build(), 0, new Object[(lists.length)]); }
From source file:org.ros.internal.message.definition.MessageDefinitionTupleParser.java
/** * Splits the message definition tuple into a {@link List} of message * definitions. Split message definitions may be empty (e.g. std_srvs/Empty). * * @param definition/*from w ww .j a va2 s . co m*/ * the message definition tuple * @param size * the expected tuple size, or -1 to ignore this requirement * @return a {@link List} of the specified size */ public static List<String> parse(String definition, int size) { Preconditions.checkNotNull(definition); List<String> definitions = Lists.newArrayList(); StringBuilder current = new StringBuilder(); for (String line : definition.split("\n")) { if (line.startsWith(SEPARATOR)) { definitions.add(current.toString()); current = new StringBuilder(); continue; } current.append(line); current.append("\n"); } if (current.length() > 0) { current.deleteCharAt(current.length() - 1); } definitions.add(current.toString()); Preconditions.checkState(size == -1 || definitions.size() <= size, String.format("Message tuple exceeds expected size: %d > %d", definitions.size(), size)); while (definitions.size() < size) { definitions.add(""); } return definitions; }
From source file:org.apache.james.mailbox.model.BlobId.java
public static BlobId fromBytes(byte[] bytes) { Preconditions.checkNotNull(bytes); return new BlobId(Hashing.sha256().hashBytes(bytes).toString()); }