List of usage examples for java.util Set isEmpty
boolean isEmpty();
From source file:com.stormpath.spring.security.provider.DefaultGroupGrantedAuthorityResolver.java
public void setModes(Set<Mode> modes) { if (modes == null || modes.isEmpty()) { throw new IllegalArgumentException("modes property cannot be null or empty."); }/* w ww . j a va 2 s . c o m*/ this.modes = modes; }
From source file:org.hawkular.apm.api.model.trace.InteractionNode.java
/** * This method determines whether the interaction node is associated with * a multi-consumer communication./*from w ww . ja va2s . c om*/ * * @return Whether interaction relates to multiple consumers */ public boolean multipleConsumers() { // TODO: When HWKAPM-698 implemented, it may no longer be necessary to capture this info Set<Property> props = getProperties(Producer.PROPERTY_PUBLISH); return !props.isEmpty() && props.iterator().next().getValue().equalsIgnoreCase(Boolean.TRUE.toString()); }
From source file:com.streamsets.pipeline.stage.processor.fieldorder.FieldOrderProcessor.java
@Override protected void process(Record record, SingleLaneBatchMaker batchMaker) throws StageException { Set<String> paths = Sets.difference(record.getEscapedFieldPaths(), discardFields); Set<String> missingFields = Sets.difference(fields, paths); if (!missingFields.isEmpty() && config.missingFieldAction == MissingFieldAction.TO_ERROR) { throw new OnRecordErrorException(record, Errors.FIELD_ORDER_001, StringUtils.join(missingFields, ", ")); }/* w ww .jav a2 s . co m*/ Set<String> extraFields = Sets.difference(paths, fields); if (!extraFields.isEmpty() && config.extraFieldAction == ExtraFieldAction.TO_ERROR) { throw new OnRecordErrorException(record, Errors.FIELD_ORDER_002, StringUtils.join(extraFields, ", ")); } switch (config.outputType) { case LIST: orderToList(record); break; case LIST_MAP: orderToListMap(record); break; default: throw new IllegalArgumentException("Unknown output type: " + config.outputType); } batchMaker.addRecord(record); }
From source file:se.uu.it.cs.recsys.constraint.builder.CreditDomainBuilder.java
/** * * @param idSet the set of course ids// ww w .jav a 2s . c om * @return mapping between course credit and course */ public Map<CourseCredit, Set<Integer>> getCreditAndIdSetMappingFor(Set<Integer> idSet) { if (idSet == null || idSet.isEmpty()) { LOGGER.warn("Does not make sense to put null or empty set, right?"); return Collections.EMPTY_MAP; } Map<CourseCredit, Set<Integer>> creditAndIds = new HashMap<>(); this.courseRepository.findByAutoGenIds(idSet).forEach(course -> { checkCourseCreditAndPutToMap(course, creditAndIds); }); return creditAndIds; }
From source file:io.microprofile.showcase.speaker.domain.VenueJavaOne2016Test.java
@Test public void readSpeakers() throws Exception { final ObjectMapper om = new ObjectMapper(); final InputStream is = this.getClass().getResourceAsStream("/speakers.json"); final Set<Speaker> speakers = om.readValue(is, new TypeReference<Set<Speaker>>() { });//from w ww . ja v a 2 s. co m Assert.assertFalse("Failed to get any speakers", speakers.isEmpty()); for (final Speaker speaker : speakers) { Assert.assertNotNull(speaker.getNameLast()); this.log.info(speaker.getNameFirst() + " " + speaker.getNameLast()); } }
From source file:com.bmwcarit.barefoot.markov.StateMemory.java
/** * Updates the state with a state vector which is a set of {@link StateCandidate} objects with * its respective measurement, which is a {@link Sample} object. * * @param vector State vector for update of the state. * @param sample Sample measurement of the state vector. *///from w w w. j a va2s . c o m public void update(Set<C> vector, S sample) { if (vector.isEmpty()) { return; } if (this.time() != null && this.time() > sample.time()) { throw new RuntimeException("out-of-order state update is prohibited"); } this.candidates = vector; this.sample = sample; }
From source file:com.github.javarch.persistence.orm.hibernate.spi.multitenant.CurrentTenantIdentifierFinder.java
@Override public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { String connectionProvidersPackage = env .getProperty(HibernateEnviroment.CURRENT_TENANT_IDENTIFIER_RESOLVER_PACKAGE, ""); LOGGER.debug("Buscando @CurrentTenantIdentifierResolver no pacote {}", connectionProvidersPackage); ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider( false);// www . j av a 2 s .c o m scanner.addIncludeFilter(new AnnotationTypeFilter(CurrentTenantIdentifierResolver.class)); Set<BeanDefinition> beanDefinitions = scanner.findCandidateComponents(connectionProvidersPackage); if (beanDefinitions.isEmpty()) { Set<BeanDefinition> defaultBeanDefinition = scanner .findCandidateComponents("com.github.javarch.persistence.orm.hibernate.spi.multitenant"); registrarBeanDefinitions(registry, defaultBeanDefinition); } else { registrarBeanDefinitions(registry, beanDefinitions); } }
From source file:ch.rasc.extclassgenerator.ModelGenerator.java
private static void createModelBean(ModelBean model, AccessibleObject accessibleObject, OutputConfig outputConfig) {// ww w .j a v a 2 s.co m Class<?> javaType = null; String name = null; Class<?> declaringClass = null; if (accessibleObject instanceof Field) { Field field = (Field) accessibleObject; javaType = field.getType(); name = field.getName(); declaringClass = field.getDeclaringClass(); } else if (accessibleObject instanceof Method) { Method method = (Method) accessibleObject; javaType = method.getReturnType(); if (javaType.equals(Void.TYPE)) { return; } if (method.getName().startsWith("get")) { name = StringUtils.uncapitalize(method.getName().substring(3)); } else if (method.getName().startsWith("is")) { name = StringUtils.uncapitalize(method.getName().substring(2)); } else { name = method.getName(); } declaringClass = method.getDeclaringClass(); } ModelType modelType = null; if (model.isAutodetectTypes()) { for (ModelType mt : ModelType.values()) { if (mt.supports(javaType)) { modelType = mt; break; } } } else { modelType = ModelType.AUTO; } ModelFieldBean modelFieldBean = null; ModelField modelFieldAnnotation = accessibleObject.getAnnotation(ModelField.class); if (modelFieldAnnotation != null) { if (StringUtils.hasText(modelFieldAnnotation.value())) { name = modelFieldAnnotation.value(); } if (StringUtils.hasText(modelFieldAnnotation.customType())) { modelFieldBean = new ModelFieldBean(name, modelFieldAnnotation.customType()); } else { ModelType type = null; if (modelFieldAnnotation.type() != ModelType.NOT_SPECIFIED) { type = modelFieldAnnotation.type(); } else { type = modelType; } modelFieldBean = new ModelFieldBean(name, type); } updateModelFieldBean(modelFieldBean, modelFieldAnnotation); model.addField(modelFieldBean); } else { if (modelType != null) { modelFieldBean = new ModelFieldBean(name, modelType); model.addField(modelFieldBean); } } ModelId modelIdAnnotation = accessibleObject.getAnnotation(ModelId.class); if (modelIdAnnotation != null) { model.setIdProperty(name); } ModelClientId modelClientId = accessibleObject.getAnnotation(ModelClientId.class); if (modelClientId != null) { model.setClientIdProperty(name); model.setClientIdPropertyAddToWriter(modelClientId.configureWriter()); } ModelVersion modelVersion = accessibleObject.getAnnotation(ModelVersion.class); if (modelVersion != null) { model.setVersionProperty(name); } ModelAssociation modelAssociationAnnotation = accessibleObject.getAnnotation(ModelAssociation.class); if (modelAssociationAnnotation != null) { model.addAssociation(AbstractAssociation.createAssociation(modelAssociationAnnotation, model, javaType, declaringClass, name)); } if (modelFieldBean != null && outputConfig.getIncludeValidation() != IncludeValidation.NONE) { Set<ModelValidation> modelValidationAnnotations = AnnotationUtils .getRepeatableAnnotation(accessibleObject, ModelValidations.class, ModelValidation.class); if (!modelValidationAnnotations.isEmpty()) { for (ModelValidation modelValidationAnnotation : modelValidationAnnotations) { AbstractValidation modelValidation = AbstractValidation.createValidation(name, modelValidationAnnotation, outputConfig.getIncludeValidation()); if (modelValidation != null) { model.addValidation(modelValidation); } } } else { Annotation[] fieldAnnotations = accessibleObject.getAnnotations(); for (Annotation fieldAnnotation : fieldAnnotations) { AbstractValidation.addValidationToModel(model, modelFieldBean, fieldAnnotation, outputConfig.getIncludeValidation()); } if (accessibleObject instanceof Field) { PropertyDescriptor pd = BeanUtils.getPropertyDescriptor(declaringClass, name); if (pd != null && pd.getReadMethod() != null) { for (Annotation readMethodAnnotation : pd.getReadMethod().getAnnotations()) { AbstractValidation.addValidationToModel(model, modelFieldBean, readMethodAnnotation, outputConfig.getIncludeValidation()); } } } } } }
From source file:com.techtrip.dynbl.context.config.WebAppinitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { // Setup Context to Accept Annotated Classes on Input (including plain Spring {@code @Component} // Stereotypes in addition to JSR-330 Compliant Classes using {@code javax.inject} AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); //context.setConfigLocation(APP_CONFIG_LOCATION); context.setConfigLocation(APP_CONFIG_LOCATION); /* /*from w w w . ja v a 2 s. c o m*/ * Add a Spring Security Filter using the JEE6 Filter Registration Filter Method from {@code FilterRegistration) that allows filters to be registered * and configured with the specified context */ /* FilterRegistration.Dynamic securityFilter = servletContext.addFilter(ProjectKeyValConsts.SECURITY_FILTER.getKey(), new DelegatingFilterProxy(ProjectKeyValConsts.SECURITY_FILTER.getValue())); securityFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, ProjectConsts.BASE_URL_MAPPING_PATTERN.getValue()); // where the filter will be applied */ // Add a Character Encoding Filter that specifies an encoding for mapped requests FilterRegistration.Dynamic characterEncodingFilter = servletContext.addFilter("characterEncodingFilter", new CharacterEncodingFilter()); characterEncodingFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, ROOT_CONTEXT); // where the filter will be applied characterEncodingFilter.setInitParameter("encoding", "UTF-8"); characterEncodingFilter.setInitParameter("forceEncoding", Boolean.TRUE.toString()); characterEncodingFilter.setAsyncSupported(true); servletContext.addListener(new ContextLoaderListener(context)); servletContext.setInitParameter("defaultHtmlEscape", Boolean.TRUE.toString()); DispatcherServlet servlet = new DispatcherServlet(); // no explicit configuration reference here: everything is configured in the root container for simplicity servlet.setContextConfigLocation(""); /* TMT From JEE 6 API Docs: * Registers the given servlet instance with this ServletContext under the given servletName. * The registered servlet may be further configured via the returned ServletRegistration object. */ ServletRegistration.Dynamic appServlet = servletContext.addServlet(APP_SERVLET, servlet); appServlet.setLoadOnStartup(1); appServlet.setAsyncSupported(true); Set<String> mappingConflicts = appServlet.addMapping("/"); if (!mappingConflicts.isEmpty()) { throw new IllegalStateException(String.format( "The servlet named '%s' cannot be mapped to '/' under Tomcat versions <= 7.0.14", APP_SERVLET)); } // TMT servletContext.addListener(new Log4jConfigListener()); System.out.println("Application inplemented on Spring Version: " + SpringVersion.getVersion()); }
From source file:nl.surfnet.coin.api.oauth.ImplicitGrantExplicitRedirectResolver.java
@Override public String resolveRedirect(String requestedRedirect, ClientDetails client) { Set<String> redirectUris = client.getRegisteredRedirectUri(); boolean implicitGrant = isImplicitGrant(); if ((redirectUris == null || redirectUris.isEmpty()) && implicitGrant) { throw new RedirectMismatchException("A redirect_uri must be configured for implicit grant."); }/*from w ww .java 2 s . com*/ return super.resolveRedirect(requestedRedirect, client); }