@Override public boolean equals(Object x) { try { return compareTo((SortableItem) x) == 0; } catch (Exception e) { return false; } }
/** * Sorts the given array node using the sort criteria given in this * ArrayProjector * * @param array The array node to sort * @param factory Json node factory * * If there is a sort criteria defined in <code>this</code>, the array * elements are sorted using that. * * @return A new ArrayNode containing the sorted elements, or if there is no * sort defined, the <code>array</code> itself */ public ArrayNode sortArray(ArrayNode array, JsonNodeFactory factory) { if (sort == null) { return array; } else { List<SortableItem> list = new ArrayList<>(array.size()); for (Iterator<JsonNode> itr = array.elements(); itr.hasNext();) { list.add(new SortableItem(itr.next(), sortFields)); } Collections.sort(list); ArrayNode newNode = factory.arrayNode(); for (SortableItem x : list) { newNode.add(x.getNode()); } return newNode; } }
/** * Sorts the given array node using the sort criteria given in this * ArrayProjector * * @param array The array node to sort * @param factory Json node factory * * If there is a sort criteria defined in <code>this</code>, the array * elements are sorted using that. * * @return A new ArrayNode containing the sorted elements, or if there is no * sort defined, the <code>array</code> itself */ public ArrayNode sortArray(ArrayNode array, JsonNodeFactory factory) { if (sort == null) { return array; } else { List<SortableItem> list = new ArrayList<>(array.size()); for (Iterator<JsonNode> itr = array.elements(); itr.hasNext();) { list.add(new SortableItem(itr.next(), sortFields)); } Collections.sort(list); ArrayNode newNode = factory.arrayNode(); for (SortableItem x : list) { newNode.add(x.getNode()); } return newNode; } }
@Override public boolean equals(Object x) { try { return compareTo((SortableItem) x) == 0; } catch (Exception e) { return false; } }