List of usage examples for org.springframework.util Assert noNullElements
public static void noNullElements(@Nullable Collection<?> collection, Supplier<String> messageSupplier)
From source file:com.griddynamics.banshun.ContextParentBean.java
/** * delimiter separated list of Spring-usual resources specifies. classpath*: classpath:, file: * start wildcards are supported.//from w w w .j a va 2 s .com * delimiters are {@link ConfigurableApplicationContext#CONFIG_LOCATION_DELIMITERS} */ public void setConfigLocations(String[] locations) throws Exception { Assert.noNullElements(locations, "Config locations must not be null"); this.configLocations = locations; }
From source file:de.escalon.hypermedia.affordance.Affordance.java
/** * Creates affordance, usually for a pre-expanded uriTemplate. Link header params may be added later. Optional * variables will be stripped before passing it to the underlying link. Use {@link #getUriTemplateComponents()} to * access the base uri, query head, query tail with optional variables etc. * * @param uriTemplate//from w w w . j a va 2s .c om * pre-expanded uri or uritemplate of the affordance * @param actionDescriptors * describing the possible http methods on the affordance * @param rels * describing the link relation type * @see PartialUriTemplate#expand */ public Affordance(PartialUriTemplate uriTemplate, List<ActionDescriptor> actionDescriptors, String... rels) { // Since AffordanceBuilder creates variables for undefined arguments, // we would get a link-template where ControllerLinkBuilder only sees a link. // For compatibility we strip variables deemed to be not required by the actionDescriptors before passing on // the template to the underlying Link. That way the href of an Affordance stays compatible with a Link that // has been created with ControllerLinkBuilder. Only serializers that make use of Affordance will see the // optional variables, too. // They can access the base uri, query etc. via getUriTemplateComponents. super(uriTemplate.stripOptionalVariables(actionDescriptors).toString()); this.partialUriTemplate = uriTemplate; Assert.noNullElements(rels, "null rels are not allowed"); for (String rel : rels) { addRel(rel); if ("self".equals(rel)) { selfRel = true; } } // if any action refers to a collection resource, make the affordance a collection affordance for (ActionDescriptor actionDescriptor : actionDescriptors) { if (Cardinality.COLLECTION == actionDescriptor.getCardinality()) { this.cardinality = Cardinality.COLLECTION; break; } } this.actionDescriptors.addAll(actionDescriptors); }
From source file:com.github.hateoas.forms.affordance.Affordance.java
/** * Creates affordance, usually for a pre-expanded uriTemplate. Link header params may be added later. Optional variables will be * stripped before passing it to the underlying link. Use {@link #getUriTemplateComponents()} to access the base uri, query head, query * tail with optional variables etc.//from ww w . j a v a2 s. c o m * * @param uriTemplate pre-expanded uri or uritemplate of the affordance * @param actionDescriptors describing the possible http methods on the affordance * @param rels describing the link relation type * @see PartialUriTemplate#expand */ public Affordance(final PartialUriTemplate uriTemplate, final List<ActionDescriptor> actionDescriptors, final String... rels) { // Since AffordanceBuilder creates variables for undefined arguments, // we would get a link-template where ControllerLinkBuilder only sees a link. // For compatibility we strip variables deemed to be not required by the actionDescriptors before passing on // the template to the underlying Link. That way the href of an Affordance stays compatible with a Link that // has been created with ControllerLinkBuilder. Only serializers that make use of Affordance will see the // optional variables, too. // They can access the base uri, query etc. via getUriTemplateComponents. super(uriTemplate.stripOptionalVariables(actionDescriptors).toString()); partialUriTemplate = uriTemplate; Assert.noNullElements(rels, "null rels are not allowed"); for (String rel : rels) { addRel(rel); if ("self".equals(rel)) { selfRel = true; } } // if any action refers to a collection resource, make the affordance a collection affordance for (ActionDescriptor actionDescriptor : actionDescriptors) { if (Cardinality.COLLECTION == actionDescriptor.getCardinality()) { cardinality = Cardinality.COLLECTION; break; } } this.actionDescriptors.addAll(actionDescriptors); }
From source file:net.projectmonkey.spring.acl.hbase.repository.HBaseACLRepository.java
/** * Returns the corresponding ACL's mapped by the relevant ObjectIdentity. * ObjectIdentities.identifier objects are required to implement one of the * configured keyRetrievalMethods./* w w w. ja v a 2 s. c o m*/ * * @param objectIdentities which must not be null * @param sids which may be null * @return map of ObjectIdentities against the corresponding ACL objects. * @throws AuthorizationServiceException if no zero argument key retrieval * method returning a byte[] could be located for an identifier * or the located method returned a null key or an unexpected * exception occurred. * */ @Override public Map<ObjectIdentity, Acl> getAclsById(final List<ObjectIdentity> objectIdentities, final List<Sid> sids) { Assert.notNull(objectIdentities, "At least one Object Identity required"); Assert.isTrue(objectIdentities.size() > 0, "At least one Object Identity required"); Assert.noNullElements(objectIdentities.toArray(new ObjectIdentity[0]), "Null object identities are not permitted"); HTableInterface table = getTable(); Map<ObjectIdentity, Acl> toReturn = new HashMap<ObjectIdentity, Acl>(); try { Map<Long, ObjectIdentity> identitiesByByteId = new HashMap<Long, ObjectIdentity>(); List<Get> gets = new ArrayList<Get>(); for (ObjectIdentity identity : objectIdentities) { if (!toReturn.containsKey(identity)) { MutableAcl acl = aclCache.getFromCache(identity); if (acl != null) { toReturn.put(identity, acl); } else { AclRecord aclKey = new AclRecord(identity, resolveConverter(identity)); byte[] key = aclKey.getKey(); Long rowId = createRowId(key); if (!identitiesByByteId.containsKey(rowId)) { gets.add(new Get(key)); identitiesByByteId.put(rowId, identity); } } } } if (!gets.isEmpty()) { Result[] results = table.get(gets); Map<ObjectIdentity, Acl> resultsFromDB = mapResults(sids, identitiesByByteId, results); toReturn.putAll(resultsFromDB); } return toReturn; } catch (IOException e) { throw new AuthorizationServiceException("An unexpected exception occurred", e); } finally { close(table); } }
From source file:de.escalon.hypermedia.spring.Affordance.java
/** * Creates affordance, action descriptors and link header params may be added later. * * @param uriTemplate//from ww w . j a va 2 s . c o m * @param rels */ public Affordance(PartialUriTemplate uriTemplate, List<ActionDescriptor> actionDescriptors, String... rels) { super(uriTemplate.stripOptionalVariables(actionDescriptors)); // keep only required and expanded variables this.uriTemplateComponents = uriTemplate.unexpandedComponents(); Assert.noNullElements(rels, "null rels are not allowed"); for (String rel : rels) { addRel(rel); } this.actionDescriptors.addAll(actionDescriptors); }
From source file:gr.abiss.calipso.service.impl.UserServiceImpl.java
/** * {@inheritDoc}// w w w. ja va2 s . co m */ @Override @Transactional(readOnly = false) public User changePassword(String userNameOrEmail, String oldPassword, String newPassword, String newPasswordConfirm) { // make sure we have all params String[] params = { userNameOrEmail, oldPassword, newPassword, newPasswordConfirm }; Assert.noNullElements(params, "Failed updating user pass: Username/email, old password, new password and new password confirmation must be provided "); // make sure new password and confirm match Assert.isTrue(newPassword.equals(newPasswordConfirm), "Failed updating user pass: New password and new password confirmation must be equal"); // make sure a user matching the credentials is found User u = this.findByCredentials(userNameOrEmail, oldPassword, null); Assert.notNull(u, "Failed updating user pass: A user could not be found with the given credentials"); // update password and return user u.setPassword(newPassword); u.setLastPassWordChangeDate(new Date()); u = this.update(u); return u; }
From source file:org.eclipse.swordfish.internal.core.planner.ScopeFilterStrategy.java
public List<Interceptor> filter(List<Interceptor> interceptors, ReadOnlyRegistry<Interceptor> registry, List<Hint<?>> hints) { Object[] arguments = { interceptors, registry, hints }; Assert.noNullElements(arguments, "Agruments passed to strategy mustn't be null."); List<Interceptor> validInterceptors = new ArrayList<Interceptor>(); Collection<ScopeHint> filteredHints = filterHints(hints); if (LOG.isDebugEnabled()) { LOG.debug("Filtering the interceptors with the followng list of hints: " + filteredHints); }/* w w w. ja v a 2 s . com*/ if (filteredHints.size() != 0) { for (Interceptor interceptor : interceptors) { if (isValidInterceptor(interceptor, registry, filteredHints)) { if (LOG.isDebugEnabled()) { LOG.debug("Adding interceptor " + interceptor + " to the list of valid interceptors."); } validInterceptors.add(interceptor); } else { if (LOG.isDebugEnabled()) { LOG.debug("Dropped interceptor " + interceptor + " from the list of valid interceptors."); } } } } else { if (filteredHints.size() == 0) { LOG.warn("No suitable hints found, skipping filtering."); } } return validInterceptors; }
From source file:org.eclipse.swordfish.internal.resolver.backend.remote.SwordfishRegistryProvider.java
private void checkProperties() { Object[] props = { getRegistryURL(), getProxy(), getWsdlReader() }; Assert.noNullElements(props, "Service registry properties are not initialized."); }
From source file:org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.java
/** * Set the name of the queue(s) to receive messages from. * @param queueName the desired queueName(s) (can not be <code>null</code>) *///w w w .j a v a 2 s .c o m public void setQueueNames(String... queueName) { Assert.noNullElements(queueName, "Queue name(s) cannot be null"); this.queueNames = new CopyOnWriteArrayList<>(Arrays.asList(queueName)); }
From source file:org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.java
/** * Add queue(s) to this container's list of queues. * @param queueNames The queue(s) to add. *//*from w w w .ja v a 2 s . c o m*/ public void addQueueNames(String... queueNames) { Assert.notNull(queueNames, "'queueNames' cannot be null"); Assert.noNullElements(queueNames, "'queueNames' cannot contain null elements"); this.queueNames.addAll(Arrays.asList(queueNames)); }