List of usage examples for java.util Set isEmpty
boolean isEmpty();
From source file:io.soabase.halva.caseclass.TestValidation.java
@Test public void testValidationPasses() { ParentBean parent = ParentBeanCase(ChildBeanCase("tester", 10)); Set<ConstraintViolation<ParentBean>> violations = validator.validate(parent); Assert.assertTrue(violations.isEmpty()); }
From source file:org.kew.rmf.reconciliation.config.WebAppInitializer.java
private void configureSpringMvc(ServletContext servletContext, WebApplicationContext rootContext) { AnnotationConfigWebApplicationContext mvcContext = new AnnotationConfigWebApplicationContext(); mvcContext.register(MvcConfig.class); mvcContext.setParent(rootContext);/*from w w w. j a va 2 s. c o m*/ ServletRegistration.Dynamic appServlet = servletContext.addServlet("reconciliation-service", new DispatcherServlet(mvcContext)); appServlet.setLoadOnStartup(1); Set<String> mappingConflicts = appServlet.addMapping("/"); if (!mappingConflicts.isEmpty()) { for (String s : mappingConflicts) { log.error("Mapping conflict: " + s); } throw new IllegalStateException("'webservice' cannot be mapped to '/'"); } }
From source file:net.maritimecloud.identityregistry.validators.CertificateRevocationTests.java
@Test public void validateValidCR() { // Set up a CR with valid reason and date CertificateRevocation cr = new CertificateRevocation(); cr.setRevokationReason("certificatehold"); Calendar cal = Calendar.getInstance(); Date now = cal.getTime();/* w w w . j a v a 2 s . c o m*/ cr.setRevokedAt(now); // Try to validate the CR Set<ConstraintViolation<CertificateRevocation>> violations = validator.validate(cr); assertTrue(violations.isEmpty()); }
From source file:net.maritimecloud.identityregistry.validators.UserValidatorTests.java
@Test public void validateValidUser() { User validUser = new User(); validUser.setFirstName("Firstname"); validUser.setLastName("Lastname"); validUser.setEmail("user@test.org"); validUser.setMrn("urn:mrn:mcl:user:testorg:test-user"); Set<ConstraintViolation<User>> violations = validator.validate(validUser); assertTrue(violations.isEmpty()); }
From source file:org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.java
public static void removeFromURISetProperty(final Collection<URI> uris, final String prop, final PropertyContainer container) { if (uris == null || uris.isEmpty() || !container.hasProperty(prop)) { return;/*w ww . j a va2 s.c om*/ } final Set<URI> existing = getURISetProperty(prop, container, null); for (final URI uri : uris) { existing.remove(uri); } if (existing.isEmpty()) { container.removeProperty(prop); } else { container.setProperty(prop, toStringArray(existing)); } }
From source file:io.lavagna.service.BoardColumnRepository.java
public List<BoardColumn> findByIds(Set<Integer> ids) { if (ids.isEmpty()) { return Collections.emptyList(); }//w w w . j a v a 2 s .c o m return queries.findByIds(ids); }
From source file:com.vmware.photon.controller.common.config.ConfigBuilder.java
private void validate() throws BadConfigException { ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); Validator validator = factory.getValidator(); Set<ConstraintViolation<T>> violations = validator.validate(config); if (!violations.isEmpty()) { List<String> errors = new ArrayList<>(); errors.add("Configuration is not valid:"); for (ConstraintViolation<T> violation : violations) { String error = String.format("\t%s %s (was %s)", violation.getPropertyPath(), violation.getMessage(), violation.getInvalidValue()); errors.add(error);/*from www . ja v a 2 s .c o m*/ } throw new BadConfigException(Joiner.on("\n").join(errors)); } }
From source file:gov.nih.nci.indexgen.IndexGenerator.java
public void generate() throws Exception { Set<EntityPersister> classSet = getIndexedClasses(); if (classSet.isEmpty()) { throw new Exception("No classes with @Indexed annotation found."); }//from w w w .ja va2s .c o m for (EntityPersister persister : classSet) { String name = persister.getEntityName(); name = name.substring(name.lastIndexOf('.') + 1); if (classFilter.isEmpty() || (include == classFilter.contains(name))) { long count = getCount(persister); System.out.println(persister.getEntityName() + ": " + count + " records found"); pool.execute(new Indexer(sessionFactory.openSession(), persister)); } } }
From source file:com.ciphertool.genetics.algorithms.mutation.cipherkey.RandomValueMutationAlgorithm.java
/** * Performs a genetic mutation of a random Gene of the supplied Chromosome * /* ww w. ja va 2 s. co m*/ * @param chromosome * the Chromosome to mutate * @param availableIndices * the Set of available indices to mutate */ protected void mutateRandomGene(KeyedChromosome<Object> chromosome, Set<Object> availableIndices) { if (availableIndices == null || availableIndices.isEmpty()) { log.warn( "List of available indices is null or empty. Unable to find a Gene to mutate. Returning null."); return; } Random generator = new Random(); Object[] keys = availableIndices.toArray(); // Get a random map key Object randomKey = keys[generator.nextInt(keys.length)]; // Replace that map value with a randomly generated Gene chromosome.getGenes().put((Object) randomKey, geneDao.findRandomGene(chromosome)); // Remove the key so that it is not used for mutation again availableIndices.remove(randomKey); }
From source file:com.aerofs.baseline.json.ValidatingJacksonJaxbJsonProvider.java
@Override public void writeTo(Object value, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException { Set<ConstraintViolation<Object>> violations = validator.validate(value); if (violations != null && !violations.isEmpty()) { throw new ConstraintViolationException(violations); }// w w w .j a va2 s .c om super.writeTo(value, type, genericType, annotations, mediaType, httpHeaders, entityStream); }