List of usage examples for org.apache.commons.collections Predicate Predicate
Predicate
From source file:net.sourceforge.fenixedu.domain.Teacher.java
public List<Professorship> getDegreeProfessorshipsByExecutionPeriod(final ExecutionSemester executionSemester) { return (List<Professorship>) CollectionUtils.select(getProfessorships(), new Predicate() { @Override/*from w w w .j ava 2 s . co m*/ public boolean evaluate(Object arg0) { Professorship professorship = (Professorship) arg0; return professorship.getExecutionCourse().getExecutionPeriod() == executionSemester && !professorship.getExecutionCourse().isMasterDegreeDFAOrDEAOnly(); } }); }
From source file:edu.kit.dama.staging.util.DataOrganizationUtils.java
/** * Check if the EXISTS flag is set as attribute of the provided node. * * @param pNode The node to check.// w w w.j a va2s. com * * @return TRUE = EXISTS is set TRUE. */ public static boolean directoryExists(ICollectionNode pNode) { IAttribute attribute = (IAttribute) CollectionUtils.find(pNode.getAttributes(), new Predicate() { @Override public boolean evaluate(Object o) { return ((IAttribute) o).getKey().equals(EXISTS); } }); return (attribute != null && Boolean.parseBoolean(attribute.getValue())); }
From source file:de.tub.citydb.modules.citykml.common.xlink.resolver.DBXlinkSplitter.java
private BuildingSurface CompareGeom(String GmlID) { final String id = GmlID; Predicate predicate = new Predicate() { public boolean evaluate(Object object) { if (((BuildingSurface) object).getPId() != null && ((BuildingSurface) object).getPId().equals(id)) return true; else/* ww w. j a v a 2s . c o m*/ return ((BuildingSurface) object).getId().equals(id); } }; Collection<BuildingSurface> filtered = CollectionUtils.select(list, predicate); return (filtered.size() > 0) ? new ArrayList<BuildingSurface>(filtered).get(0) : null; }
From source file:edu.kit.dama.staging.util.DataOrganizationUtils.java
/** * Check if the TRANSFERRED flag is set as attribute of the provided node. * * @param pNode The node to check./*from w w w . j a va 2 s.co m*/ * * @return TRUE = TRANSFERRED is set TRUE. */ public static boolean isFileTransferred(IFileNode pNode) { IAttribute attribute = (IAttribute) CollectionUtils.find(pNode.getAttributes(), new Predicate() { @Override public boolean evaluate(Object o) { return ((IAttribute) o).getKey().equals(TRANSFERRED); } }); return (attribute != null && Boolean.parseBoolean(attribute.getValue())); }
From source file:com.projity.pm.resource.ResourceImpl.java
public static Predicate instanceofPredicate() { return new Predicate() { public boolean evaluate(Object arg0) { return arg0 instanceof Resource; }// www . j av a2s . c om }; }
From source file:edu.kit.dama.staging.util.DataOrganizationUtils.java
/** * Mark the provided IFileNode as TRANSFERRED. Basically, an attribute * TRANSFERRED with the value 'TRUE' is added. This feature is needed for * the KIT Data Manager data transfer.// w w w . j a v a2 s.c o m * * @param pNode The tree node which should be marked as TRANSFERRED. */ public static void markFileTransferred(IFileNode pNode) { IAttribute attribute = (IAttribute) CollectionUtils.find(pNode.getAttributes(), new Predicate() { @Override public boolean evaluate(Object o) { return ((IAttribute) o).getKey().equals(TRANSFERRED); } }); if (attribute == null) { pNode.addAttribute(new AttributeImpl(TRANSFERRED, Boolean.TRUE.toString())); } else { attribute.setValue(Boolean.TRUE.toString()); } }
From source file:jp.co.opentone.bsol.linkbinder.service.admin.impl.CompanyServiceImpl.java
/** * ?????????????./*from w w w.java2 s . c om*/ * @param id ID * @param users * @throws ServiceAbortException ?????? */ private void validateProjectUserExists(Long id, List<User> users) throws ServiceAbortException { SearchUserCondition condition = new SearchUserCondition(); condition.setProjectId(getCurrentProjectId()); UserDao dao = getDao(UserDao.class); List<ProjectUser> projectUsers = dao.findProjectUser(condition); for (final User u : users) { // ???????? Object ret = CollectionUtils.find(projectUsers, new Predicate() { public boolean evaluate(Object object) { ProjectUser pu = (ProjectUser) object; return u.getEmpNo().equals(pu.getUser().getEmpNo()); } }); if (ret == null) { throw new ServiceAbortException("invalid user", ApplicationMessageCode.CANNOT_PERFORM_BECAUSE_USER_ALREADY_DELETED, u.getLabel()); } } }
From source file:com.kcs.service.impl.GenerateXmlOtherServiceImpl.java
private List<Datasetfxa> filterChildFxa(final Datasetfxa main, List<Datasetfxa> childList) { List<Datasetfxa> result = new ArrayList<Datasetfxa>(); final Predicate predicate = new Predicate() { @Override/*from w w w. j a v a 2s . c om*/ public boolean evaluate(Object o) { if (Utility.isNotNull(o)) { Datasetfxa child = (Datasetfxa) o; boolean result = (objEquals(main.getCustCode(), child.getCustCode()) && objEquals(main.getSeq(), child.getSeq()) && objEquals(main.getSysCode(), child.getSysCode())); return result; } return false; } }; result = (List<Datasetfxa>) CollectionUtils.select(childList, predicate); return result; }
From source file:module.siadap.domain.wrappers.UnitSiadapWrapper.java
public BigDecimal getExcellencyEvaluationPercentage() { int totalPeopleWorkingForUnit = getUnitEmployees(true).size(); Collection<PersonSiadapWrapper> excellentEvaluationPersons = getUnitEmployees(true, new Predicate() { @Override//from w ww. j a v a 2 s.c om public boolean evaluate(Object personObject) { PersonSiadapWrapper personWrapper = (PersonSiadapWrapper) personObject; if (personWrapper.getSiadap() == null || personWrapper.getSiadap().getDefaultSiadapEvaluationUniverse() == null) { return false; } return personWrapper.getSiadap().getDefaultSiadapEvaluationUniverse().hasExcellencyAwarded(); } }); int excellentCount = excellentEvaluationPersons.size(); if ((excellentCount == 0) || (totalPeopleWorkingForUnit == 0)) { return BigDecimal.ZERO; } return new BigDecimal(excellentCount) .divide(new BigDecimal(totalPeopleWorkingForUnit), UnitSiadapWrapper.SCALE, RoundingMode.HALF_EVEN) .multiply(new BigDecimal(100), new MathContext(UnitSiadapWrapper.SCALE)); }
From source file:com.dell.asm.asmcore.asmmanager.util.deployment.ServerFilteringUtil.java
private LogicalNetworkInterface findFirstNIC(LogicalNetworkInterface nic, List<LogicalNetworkInterface> nics) { NicFQDD fqdd = new NicFQDD(nic.getFqdd()); final String nicFqdd1stPort; if (fqdd.getPartition() == null) { nicFqdd1stPort = fqdd.getCardKey() + "-1"; } else {/*from ww w. j a v a 2 s . c o m*/ nicFqdd1stPort = fqdd.getCardKey() + "-1-1"; } return (LogicalNetworkInterface) CollectionUtils.find(nics, new Predicate() { @Override public boolean evaluate(Object object) { return ((LogicalNetworkInterface) object).getFqdd().equals(nicFqdd1stPort); } }); }