/** * @see java.lang.Object#toString() */ public String toString() { return new StringBuffer().append("[SortParam property=").append(getProperty()).append( " ascending=").append(asc).append("]").toString(); } }
private void sortList(final List<FFPAccountingDO> list) { final SortParam<String> sp = getSort(); if (sp != null && "NOSORT".equals(sp.getProperty()) == false) { if (this.sortParam != null && StringUtils.equals(this.sortParam.getProperty(), sp.getProperty()) == false) { this.secondSortParam = this.sortParam; } final Comparator<FFPAccountingDO> comp = getComparator(sp, secondSortParam); Collections.sort(list, comp); } this.sortParam = sp; }
protected Property<T> getProperty(SortParam<?> sort) { if (sort == null || sort.getProperty() == null) return null; for (Property<T> property : getProperties()) { if (sort.getProperty().equals(property.getName())) { return property; } } return null; } /**
@Override public Comparable<?> apply(T input) { return comparableValue(input, sortParam.getProperty()); } });
/** * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object rhs) { if (rhs instanceof SortParam) { SortParam param = (SortParam)rhs; return getProperty().equals(param.getProperty()) && isAscending() == param.isAscending(); } return false; }
protected Comparator<T> getComparator(final SortParam<String> sortParam, final SortParam<String> secondSortParam) { final String sortProperty = sortParam != null ? sortParam.getProperty() : null; final boolean ascending = sortParam != null ? sortParam.isAscending() : true; final String secondSortProperty = secondSortParam != null ? secondSortParam.getProperty() : null; final boolean secondAscending = secondSortParam != null ? secondSortParam.isAscending() : true; return new MyBeanComparator<T>(sortProperty, ascending, secondSortProperty, secondAscending); }
protected Comparator<VacationDO> getComparator(final SortParam<String> sortParam, final SortParam<String> secondSortParam) { final String sortProperty = sortParam != null ? sortParam.getProperty() : null; final boolean ascending = sortParam != null ? sortParam.isAscending() : true; final String secondSortProperty = secondSortParam != null ? secondSortParam.getProperty() : null; final boolean secondAscending = secondSortParam != null ? secondSortParam.isAscending() : true; return new MyBeanComparator<VacationDO>(sortProperty, ascending, secondSortProperty, secondAscending); }
@Override public SortOrder getPropertySortOrder(final T property) { Args.notNull(property, "property"); if ((param == null) || (param.getProperty().equals(property) == false)) { return SortOrder.NONE; } return param.isAscending() ? SortOrder.ASCENDING : SortOrder.DESCENDING; }
protected Comparator<FFPAccountingDO> getComparator(final SortParam<String> sortParam, final SortParam<String> secondSortParam) { final String sortProperty = sortParam != null ? sortParam.getProperty() : null; final boolean ascending = sortParam != null ? sortParam.isAscending() : true; final String secondSortProperty = secondSortParam != null ? secondSortParam.getProperty() : null; final boolean secondAscending = secondSortParam != null ? secondSortParam.isAscending() : true; return new MyBeanComparator<FFPAccountingDO>(sortProperty, ascending, secondSortProperty, secondAscending); }
private void sortList(List<D> list, SortParam sortParam) { if (sortParam != null && sortParam.getProperty().startsWith("detail.")) { ListPropertySorter.sort(list, sortParam); final String property = sortParam.getProperty().substring(7); final SortDefinition sortDefinition = new MutableSortDefinition(property, true, sortParam.isAscending()); Collections.sort(list, new PropertyComparator(sortDefinition)); } }
protected Comparator<T> getComparator(final SortParam<String> sortParam, final SortParam<String> secondSortParam) { final String sortProperty = sortParam != null ? sortParam.getProperty() : null; final boolean ascending = sortParam != null ? sortParam.isAscending() : true; if (sortProperty != null && sortProperty.startsWith("attr:")) { return (Comparator<T>) new AttrComperator(sortProperty, ascending); } final String secondSortProperty = secondSortParam != null ? secondSortParam.getProperty() : null; final boolean secondAscending = secondSortParam != null ? secondSortParam.isAscending() : true; return new MyBeanComparator<T>(sortProperty, ascending, secondSortProperty, secondAscending); }
@Override public Iterator<? extends T> iterator(long first, long count) { SortParam<S> sort = getSort(); return list((int) first, (int) count, (sort == null) ? null : sort.getProperty(), (sort == null) ? true : sort.isAscending()) .iterator(); }
@Override public Iterator<? extends T> iterator(long first, long count) { SortParam<S> sort = getSort(); return list((int) first, (int) count, (sort == null) ? null : sort.getProperty(), (sort == null) ? true : sort.isAscending()) .iterator(); }
public int compare(final T o1, final T o2) { PropertyModel<Comparable<T>> model1 = new PropertyModel<Comparable<T>>( o1, Objects.toString(sortParam.getProperty(), null)); PropertyModel<Comparable<T>> model2 = new PropertyModel<Comparable<T>>( o2, Objects.toString(sortParam.getProperty(), null)); int result = new CompareToBuilder().append( model1.getObject(), model2.getObject()).toComparison(); if (!sortParam.isAscending()) { result = -result; } return result; }
@Override public Ordering<T> createOrdering(SortParam sortParam) { return Ordering.<T>from(new PropertyComparator( new MutableSortDefinition(sortParam.getProperty(), true, sortParam.isAscending()))); } }
@Override public Iterator<? extends T> iterator(long first, long count) { SortParam<S> sort = getSort(); return iterator((int) first, (int) count, (sort == null) ? null : sort.getProperty(), (sort == null) ? true : sort.isAscending()); }
@Override public Iterator<? extends T> iterator(long first, long count) { SortParam<S> sort = getSort(); return iterator((int) first, (int) count, (sort == null) ? null : sort.getProperty(), (sort == null) ? true : sort.isAscending()); }
@Override public Iterator<T> iterator(long first, long count) { EntityCriteria<T> criteria = EntityCriteria.of(entityType); if (getSort() != null) { if (getSort().isAscending()) criteria.addOrder(Order.asc(getSort().getProperty())); else criteria.addOrder(Order.desc(getSort().getProperty())); } return AppLoader.getInstance(Dao.class).query(criteria, (int)first, (int)count).iterator(); }
@Override public Iterator<? extends MODEL> iterator(long first, long count) { if(singleSortState.getSort() != null){ Sort property = (Sort) singleSortState.getSort().getProperty(); boolean ascending = singleSortState.getSort().isAscending(); getFilter().setSort(property, ascending); } //TODO quick and dirty check again long page = first / count; List<MODEL> customers = getFilterService().findAll(page, count, this.getFilter()); return customers.iterator(); }
@Override public int getGroupSize(int index) { SortParam groupParam = getGroupParam(); if (groupSizeCache == null) { List<T> toSort = getData(); sortData(toSort, getGroupParam(), getSort()); groupSizeCache = GroupSizeCache.getSizeCache(toSort, getGroupRenderer(groupParam.getProperty())); } return groupSizeCache.getGroupSize(index); }