@Test(expected = IllegalArgumentException.class) public void testParseWithTooManyParts() throws Exception { SortCriterionImpl.parse("name:ASC:first"); }
public static SortCriterionImpl parse(final String sortCriterion) { requireNonNull(sortCriterion); String[] parts = sortCriterion.split(":"); if (parts.length != 2) throw new IllegalArgumentException("sortOrder must be of form <field name>:ASC/DESC"); if ("ASC".equalsIgnoreCase(parts[1]) || "Ascending".equalsIgnoreCase(parts[1])) return new SortCriterionImpl(parts[0], Order.Ascending); if ("DESC".equalsIgnoreCase(parts[1]) || "Descending".equalsIgnoreCase(parts[1])) return new SortCriterionImpl(parts[0], Order.Descending); throw new IllegalArgumentException("Invalid order " + parts[1]); }
SortCriterionImpl implements SortCriterion { public static SortCriterionImpl parse(final String sortCriterion) { requireNonNull(sortCriterion); String[] parts = sortCriterion.split(":"); if (parts.length != 2) throw new IllegalArgumentException("sortOrder must be of form <field name>:ASC/DESC"); if ("ASC".equalsIgnoreCase(parts[1]) || "Ascending".equalsIgnoreCase(parts[1])) return new SortCriterionImpl(parts[0], Order.Ascending); if ("DESC".equalsIgnoreCase(parts[1]) || "Descending".equalsIgnoreCase(parts[1])) return new SortCriterionImpl(parts[0], Order.Descending); throw new IllegalArgumentException("Invalid order " + parts[1]); } }
SortCriterionImpl implements SortCriterion { public static SortCriterionImpl parse(final String sortCriterion) { requireNonNull(sortCriterion); String[] parts = sortCriterion.split(":"); if (parts.length != 2) throw new IllegalArgumentException("sortOrder must be of form <field name>:ASC/DESC"); if ("ASC".equalsIgnoreCase(parts[1]) || "Ascending".equalsIgnoreCase(parts[1])) return new SortCriterionImpl(parts[0], Order.Ascending); if ("DESC".equalsIgnoreCase(parts[1]) || "Descending".equalsIgnoreCase(parts[1])) return new SortCriterionImpl(parts[0], Order.Descending); throw new IllegalArgumentException("Invalid order " + parts[1]); } SortCriterionImpl(String fieldName, Order order); }
SortCriterionImpl implements SortCriterion { public static SortCriterionImpl parse(final String sortCriterion) { requireNonNull(sortCriterion); String[] parts = sortCriterion.split(":"); if (parts.length != 2) throw new IllegalArgumentException("sortOrder must be of form <field name>:ASC/DESC"); if ("ASC".equalsIgnoreCase(parts[1]) || "Ascending".equalsIgnoreCase(parts[1])) return new SortCriterionImpl(parts[0], Order.Ascending); if ("DESC".equalsIgnoreCase(parts[1]) || "Descending".equalsIgnoreCase(parts[1])) return new SortCriterionImpl(parts[0], Order.Descending); throw new IllegalArgumentException("Invalid order " + parts[1]); } SortCriterionImpl(String fieldName, Order order); static SortCriterionImpl parse(final String sortCriterion); @Override String getFieldName(); @Override Order getOrder(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
SortCriterionImpl implements SortCriterion { public static SortCriterionImpl parse(final String sortCriterion) { requireNonNull(sortCriterion); String[] parts = sortCriterion.split(":"); if (parts.length != 2) throw new IllegalArgumentException("sortOrder must be of form <field name>:ASC/DESC"); if ("ASC".equalsIgnoreCase(parts[1]) || "Ascending".equalsIgnoreCase(parts[1])) return new SortCriterionImpl(parts[0], Order.Ascending); if ("DESC".equalsIgnoreCase(parts[1]) || "Descending".equalsIgnoreCase(parts[1])) return new SortCriterionImpl(parts[0], Order.Descending); throw new IllegalArgumentException("Invalid order " + parts[1]); } SortCriterionImpl(String fieldName, Order order); static SortCriterionImpl parse(final String sortCriterion); @Override String getFieldName(); @Override Order getOrder(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }