List of usage examples for java.util Objects requireNonNull
public static <T> T requireNonNull(T obj)
From source file:io.coala.bind.persist.LocalIdDao.java
public static LocalIdDao find(final EntityManager em, final LocalId id) { final Comparable<?> value = Objects.requireNonNull(id.unwrap()); final LocalIdDao parentRef = id.parentRef().parentRef() == null ? null : find(em, id.parentRef()); final UUID context = Objects.requireNonNull(id.contextRef()); try {/* www. j a v a 2 s .c o m*/ return em .createQuery("SELECT d FROM " + ENTITY_NAME + " d WHERE d.value=?1 AND d.parentRef=?2" + " AND d.contextRef=?3", LocalIdDao.class) .setParameter(1, value).setParameter(2, parentRef).setParameter(3, context).getSingleResult(); } catch (final NoResultException ignore) { return null; } }
From source file:net.sf.jabref.logic.fetcher.SpringerLink.java
@Override public Optional<URL> findFullText(BibEntry entry) throws IOException { Objects.requireNonNull(entry); Optional<URL> pdfLink = Optional.empty(); // Try unique DOI first Optional<DOI> doi = DOI.build(entry.getField("doi")); if (doi.isPresent()) { // Available in catalog? try {/*from w ww. java 2 s.c o m*/ HttpResponse<JsonNode> jsonResponse = Unirest.get(API_URL).queryString("api_key", API_KEY) .queryString("q", String.format("doi:%s", doi.get().getDOI())).asJson(); JSONObject json = jsonResponse.getBody().getObject(); int results = json.getJSONArray("result").getJSONObject(0).getInt("total"); if (results > 0) { LOGGER.info("Fulltext PDF found @ Springer."); pdfLink = Optional.of(new URL("http", CONTENT_HOST, String.format("/content/pdf/%s.pdf", doi.get().getDOI()))); } } catch (UnirestException e) { LOGGER.warn("SpringerLink API request failed", e); } } return pdfLink; }
From source file:net.sf.jabref.logic.journals.JournalAbbreviationRepository.java
public boolean isKnownName(String journalName) { String nameKey = Objects.requireNonNull(journalName).trim().toLowerCase(Locale.ENGLISH); return (fullNameLowerCase2Abbreviation.containsKey(nameKey)) || (isoLowerCase2Abbreviation.containsKey(nameKey)) || (medlineLowerCase2Abbreviation.containsKey(nameKey)); }
From source file:net.maritimecloud.identityregistry.model.database.entities.EntityModel.java
/** Copies this entity into the other * Only update things that are allowed to change on update */ public EntityModel selectiveCopyTo(EntityModel entity) { Objects.requireNonNull(entity); entity.setMrn(mrn);//www. j ava2 s . c o m entity.setPermissions(permissions); return entity; }
From source file:org.eclipse.hono.connection.ConnectionFactoryImpl.java
/** * Sets the Vert.x instance to use.// w w w .j a v a 2s .c o m * * @param vertx The Vert.x instance. * @throws NullPointerException if the instance is {@code null}. */ @Autowired public final void setVertx(final Vertx vertx) { this.vertx = Objects.requireNonNull(vertx); }
From source file:com.buildria.mocking.serializer.JacksonJsonSerializer.java
public JacksonJsonSerializer(ObjectSerializerContext ctx) { this.ctx = Objects.requireNonNull(ctx); }
From source file:org.eclipse.hono.util.SpringBasedExpiringValueCache.java
@Override public void put(K key, V value, Duration maxAge) { Objects.requireNonNull(key); Objects.requireNonNull(value); Objects.requireNonNull(maxAge); put(key, value, Instant.now().plus(maxAge)); }
From source file:net.maritimecloud.identityregistry.model.Device.java
/** Copies this organization into the other */ public Device copyTo(Device device) { Objects.requireNonNull(device); device.setId(id);/*from w w w . j a va2 s . c o m*/ device.setIdOrganization(idOrganization); device.setName(name); device.setDeviceOrgId(deviceOrgId); device.setCertificate(certificates); return device; }
From source file:org.eclipse.hono.authorization.impl.BaseAuthorizationService.java
/** * Sets the global Hono configuration properties. * /* w w w .j av a2 s .c o m*/ * @param props The properties. * @throws NullPointerException if props is {@code null}. */ @Autowired(required = false) public void setHonoConfiguration(final ServiceConfigProperties props) { this.honoConfig = Objects.requireNonNull(props); }
From source file:io.github.moosbusch.lumpi.gui.impl.SelectionAdapter.java
@Override public void setEventSource(Component eventSource) { this.eventSourceRef = new WeakReference<>(Objects.requireNonNull(eventSource)); }