List of usage examples for java.util Objects requireNonNull
public static <T> T requireNonNull(T obj)
From source file:com.github.horrorho.liquiddonkey.cloud.client.SnapshotClient.java
SnapshotClient(ResponseHandler<List<ICloud.MBSFile>> mbsFileListHandler, Headers headers) { this.mbsFileListHandler = Objects.requireNonNull(mbsFileListHandler); this.headers = Objects.requireNonNull(headers); }
From source file:fr.landel.utils.commons.builder.EqualsBuilder.java
/** * Test if both {@link Object} returned by the {@code getter} function are * equal using their {@code equals} method. The {@code getter} method is * only applied if both {@link Object} are not {@code null}. The predicate * function is only applied if both values are not {@code null}. * // w w w . j a v a 2 s .c o m * @param lhs * the first object * @param rhs * the second object * @param getter * the function to apply if both objects are not {@code null} * (required, throws a {@link NullPointerException} if * {@code null}) * @param predicate * the function to check, if get parameter are equals (if * {@code null}, use the default {@code equals} method) * @param <T> * the check object type * @param <X> * the sub type * @return the current builder */ public <T, X> EqualsBuilder append(final T lhs, final T rhs, final Function<T, X> getter, final BiPredicate<X, X> predicate) { Objects.requireNonNull(getter); if (!this.isEquals()) { return this; } if (lhs != null && rhs != null) { final X v1 = getter.apply(lhs); final X v2 = getter.apply(rhs); if (predicate != null) { if (v1 != null && v2 != null) { this.setEquals(predicate.test(v1, v2)); } else { // check if both values are null this.setEquals(v1 == v2); } } else { this.append(v1, v2); } } else { this.setEquals(lhs == null && rhs == null); } return this; }
From source file:dk.dma.ais.transform.AisPacketTaggingTransformer.java
/** * Constructor taking policy and the tagging to be used * /*from w w w.ja v a 2s .c o m*/ * @param policy * @param tagging */ public AisPacketTaggingTransformer(Policy policy, AisPacketTags tagging) { Objects.requireNonNull(policy); Objects.requireNonNull(tagging); this.policy = policy; this.tagging = tagging; }
From source file:org.opennms.netmgt.bsm.vaadin.adminpage.BusinessServiceTreeTable.java
public BusinessServiceTreeTable(BusinessServiceManager businessServiceManager) { this.businessServiceManager = Objects.requireNonNull(businessServiceManager); setSizeFull();/* w ww. j a v a 2 s . c o m*/ setContainerDataSource(new BusinessServiceContainer()); // Add the "LINKS" columns addGeneratedColumn("links", new Table.ColumnGenerator() { private static final long serialVersionUID = 7113848887128656685L; @Override public Object generateCell(Table source, Object itemId, Object columnId) { final HorizontalLayout layout = new HorizontalLayout(); final BusinessServiceStateMachine stateMachine = businessServiceManager.getStateMachine(); final BusinessService businessService = getItem(itemId).getBean().getBusinessService(); final Status status = stateMachine.getOperationalStatus(businessService); if (status != null) { // Build the query string final List<BasicNameValuePair> urlParms = Lists.newArrayList( new BasicNameValuePair("focus-vertices", businessService.getId().toString()), new BasicNameValuePair("szl", "1"), new BasicNameValuePair("layout", "Hierarchy Layout"), new BasicNameValuePair("provider", "Business Services")); final String queryString = URLEncodedUtils.format(urlParms, Charset.forName("UTF-8")); // Generate the link final Link link = new Link("View in Topology UI", new ExternalResource(String.format("/opennms/topology?%s", queryString))); link.setIcon(FontAwesome.EXTERNAL_LINK_SQUARE); // This app is typically access in an iframe, so we open the URL in a new window/tab link.setTargetName("_blank"); layout.addComponent(link); layout.setComponentAlignment(link, Alignment.MIDDLE_CENTER); } else { Label label = new Label("N/A"); label.setDescription("Try reloading the daemon and refreshing the table."); label.setWidth(null); layout.addComponent(label); } return layout; } }); // add edit and delete buttons addGeneratedColumn("edit / delete", new Table.ColumnGenerator() { private static final long serialVersionUID = 7113848887128656685L; @Override public Object generateCell(Table source, Object itemId, Object columnId) { HorizontalLayout layout = new HorizontalLayout(); layout.setSpacing(true); Button editButton = new Button("Edit", FontAwesome.PENCIL_SQUARE_O); editButton.setId("editButton-" + getItem(itemId).getBean().getName()); editButton.addClickListener(UIHelper.getCurrent(TransactionAwareUI.class) .wrapInTransactionProxy((Button.ClickListener) event -> { final Long businessServiceId = getItem(itemId).getBean().getBusinessService().getId(); BusinessService businessService = businessServiceManager .getBusinessServiceById(businessServiceId); final BusinessServiceEditWindow window = new BusinessServiceEditWindow(businessService, businessServiceManager); window.addCloseListener(e -> refresh()); getUI().addWindow(window); })); layout.addComponent(editButton); Button deleteButton = new Button("Delete", FontAwesome.TRASH_O); deleteButton.setId("deleteButton-" + getItem(itemId).getBean().getName()); deleteButton.addClickListener((Button.ClickListener) event -> { final Long businessServiceId = getItem(itemId).getBean().getBusinessService().getId(); BusinessService businessService = businessServiceManager .getBusinessServiceById(businessServiceId); if (businessService.getParentServices().isEmpty() && businessService.getChildEdges().isEmpty()) { UIHelper.getCurrent(TransactionAwareUI.class).runInTransaction(() -> { businessServiceManager.getBusinessServiceById(businessServiceId).delete(); refresh(); }); } else { new org.opennms.netmgt.vaadin.core.ConfirmationDialog() .withOkAction((org.opennms.netmgt.vaadin.core.ConfirmationDialog.Action) UIHelper .getCurrent(TransactionAwareUI.class).wrapInTransactionProxy( new org.opennms.netmgt.vaadin.core.ConfirmationDialog.Action() { @Override public void execute( org.opennms.netmgt.vaadin.core.ConfirmationDialog window) { businessServiceManager .getBusinessServiceById(businessServiceId).delete(); refresh(); } })) .withOkLabel("Delete anyway").withCancelLabel("Cancel").withCaption("Warning") .withDescription( "This entry is referencing or is referenced by other Business Services! Do you really want to delete this entry?") .open(); } }); layout.addComponent(deleteButton); return layout; } }); setColumnExpandRatio("name", 5); setColumnExpandRatio("links", 1); setColumnExpandRatio("edit / delete", 1); }
From source file:net.maritimecloud.identityregistry.model.Organization.java
/** Copies this organization into the other. * Only updates OIDC if non-null content is given, skips password and shortname */ public Organization selectiveCopyTo(Organization org) { Objects.requireNonNull(org); org.setName(name);/*from w w w .j av a2 s.c o m*/ org.setEmail(email); org.setUrl(url); org.setCountry(country); org.setLogo(logo); org.setType(type); if (oidcClientName != null) { org.setOidcClientName(oidcClientName); } if (oidcClientSecret != null) { org.setOidcClientSecret(oidcClientSecret); } if (oidcWellKnownUrl != null) { org.setOidcWellKnownUrl(oidcWellKnownUrl); } return org; }
From source file:io.github.moosbusch.lumpi.beans.impl.Options.java
public void put(String key, String value) { preferences.put(key, Objects.requireNonNull(value)); }
From source file:io.github.retz.protocol.data.Job.java
public Job(String appName, String cmd, Properties props, int cpu, int memMB, int gpu, int ports) { this(appName, cmd, props, cpu, memMB); this.gpu = Objects.requireNonNull(gpu); this.ports = ports; }
From source file:com.github.horrorho.inflatabledonkey.cloud.AssetPool.java
public AssetPool(Object lock, AuthorizeAssetsClient authorizeAssets, VoodooChunkEncryptionKeyMapper keyMapper, Set<Asset> assets) { this.lock = Objects.requireNonNull(lock); this.authorizeAssets = Objects.requireNonNull(authorizeAssets); this.keyMapper = Objects.requireNonNull(keyMapper); this.assets = validate(assets); }
From source file:com.github.horrorho.inflatabledonkey.cloud.AuthorizeAssetsClient.java
public AuthorizeAssetsClient(ResponseHandler<FileGroups> responseHandler, String container, String zone) { this.responseHandler = Objects.requireNonNull(responseHandler); this.container = Objects.requireNonNull(container); this.zone = Objects.requireNonNull(zone); }