List of usage examples for java.util Objects requireNonNull
public static <T> T requireNonNull(T obj, Supplier<String> messageSupplier)
From source file:it.reply.orchestrator.dto.deployment.SlaPlacementPolicy.java
public void setSlaId(String slaId) { Objects.requireNonNull(slaId, "slaId must not be null"); this.slaId = slaId; }
From source file:com.haulmont.cuba.core.global.EntityLoadInfoBuilder.java
/** * Create a new info instance.//from w w w . java 2 s.c o m * * @param entity entity instance * @param viewName view name, can be null * @return info instance */ public EntityLoadInfo create(Entity entity, @Nullable String viewName) { Objects.requireNonNull(entity, "entity is null"); MetaClass metaClass = metadata.getSession().getClassNN(entity.getClass()); MetaProperty primaryKeyProperty = metadata.getTools().getPrimaryKeyProperty(metaClass); boolean stringKey = primaryKeyProperty != null && primaryKeyProperty.getJavaType().equals(String.class); return new EntityLoadInfo(entity.getId(), metaClass, viewName, stringKey); }
From source file:com.seyren.core.util.velocity.AbstractHelper.java
protected VelocityContext createVelocityContext(Check check, Subscription subscription, List<Alert> alerts) { Objects.requireNonNull(check, "check is null"); VelocityContext result = new VelocityContext(); result.put("CHECK", check); result.put("ALERTS", alerts); result.put("SEYREN_URL", seyrenConfig.getBaseUrl()); result.put("SUBSCRIPTION", subscription); result.put("PREVIEW", getPreviewImage(check)); result.put("JSONMAPPER", MAPPER); return result; }
From source file:com.haulmont.cuba.gui.app.security.session.browse.SessionMessageWindow.java
@Override public void init(Map<String, Object> params) { TO_ALL = messages.getMessage(getClass(), "messageWindow.toAll"); TO_SELECTED = messages.getMessage(getClass(), "messageWindow.toSelected"); allSessions = (Set) params.get("allSessions"); selectedSessions = (Set) params.get("selectedSessions"); Objects.requireNonNull(allSessions, "allSessions window parameter is not set"); Objects.requireNonNull(selectedSessions, "selectedSessions window parameter is not set"); List<String> whomOptions = new ArrayList<>(2); if (!selectedSessions.isEmpty()) { whomOptions.add(TO_SELECTED);// w w w.j a va2 s . c o m } whomOptions.add(TO_ALL); whomOptionsGroup.setOptionsList(whomOptions); if (whomOptions.size() == 1) { whomOptionsGroup.setVisible(false); sendToAllLabel.setValue(TO_ALL); sendToAllLabel.setVisible(true); } whomOptionsGroup.setValue(whomOptions.get(0)); }
From source file:org.elasticsearch.client.sniff.SniffOnFailureListener.java
/** * Sets the {@link Sniffer} instance used to perform sniffing * @throws IllegalStateException if the sniffer was already set, as it can only be set once *//* w ww .j a v a 2s . c o m*/ public void setSniffer(Sniffer sniffer) { Objects.requireNonNull(sniffer, "sniffer must not be null"); if (set.compareAndSet(false, true)) { this.sniffer = sniffer; } else { throw new IllegalStateException("sniffer can only be set once"); } }
From source file:com.github.jrh3k5.habitat4j.rest.CachingAccessTokenProvider.java
/** * Creates a caching access token provider. * // w w w. j av a2 s . c o m * @param sourceProvider * An {@link AccessTokenProvider} used to provision access tokens. */ public CachingAccessTokenProvider(AccessTokenProvider sourceProvider) { this.sourceProvider = Objects.requireNonNull(sourceProvider, "Source token provider cannot be null."); }
From source file:intelligent.wiki.editor.core_impl.sweble.SwebleASTNode.java
public SwebleASTNode(WtNode content, ASTNode parent) { // parent check is unnecessary - recursive initializer would not compile id = new ASTNodeID(); this.node = Objects.requireNonNull(content, "Null WtNode!"); this.parent = parent; }
From source file:com.ejisto.core.classloading.decorator.MockedFieldDecorator.java
public MockedFieldDecorator(MockedFieldImpl target) { Objects.requireNonNull(target, "target field cannot be null"); this.target = target; }
From source file:edu.usu.sdl.openstorefront.security.OpenAmRealm.java
@Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { Objects.requireNonNull(principals, "Principals Required"); OpenAmUser openAmUser = (OpenAmUser) principals.getPrimaryPrincipal(); if (openAmUser != null) { return populateAccount(openAmUser.getTokenId(), openAmUser.getUsername()); } else {// w w w . j av a 2 s. co m log.log(Level.SEVERE, "Unable to get Primary Principle. The primary principal is not set."); return null; } }
From source file:com.bac.accountserviceapp.AccountServiceUserDetailsService.java
@Override public UserDetails loadUserByUsername(String userKey) throws UsernameNotFoundException { Objects.requireNonNull(access, nullAccessorMsg); ///*from www. ja va 2 s . com*/ // Read the User object by secondary key // User user = new SimpleUser(); user.setUserEmail(userKey); user = access.getUserBySecondaryKey(user); if (user == null) { throw new UsernameNotFoundException(String.format(nameNotFoundMsgFormat, userKey)); } // Read User accounts and generate UserDetailsAuthority list Collection<UserDetailsAuthority> userDetailsAuthorities = null; String s = user.getUserName(); Set<? extends Account> accounts = user.getAccounts(); if (accounts == null) { return new AccountServiceUserDetails(user, userDetailsAuthorities); } // // Generate UserDetailsAuthority list // userDetailsAuthorities = new HashSet<>(); for (Account account : accounts) { // // Inactive accounts should be skipped // if (!account.isEnabled()) { continue; } AccountUser accountUser = new SimpleAccountUser(); accountUser.setAccountId(account.getId()); accountUser.setUserId(user.getId()); accountUser = access.getAccountUser(accountUser); // // Inactive user accounts should be skipped // if (!accountUser.isEnabled()) { continue; } Application application = access.getApplication(account.getApplicationId()); // // Inactive application should be skipped // if (!application.isEnabled()) { continue; } // // Populate // AccessLevel accessLevel = access.getAccessLevel(accountUser.getAccessLevelId()); UserDetailsAuthority uda = new UserDetailsAuthority(application, accessLevel); userDetailsAuthorities.add(uda); } // // Create new AccountsServiceUserDetails // return new AccountServiceUserDetails(user, userDetailsAuthorities); }