List of usage examples for java.util Objects requireNonNull
public static <T> T requireNonNull(T obj)
From source file:applica.framework.licensing.LicenseManager.java
public void validate() throws InvalidLicenseException { Objects.requireNonNull(user); InputStream in = getClass().getResourceAsStream("/".concat(LICENSE_FILE)); if (in == null) { throw new LicenseException(LICENSE_FILE + " not found"); }/*w w w . ja v a 2s. c o m*/ try { byte[] bytes = IOUtils.toByteArray(in); License license = new License(user, bytes); license.validate(); } catch (IOException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(in); } }
From source file:com.avanza.astrix.dashboard.web.ServiceRegistryController.java
@Autowired public ServiceRegistryController(ServiceRegistryAdministrator serviceRegistryAdmin) { this.serviceRegistryAdmin = Objects.requireNonNull(serviceRegistryAdmin); }
From source file:io.github.moosbusch.lumpi.gui.impl.SelectionAdapter.java
public SelectionAdapter(Component eventSource, T value, Expression expr) { this.eventSourceRef = new WeakReference<>(Objects.requireNonNull(eventSource)); this.data = new Dictionary.Pair<>(expr, new WeakReference<>(Objects.requireNonNull(value))); }
From source file:io.github.moosbusch.lumpi.gui.form.editor.io.spi.ListButtonStoreValueDelegate.java
public ListButtonStoreValueDelegate(FormEditor<T> formEditor) { this.formEditor = Objects.requireNonNull(formEditor); }
From source file:org.eclipse.hono.service.cache.SpringBasedExpiringValueCache.java
@Override public void put(final K key, final V value, final Instant expirationTime) { Objects.requireNonNull(key); Objects.requireNonNull(value); Objects.requireNonNull(expirationTime); if (Instant.now().isBefore(expirationTime)) { final ExpiringValue<V> expiringValue = new BasicExpiringValue<>(value, expirationTime); cache.put(key, expiringValue);//from w ww.ja v a2 s . c om } else { throw new IllegalArgumentException("value is already expired"); } }
From source file:io.github.moosbusch.lumpi.beans.impl.Options.java
public Options(Preferences preferences) { this.preferences = Objects.requireNonNull(preferences); }
From source file:it.unibo.alchemist.language.protelis.datatype.AbstractField.java
/** * Reduce the desired {@link Iterable} using the provided * {@link BinaryOperator}, excluding an element and returning a default * value if the {@link Iterable} is empty or only contains the value to * exclude. If multiple elements to exclude are present in the iterable, * only the first will be discarded./* w w w .j av a2 s .co m*/ * * @param c * the {@link Iterable} * @param op * the {@link BinaryOperator} that selects which element should * be kept * @param exclude * element not to consider (can be null) * @param defaultVal * the value to return if the iterator is empty or only contains * the value to ignore * @param <T> * return type * @return the reduced element * */ protected static <T> T reduce(final Iterable<T> c, final BinaryOperator<T> op, final T exclude, final T defaultVal) { Objects.requireNonNull(c); Objects.requireNonNull(op); boolean filter = exclude != null; T result = null; for (final T el : c) { if (filter && el.equals(exclude)) { filter = false; } else { if (result != null) { result = op.apply(result, el); } else { result = el; } } } if (result == null) { return defaultVal; } else { return result; } }
From source file:com.ait.tooling.server.core.security.SimpleKeyStringSigningProvider.java
@Override public String makeSignature(final String text) { return hmac(Objects.requireNonNull(text)); }
From source file:io.github.moosbusch.lumpi.gui.impl.Expression.java
public Expression(String expression, char separatorChar) { this.separatorChar = Objects.requireNonNull(separatorChar); parseExpression(expression); }
From source file:at.yawk.buycraft.BuycraftApiImpl.java
@Override public InfoResponse info(String port, String onlineMode, String playerLimit, String version) throws IOException { Objects.requireNonNull(port); Objects.requireNonNull(onlineMode); Objects.requireNonNull(playerLimit); Objects.requireNonNull(version); JsonObject object = get("info", new URIBuilder().setParameter("serverPort", port).setParameter("onlineMode", onlineMode) .setParameter("playersMax", playerLimit).setParameter("version", version)); JsonObject payload = object.getAsJsonObject("payload"); return new InfoResponse(payload.get("latestVersion").getAsDouble(), payload.get("latestDownload").getAsString(), payload.get("serverId").getAsInt(), payload.get("serverCurrency").getAsString(), payload.get("serverName").getAsString(), payload.get("serverStore").getAsString(), payload.get("updateUsernameInterval").getAsInt(), payload.get("onlineMode").getAsBoolean()); }