List of usage examples for java.util Set isEmpty
boolean isEmpty();
From source file:com.ofalvai.bpinfo.ui.alertlist.AlertListPresenter.java
/** * Returns a new filtered list of Alerts matching the provided set of RouteTypes, and sorted * according to the alert list type (descending/ascending) *///from ww w.j av a2 s . c o m @NonNull private static List<Alert> filterAndSort(@Nullable Set<RouteType> types, @NonNull List<Alert> alerts, @NonNull AlertListType type) { List<Alert> sorted = new ArrayList<>(alerts); // Sort: descending by alert start time Collections.sort(sorted, new Utils.AlertStartTimestampComparator()); if (type == AlertListType.ALERTS_TODAY) { Collections.reverse(sorted); } if (types == null || types.isEmpty()) { return sorted; } List<Alert> filtered = new ArrayList<>(); for (Alert alert : sorted) { for (Route route : alert.getAffectedRoutes()) { if (types.contains(route.getType())) { filtered.add(alert); break; } } } return filtered; }
From source file:com.cloudera.whirr.cm.CmServerClusterInstance.java
public static boolean logCluster(CmServerLog logger, String label, Configuration configuration, CmServerCluster cluster, Set<Instance> instances) throws IOException { if (!instances.isEmpty()) { logger.logOperationInProgressSync(label, "HOST ADDRESSES"); for (Instance instance : instances) { logger.logOperationInProgressSync(label, " " + instance.getId() + "@" + instance.getPublicHostName() + "@" + instance.getPublicIp() + "@" + instance.getPrivateIp()); }/*from ww w . j a va 2s .co m*/ } if (!cluster.getAgents().isEmpty()) { logger.logOperationInProgressSync(label, "HOST SSH"); } SortedSet<String> cmAgentsSorted = new TreeSet<String>(); for (CmServerService cmAgent : cluster.getAgents()) { cmAgentsSorted.add(" ssh -o StrictHostKeyChecking=no -i " + configuration.getString(ClusterSpec.Property.PRIVATE_KEY_FILE.getConfigName()) + " " + configuration.getString(ClusterSpec.Property.CLUSTER_USER.getConfigName()) + "@" + cmAgent.getIp()); } for (String cmAgentSorted : cmAgentsSorted) { logger.logOperationInProgressSync(label, cmAgentSorted); } if (!cluster.getServiceTypes(CmServerServiceType.CLUSTER).isEmpty()) { for (CmServerServiceType type : cluster.getServiceTypes()) { logger.logOperationInProgressSync(label, "CDH " + type.toString() + " SERVICE"); for (CmServerService service : cluster.getServices(type)) { logger.logOperationInProgressSync(label, " " + service.getName() + "@" + service.getIp() + "=" + service.getStatus()); } } } Set<Instance> balancerInstances = new HashSet<Cluster.Instance>(); for (Instance instance : instances) { if (instance.getRoles().contains(CmBalancerHandler.ROLE)) { balancerInstances.add(instance); } } if (!balancerInstances.isEmpty()) { logger.logOperationInProgressSync(label, "BALANCER IMPALA"); for (Instance instance : balancerInstances) { logger.logOperationInProgressSync(label, " impala-shell -i " + instance.getPrivateIp() + ":" + configuration.getString(CmConstants.CONFIG_WHIRR_INTERNAL_PORT_BALANCER_IMPALA)); } } logger.logOperationInProgressSync(label, "CONSOLE MANAGER"); if (cluster.getServer() != null) { logger.logOperationInProgressSync(label, " http://" + cluster.getServer().getHost() + ":" + configuration.getString(CmConstants.CONFIG_WHIRR_INTERNAL_PORT_WEB)); } else { logger.logOperationInProgressSync(label, "NO CM SERVER"); } logger.logOperationInProgressSync(label, "CONSOLE NAVIGATOR"); if (cluster.getServer() != null) { logger.logOperationInProgressSync(label, " http://" + cluster.getServer().getHost() + ":" + configuration.getString(CmConstants.CONFIG_WHIRR_INTERNAL_PORT_NAV)); } else { logger.logOperationInProgressSync(label, "NO NAVIGATOR SERVER"); } logger.logOperationInProgressSync(label, "CONSOLE HUE"); if (cluster.getServiceTypes(CmServerServiceType.HUE) != null) { String hueHost = null; for (Instance instance : instances) { if (instance.getRoles().contains(CmCdhHueServerHandler.ROLE)) { hueHost = instance.getPublicHostName(); break; } } logger.logOperationInProgressSync(label, " http://" + hueHost + ":" + configuration.getString(CmConstants.CONFIG_WHIRR_INTERNAL_PORT_HUE)); } else { logger.logOperationInProgressSync(label, "NO HUE SERVER"); } return !cluster.isEmpty(); }
From source file:gov.nih.nci.caarray.application.translation.geosoft.GeoSoftFileWriterUtil.java
private static void writeOrganism(Set<Source> sources, Set<Sample> samples, Experiment exp, PrintWriter out) { final Set<Organism> all = new TreeSet<Organism>(ENTITY_COMPARATOR); for (final Source source : sources) { addIgnoreNull(all, source.getOrganism()); }/* ww w .jav a 2 s. c om*/ for (final Sample sample : samples) { addIgnoreNull(all, sample.getOrganism()); } if (all.isEmpty()) { all.add(exp.getOrganism()); } for (final Organism o : all) { out.print("!Sample_organism="); out.println(o.getScientificName()); } }
From source file:net.sourceforge.fenixedu.domain.space.SpaceUtils.java
public static Occupation getFirstOccurrenceOfResourceAllocationByClass(final Space space, final Lesson lesson) { for (final Occupation resourceAllocation : space.getOccupationSet()) { if (resourceAllocation instanceof LessonInstanceSpaceOccupation) { final LessonInstanceSpaceOccupation lessonInstanceSpaceOccupation = (LessonInstanceSpaceOccupation) resourceAllocation; final Set<LessonInstance> instancesSet = lessonInstanceSpaceOccupation.getLessonInstancesSet(); if (!instancesSet.isEmpty() && instancesSet.iterator().next().getLesson() == lesson) { return resourceAllocation; }// w w w .j a v a 2 s . c om } } return null; }
From source file:net.sourceforge.fenixedu.domain.space.SpaceUtils.java
public static Occupation getFirstOccurrenceOfResourceAllocationByClass(final Space space, final WrittenEvaluation evaluation) { for (final Occupation resourceAllocation : space.getOccupationSet()) { if (resourceAllocation instanceof WrittenEvaluationSpaceOccupation) { final WrittenEvaluationSpaceOccupation evaluationSpaceOccupation = (WrittenEvaluationSpaceOccupation) resourceAllocation; final Set<WrittenEvaluation> evaluations = evaluationSpaceOccupation.getWrittenEvaluationsSet(); if (!evaluations.isEmpty() && evaluations.iterator().next() == evaluation) { return resourceAllocation; }/*from w w w. ja v a 2 s . c om*/ } } return null; }
From source file:org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils.java
/** * Check if the current user has none of the specified roles. * @param roles a comma-delimited list of role names * @return <code>true</code> if the user is authenticated and has none the roles *///from w ww.ja v a 2 s . com public static boolean ifNotGranted(final String roles) { Collection<GrantedAuthority> inferred = findInferredAuthorities(getPrincipalAuthorities()); Set<String> grantedCopy = retainAll(inferred, parseAuthoritiesString(roles)); return grantedCopy.isEmpty(); }
From source file:org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils.java
/** * Check if the current user has any of the specified roles. * @param roles a comma-delimited list of role names * @return <code>true</code> if the user is authenticated and has any the roles *///from w w w .ja v a 2 s . c om public static boolean ifAnyGranted(final String roles) { Collection<GrantedAuthority> inferred = findInferredAuthorities(getPrincipalAuthorities()); Set<String> grantedCopy = retainAll(inferred, parseAuthoritiesString(roles)); return !grantedCopy.isEmpty(); }
From source file:com.aurel.track.admin.customize.category.filter.parameters.FilterSelectsParametersUtil.java
/** * Get a list of IntegerStringBean for those fields which are parameterized * @param filterSelectsTO//w ww.j ava 2 s . c o m * @return */ public static List<IntegerStringBean> getParameterizedFields(FilterUpperTO filterSelectsTO) { List<IntegerStringBean> result = new LinkedList<IntegerStringBean>(); List<Integer> upperSelectFields = getUpperSelectFields(filterSelectsTO); Set<Integer> fieldIDs = new HashSet<Integer>(); for (Integer fieldID : upperSelectFields) { if (containsParameter(filterSelectsTO.getSelectedValuesForField(fieldID))) { fieldIDs.add(fieldID); } } if (!fieldIDs.isEmpty()) { List<TFieldBean> allFields = FieldBL.loadByFieldIDs(fieldIDs.toArray()); for (TFieldBean fieldBean : allFields) { result.add(new IntegerStringBean(fieldBean.getName(), fieldBean.getObjectID())); } } //PSEUDO FIELDS if (containsParameter(filterSelectsTO.getSelectedConsultantsInformants())) { result.add(new IntegerStringBean("watcher", PSEUDO_FIELDS.CONSULTANT_INFORMNAT_FIELD_ID)); } return result; }
From source file:com.stratio.deep.cassandra.util.CassandraUtils.java
/** * Returns an instance of the Cassandra validator that matches the provided object. * * @param obj the object to use to resolve the cassandra marshaller. * @param <T> the generic object type. * @return an instance of the Cassandra validator that matches the provided object. * @throws com.stratio.deep.commons.exception.DeepGenericException if no validator can be found for the specified object. *//*from w w w.j a va 2 s . c o m*/ public static <T> AbstractType<?> marshallerInstance(T obj) { AbstractType<?> abstractType = null; if (obj != null) { abstractType = MAP_JAVA_TYPE_TO_ABSTRACT_TYPE.get(obj.getClass()); if (obj instanceof UUID) { UUID uuid = (UUID) obj; if (uuid.version() == 1) { abstractType = TimeUUIDType.instance; } else { abstractType = UUIDType.instance; } } if (abstractType == null) { //LIST Case if (List.class.isAssignableFrom(obj.getClass())) { List list = (List) obj; if (!list.isEmpty()) { abstractType = ListType.getInstance(marshallerInstance(list.get(0))); } } // SET Case else if (Set.class.isAssignableFrom(obj.getClass())) { Set set = (Set) obj; if (!set.isEmpty()) { java.util.Iterator i = set.iterator(); Object o = i.next(); abstractType = SetType.getInstance(marshallerInstance(o)); } } // MAP Case else if (Map.class.isAssignableFrom(obj.getClass())) { Set set = ((Map) obj).keySet(); if (!set.isEmpty()) { java.util.Iterator i = set.iterator(); Object o = i.next(); abstractType = MapType.getInstance(marshallerInstance(o), marshallerInstance(((Map) obj).get(o))); } } } } if (abstractType == null) { throw new DeepGenericException("parameter class " + obj.getClass().getCanonicalName() + " does not have a" + " Cassandra marshaller"); } return abstractType; }
From source file:com.netflix.genie.web.controllers.RestControllerIntegrationTestsBase.java
private static String getLinkedResourceExpectedUri(final String entityApi, final String entityId, final Set<String> optionalHalParams, final String linkedEntityType) { final String uriPath = entityApi + "/" + entityId + "/" + linkedEntityType; // Append HAL parameters separately to avoid URI encoding final StringBuilder halParamsStringBuilder = new StringBuilder(); if (optionalHalParams != null && !optionalHalParams.isEmpty()) { halParamsStringBuilder.append("{?").append(StringUtils.join(optionalHalParams, ",")).append("}"); }//from ww w . ja v a 2s .com return uriPath + halParamsStringBuilder.toString(); }