/** * Returns the sort order that matches the given string, or returns a new one if none match it. * * @param code The name of the code to fetch or to create. * @return A code matching the given name. */ public static SortOrder valueOf(String code) { return valueOf(SortOrder.class, code); } }
/** * Returns the sort order that matches the given string, or returns a * new one if none match it. More specifically, this methods returns the first instance for * which <code>{@linkplain #name() name()}.{@linkplain String#equals equals}(code)</code> * returns {@code true}. If no existing instance is found, then a new one is created for * the given name. * * @param code the name of the code to fetch or to create. * @return a code matching the given name. */ public static SortOrder valueOf(String code) { return valueOf(SortOrder.class, code); } }
public static SortBy getSortBy( String sortByString, List<SortTypeConfiguration> sortTypeConfigurationList, boolean supportWildcards ) { SortBy sortBy = null; if ( StringUtils.isNotBlank( sortByString ) ) { String[] sortValues = sortByString.split( "," ); String sortKey = sortValues[0]; if ( StringUtils.isNotBlank( sortKey ) ) { SortTypeConfiguration sortType = getSortConfiguration( sortKey, sortTypeConfigurationList, supportWildcards ); if ( sortType != null ) { String sortAttribute = sortType.getSortAttribute(); SortOrder sortOrder = null; if ( sortValues.length >= 3 ) { if ( Boolean.FALSE.toString().equalsIgnoreCase( sortValues[2] ) ) { sortOrder = SortOrder.DESCENDING; } else { sortOrder = SortOrder.ASCENDING; } } else { sortOrder = SortOrder.valueOf( sortType.getSortOrder() ); } sortBy = new SortByImpl( sortAttribute, sortOrder ); } } } return sortBy; }