List of usage examples for java.util Objects requireNonNull
public static <T> T requireNonNull(T obj, Supplier<String> messageSupplier)
From source file:com.fizzed.blaze.util.Streamables.java
static public StreamableInput input(File file) { Objects.requireNonNull(file, "file cannot be null"); return input(file.toPath()); }
From source file:com.conwet.silbops.msg.NotifyMsg.java
public NotifyMsg(Notification notification) { super(MessageType.NOTIFY); this.notification = Objects.requireNonNull(notification, "Notification is null"); }
From source file:com.conwet.silbops.msg.SubscribeMsg.java
public SubscribeMsg(Subscription subscription) { super(MessageType.SUBSCRIBE); this.subscription = Objects.requireNonNull(subscription, "Subscription is null"); }
From source file:com.conwet.silbops.model.basic.Attribute.java
/** * Construct an attribute with the given parameters * @param name the name of the attribute * @param type the type of the attribute * @throws IllegalArgumentException if some of the parameters are null *//*from w w w . j a v a 2s. c o m*/ public Attribute(String name, Type type) { this.name = Objects.requireNonNull(name, "Attribute name is null"); this.type = Objects.requireNonNull(type, "Type is null"); }
From source file:fr.landel.utils.commons.exception.ExceptionUtils.java
/** * Throws an exception if the predicate doesn't match * //w w w . j ava2 s . com * <pre> * String key = "test"; * // ... * ExceptionUtils.throwsException(key, StringUils::isNotEmpty, IllegalArgumentException::new, null, "error on key"); * </pre> * * @param object * the object to check * @param predicate * the predicate that validates the object * @param supplier * the exception supplier * @param locale * the message locale (optional) * @param message * the error message (required) * @param arguments * the message arguments * @param <T> * the object type * @param <E> * the exception type * @throws E * if predicate doesn't match */ public static <T, E extends Throwable> void throwsException(final T object, final Predicate<T> predicate, final Function<String, E> supplier, final Locale locale, final String message, final Object... arguments) throws E { Objects.requireNonNull(predicate, "predicate"); Objects.requireNonNull(supplier, "supplier"); Objects.requireNonNull(message, "message"); if (!predicate.test(object)) { throw supplier.apply(StringUtils.format(locale, message, new Object[] { object }, arguments)); } }
From source file:org.elasticsearch.client.Response.java
Response(RequestLine requestLine, HttpHost host, HttpResponse response) { Objects.requireNonNull(requestLine, "requestLine cannot be null"); Objects.requireNonNull(host, "node cannot be null"); Objects.requireNonNull(response, "response cannot be null"); this.requestLine = requestLine; this.host = host; this.response = response; }
From source file:com.netflix.nicobar.core.module.jboss.JBossScriptModule.java
public JBossScriptModule(ModuleId moduleId, Module jbossModule, ScriptArchive sourceArchive) { this.moduleId = Objects.requireNonNull(moduleId, "moduleId"); this.jbossModule = Objects.requireNonNull(jbossModule, "jbossModule"); this.createTime = sourceArchive.getCreateTime(); this.sourceArchive = Objects.requireNonNull(sourceArchive, "sourceArchive"); }
From source file:it.reply.orchestrator.dto.deployment.SlaPlacementPolicy.java
@Override public void setNodes(List<String> nodes) { Objects.requireNonNull(nodes, "nodes list must not be null"); this.nodes = nodes; }
From source file:com.fizzed.blaze.util.Streamables.java
static public StreamableInput input(Path path) { Objects.requireNonNull(path, "path cannot be null"); if (!Files.exists(path)) { throw new FileNotFoundException("Path " + path + " not found"); }//w w w .j a v a 2 s .co m long size; try { size = Files.size(path); } catch (IOException e) { throw new BlazeException(e.getMessage(), e); } return new StreamableInput(new DeferredFileInputStream(path), path.getFileName().toString(), path, size); }
From source file:com.conwet.silbops.msg.AdvertiseMsg.java
public AdvertiseMsg(Advertise advertise, Advertise context) { super(MessageType.ADVERTISE); this.advertise = Objects.requireNonNull(advertise, "Advertise is null"); this.context = Objects.requireNonNull(context, "Context is null"); }