List of usage examples for org.apache.commons.collections CollectionUtils exists
public static boolean exists(Collection collection, Predicate predicate)
From source file:com.redhat.rhn.frontend.security.BaseAuthenticationService.java
protected boolean requestRestrictedWhitelist(final HttpServletRequest request) { return CollectionUtils.exists(getRestrictedWhitelistURIs(), new Predicate() { public boolean evaluate(Object uri) { return request.getRequestURI().startsWith(uri.toString()); }// w w w.j av a2 s . c o m }); }
From source file:com.redhat.rhn.domain.monitoring.command.CommandGroup.java
/** * Return <code>true</code> if <code>c</code> is contained in this * group. The comparison is based on command names. * @param c the command to check for//from w ww . j a v a2 s. com * @return <code>true</code> if <code>c</code> is contained in this * group */ public boolean contains(Command c) { if (ALL_GROUP_NAME.equals(getGroupName())) { return true; } return CollectionUtils.exists(getCommands(), new Command.NameEquals(c)); }
From source file:com.michelin.cio.jenkins.plugin.rrod.RequestRenameOrDeletePlugin.java
public void addRequest(final Request request) { boolean alreadyRequested = CollectionUtils.exists(requests, new Predicate() { public boolean evaluate(Object object) { return request.equals(object); }/* www . j a va2 s.c o m*/ }); if (!alreadyRequested) { requests.add(request); persistPendingRequests(); } }
From source file:de.hybris.platform.b2bacceleratorfacades.order.populators.B2BUserGroupEditPermissionsPopulator.java
protected boolean isUserGroupAllowedToEditByCurrentUser(final B2BUserGroupData userGroupToCheck, final List<B2BUserGroupModel> editableUserGroupsForCurrentUser) { return CollectionUtils.exists(editableUserGroupsForCurrentUser, new org.apache.commons.collections.Predicate() { @Override/*from w w w. j a v a2s . c om*/ public boolean evaluate(final Object input) { final B2BUserGroupModel b2BUserGroupModel = (B2BUserGroupModel) input; final String uidToCheck = userGroupToCheck.getUid(); final String editableUid = b2BUserGroupModel.getUid(); return StringUtils.equals(uidToCheck, editableUid); } }); }
From source file:gov.nih.nci.caarray.application.translation.magetab.MageTabTranslationResult.java
/** * Punt organism terms from the cache of translated terms (since they * will be saved as Organism instances instead. *///from w w w . ja v a 2 s .co m void removeOrganismTerms() { for (Iterator<Map.Entry<OntologyTerm, Term>> it = termMap.entrySet().iterator(); it.hasNext();) { Map.Entry<OntologyTerm, Term> termEntry = it.next(); if (CollectionUtils.exists(termEntry.getValue().getCategories(), IsOrganismCategory.INSTANCE)) { it.remove(); } } }
From source file:com.perceptive.epm.perkolcentral.bl.EmployeeBL.java
@Cacheable(cacheName = "EmployeeKeyedByGroupCache", keyGenerator = @KeyGenerator(name = "HashCodeCacheKeyGenerator", properties = @Property(name = "includeMethod", value = "false"))) @Transactional(propagation = Propagation.REQUIRED, readOnly = true, isolation = Isolation.SERIALIZABLE, rollbackFor = ExceptionWrapper.class) public LinkedHashMap<Integer, ArrayList<EmployeeBO>> getAllEmployeesKeyedByGroupId() throws ExceptionWrapper { LinkedHashMap<Integer, ArrayList<EmployeeBO>> employeeBOLinkedHashMap = new LinkedHashMap<Integer, ArrayList<EmployeeBO>>(); Collection<EmployeeBO> employeeBOCollection = this.getAllEmployees().values(); try {/*w ww .ja va 2 s . co m*/ for (Object item : groupsBL.getAllGroups().values()) { final GroupBO groupBO = (GroupBO) item; ArrayList<EmployeeBO> employeeBOArrayList = new ArrayList<EmployeeBO>(employeeBOCollection); CollectionUtils.filter(employeeBOArrayList, new Predicate() { @Override public boolean evaluate(Object o) { return CollectionUtils.exists(((EmployeeBO) o).getGroups(), new Predicate() { @Override public boolean evaluate(Object o) { return ((GroupBO) o).getGroupId().equalsIgnoreCase(groupBO.getGroupId()); } }); } }); employeeBOLinkedHashMap.put(Integer.valueOf(groupBO.getGroupId()), employeeBOArrayList); } } catch (Exception ex) { throw new ExceptionWrapper(ex); } return employeeBOLinkedHashMap; }
From source file:com.ebay.cloud.cms.dal.search.impl.criteria.EqualityCriteriaHandler.java
private boolean evalEq(final List<?> fieldValues, final Object criteriaValue) { Predicate eqPre = new Predicate() { @Override//w w w.j a v a 2 s . co m public boolean evaluate(Object object) { if (criteriaValue instanceof Long && object instanceof Integer) { Long value = Long.valueOf((Integer) object); return criteriaValue.equals(value); } else { return criteriaValue.equals(object); } } }; return CollectionUtils.exists(fieldValues, eqPre); }
From source file:com.perceptive.epm.perkolcentral.businessobject.EmployeeBO.java
public String getSpecificRoleInScrumTeam() { if (CollectionUtils.exists(groups, new Predicate() { @Override//from w w w. j a v a2 s . c om public boolean evaluate(Object o) { return ((GroupBO) o).getGroupId() .equalsIgnoreCase(String.valueOf(GroupEnum.SCRUM_MASTERS.getCode())); } })) { return "SCRUM MASTER"; } if (CollectionUtils.exists(groups, new Predicate() { @Override public boolean evaluate(Object o) { return ((GroupBO) o).getGroupId().equalsIgnoreCase(String.valueOf(GroupEnum.DEV_MANAGER.getCode())); } })) { return "DEVELOPMENT MANAGER"; } if (CollectionUtils.exists(groups, new Predicate() { @Override public boolean evaluate(Object o) { return ((GroupBO) o).getGroupId().equalsIgnoreCase(String.valueOf(GroupEnum.VERTICAL_QA.getCode())); } })) { return "QA"; } if (CollectionUtils.exists(groups, new Predicate() { @Override public boolean evaluate(Object o) { return ((GroupBO) o).getGroupId().equalsIgnoreCase(String.valueOf(GroupEnum.VERTICAL_TW.getCode())); } })) { return "TECH. WRITER"; } if (CollectionUtils.exists(groups, new Predicate() { @Override public boolean evaluate(Object o) { return ((GroupBO) o).getGroupId().equalsIgnoreCase(String.valueOf(GroupEnum.VERTICAL_UX.getCode())); } })) { return "UX"; } if (CollectionUtils.exists(groups, new Predicate() { @Override public boolean evaluate(Object o) { return ((GroupBO) o).getGroupId() .equalsIgnoreCase(String.valueOf(GroupEnum.VERTICAL_DEV.getCode())); } })) { return "DEVELOPMENT"; } return specificRoleInScrumTeam; }
From source file:eionet.cr.web.util.columns.SubjectPredicateColumn.java
/** * @see eionet.cr.web.util.columns.SearchResultColumn#format(java.lang.Object) * * Gets the collection of objects matching to the given predicate in the given subject. Formats the given collection to * comma-separated string. For literal objects, simply the value of the literal will be used. For resource objects, * clickable factsheet links will be created. *///from w w w . ja va 2 s . c o m @Override public String format(Object object) { String result = null; if (object != null && object instanceof SubjectDTO && predicateUri != null) { SubjectDTO subjectDTO = (SubjectDTO) object; Collection<ObjectDTO> objects = subjectDTO.getObjectsForSearchResultsDisplay(predicateUri, getLanguages()); if (predicateUri.equals(Predicates.RDFS_LABEL)) { if (objects.isEmpty()) { Collection<String> rdfTypes = subjectDTO.getObjectValues(Predicates.RDF_TYPE); if (CollectionUtils.isEmpty(rdfTypes) && subjectTypes != null) { rdfTypes = Arrays.asList(subjectTypes); } if (CollectionUtils.exists(rdfTypes, new EqualPredicate(Subjects.DATACUBE_OBSERVATION))) { // If type is DataCube observation, then special handling. result = StringUtils.substringAfter(subjectDTO.getUri(), ScoreboardSparqlDAO.OBSERVATION_URI_PREFIX); if (StringUtils.isBlank(result)) { result = subjectDTO.getUri(); } } else { result = URIUtil.extractURILabel(subjectDTO.getUri(), SubjectDTO.NO_LABEL); } } else { result = objectValuesToCSV(objects); } logger.debug(result); result = buildFactsheetLink(subjectDTO.getUri(), StringEscapeUtils.escapeXml(result), false); } else if (!objects.isEmpty()) { StringBuffer buf = new StringBuffer(); for (ObjectDTO o : objects) { if (buf.length() > 0) { buf.append(", "); } if (o.isLiteral()) { buf.append(o.getValue()); } else { String label = o.getDerviedLiteralValue(); if (label == null) { label = URIUtil.extractURILabel(o.getValue(), SubjectDTO.NO_LABEL); } buf.append(buildFactsheetLink(o.getValue(), StringEscapeUtils.escapeXml(label), true)); } } result = buf.toString(); } } return StringUtils.isBlank(result) ? " " : result; }
From source file:com.ebay.cloud.cms.dal.search.impl.criteria.EqualityCriteriaHandler.java
private boolean evalNotEq(final List<?> fieldValues, final Object criteriaValue) { if (fieldValues == null || fieldValues.isEmpty()) { return true; }// w ww .ja v a 2 s .c o m Predicate notEqPre = new Predicate() { @Override public boolean evaluate(Object object) { if (criteriaValue instanceof Long && object instanceof Integer) { Long value = Long.valueOf((Integer) object); return !criteriaValue.equals(value); } else { return !criteriaValue.equals(object); } } }; return CollectionUtils.exists(fieldValues, notEqPre); }