/** * @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); }
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); }
@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; }
@Override public Iterator<TimesheetDO> iterator(final long first, final long count) { final SortParam sp = getSort(); final Comparator<TimesheetDO> comp = new MyBeanComparator<TimesheetDO>(sp.getProperty().toString(), sp.isAscending()); Collections.sort(timesheets, comp); return timesheets.subList((int) first, (int) (first + count)).iterator(); }
@Override public Iterator<? extends AddressDO> iterator(final long first, final long count) { final SortParam sp = getSort(); if (addresses == null) { return null; } final Comparator<AddressDO> comp = new MyBeanComparator<AddressDO>(sp.getProperty().toString(), sp.isAscending()); Collections.sort(addresses, comp); return addresses.subList((int) first, (int) (first + count)).iterator(); }
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(); }
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 static String toOrderBy(final SortParam<String> sort) { OrderByClauseBuilder builder = SyncopeClient.getOrderByClauseBuilder(); String property = sort.getProperty(); if (property.indexOf('#') != -1) { property = property.substring(property.indexOf('#') + 1); } if (sort.isAscending()) { builder.asc(property); } else { builder.desc(property); } return builder.build(); }
@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()); }
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 Iterator<K> iterator(long first, long count) { SortParam<String> sort = getSort(); if(sort!=null) { model.setSortableParameter(sort.getProperty()); model.setAscending(sort.isAscending()); } return (Iterator<K>)model.iterator(first, count); }
@Override public Iterator<K> iterator(long first, long count) { SortParam<String> sort = getSort(); if(sort!=null) { model.setSortableParameter(sort.getProperty()); model.setAscending(sort.isAscending()); } return (Iterator<K>)model.iterator(first, count); }
@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 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(); }