public ReferenceComparator() { Comparator<String> stringComparator = new Comparator<String>() { @Override public int compare(String o1, String o2) { return o1.compareTo(o2); } }; nullSafeStringComparator = new NullComparator(stringComparator, false); }
public static <T> Comparator<T> getComparator(String columnName, boolean reverse) { Comparator<T> c; if (reverse) { c = Collections.reverseOrder(new BeanComparator<T>(columnName, new NullComparator(false))); } else { c = new BeanComparator<T>(columnName, new NullComparator(false)); } return c; }
/** * getFormulasList returns a List of all formulas, sorted by formula name * @return */ public List<CalculatedQuestionFormulaBean> getFormulasList() { List<CalculatedQuestionFormulaBean> beanList = new ArrayList<CalculatedQuestionFormulaBean>(formulas.values()); Collections.sort(beanList, new Comparator<CalculatedQuestionFormulaBean>() { public int compare(CalculatedQuestionFormulaBean bean1, CalculatedQuestionFormulaBean bean2) { return new NullComparator().compare(bean1.getName(), bean2.getName()); } }); return beanList; }
/** * getVariablesList returns a List of all variables, sorted by variable name * @return */ public List<CalculatedQuestionVariableBean> getVariablesList() { List<CalculatedQuestionVariableBean> beanList = new ArrayList<CalculatedQuestionVariableBean>(variables.values()); Collections.sort(beanList, new Comparator<CalculatedQuestionVariableBean>() { public int compare(CalculatedQuestionVariableBean bean1, CalculatedQuestionVariableBean bean2) { return new NullComparator().compare(bean1.getName(), bean2.getName()); } }); return beanList; }
protected List<WorkflowInstanceSearchModel> sortSearchResult( List<WorkflowInstanceSearchModel> result, int column, String direction ){ List<WorkflowInstanceSearchModel> unorderedSource = new ArrayList<>( result ); String fieldName = DataTableColumnMapper.from( column ).getFieldName(); BeanComparator<WorkflowInstanceSearchModel> beanComparator; if( "asc".equalsIgnoreCase( direction ) ){ beanComparator = new BeanComparator<>( fieldName, new NullComparator() ); } else{ beanComparator = new BeanComparator<>( fieldName, new ReverseComparator( new NullComparator() ) ); } Collections.sort( unorderedSource, beanComparator ); return unorderedSource; }
/** * * Override point. Allows user to use custom comparators based on * properties. * * @param property the property whose comparator is requested * @return Comparator that will compare two objects based on a property */ protected Comparator<?> getUnderlyingComparator(Object property) { return new NullComparator(); }
/** * Override point. Allows user to use custom comparators based on properties. * * @param property the property whose comparator is requested * @return Comparator that will compare two objects based on a property */ protected Comparator<T> getUnderlyingComparator(final Object property) { return new NullComparator(); }