@Test void convertSingleAttrDesc() { assertEquals(new Sort().on("attr", DESC), new SortConverter().convert("attr:desc")); }
@Override public Sort convert(String source) { Sort sort = new Sort(); for (String attr : source.split(",")) { Sort.Direction direction; if (attr.endsWith(ORDER_DESC_POSTFIX)) { direction = Sort.Direction.DESC; attr = attr.substring(0, attr.length() - ORDER_DESC_POSTFIX.length()); } else if (attr.endsWith(ORDER_ASC_POSTFIX)) { direction = Sort.Direction.ASC; attr = attr.substring(0, attr.length() - ORDER_ASC_POSTFIX.length()); } else { direction = Sort.Direction.ASC; } sort.on(attr, direction); } return sort; }
SortConverter implements Converter<String, Sort> { @Override public Sort convert(String source) { Sort sort = new Sort(); for (String attr : source.split(",")) { Sort.Direction direction; if (attr.endsWith(ORDER_DESC_POSTFIX)) { direction = Sort.Direction.DESC; attr = attr.substring(0, attr.length() - ORDER_DESC_POSTFIX.length()); } else if (attr.endsWith(ORDER_ASC_POSTFIX)) { direction = Sort.Direction.ASC; attr = attr.substring(0, attr.length() - ORDER_ASC_POSTFIX.length()); } else { direction = Sort.Direction.ASC; } sort.on(attr, direction); } return sort; } }
SortConverter implements Converter<String, Sort> { @Override public Sort convert(String source) { Sort sort = new Sort(); for (String attr : source.split(",")) { Sort.Direction direction; if (attr.endsWith(ORDER_DESC_POSTFIX)) { direction = Sort.Direction.DESC; attr = attr.substring(0, attr.length() - ORDER_DESC_POSTFIX.length()); } else if (attr.endsWith(ORDER_ASC_POSTFIX)) { direction = Sort.Direction.ASC; attr = attr.substring(0, attr.length() - ORDER_ASC_POSTFIX.length()); } else { direction = Sort.Direction.ASC; } sort.on(attr, direction); } return sort; }  }
SortConverter implements Converter<String, Sort> { @Override public Sort convert(String source) { Sort sort = new Sort(); for (String attr : source.split(",")) { Sort.Direction direction; if (attr.endsWith(ORDER_DESC_POSTFIX)) { direction = Sort.Direction.DESC; attr = attr.substring(0, attr.length() - ORDER_DESC_POSTFIX.length()); } else if (attr.endsWith(ORDER_ASC_POSTFIX)) { direction = Sort.Direction.ASC; attr = attr.substring(0, attr.length() - ORDER_ASC_POSTFIX.length()); } else { direction = Sort.Direction.ASC; } sort.on(attr, direction); } return sort; }  @Override Sort convert(String source); }
SortConverter implements Converter<String, Sort> { @Override public Sort convert(String source) { Sort sort = new Sort(); for (String attr : source.split(",")) { Sort.Direction direction; if (attr.endsWith(ORDER_DESC_POSTFIX)) { direction = Sort.Direction.DESC; attr = attr.substring(0, attr.length() - ORDER_DESC_POSTFIX.length()); } else if (attr.endsWith(ORDER_ASC_POSTFIX)) { direction = Sort.Direction.ASC; attr = attr.substring(0, attr.length() - ORDER_ASC_POSTFIX.length()); } else { direction = Sort.Direction.ASC; } sort.on(attr, direction); } return sort; }  @Override Sort convert(String source);  }