Class PropertyOrdering

java.lang.Object
org.approvej.print.PropertyOrdering

public final class PropertyOrdering extends Object
Utility for deterministic property ordering during serialization.

Field-backed properties are ordered first in their declaration order, followed by any additional properties (e.g. from getters) in alphabetical order.

  • Method Details

    • reorder

      public static <T> List<T> reorder(Class<?> type, List<T> properties, Function<T,String> nameExtractor)
      Reorders a list of named properties so that field-backed properties appear first in their declaration order, followed by remaining properties sorted alphabetically.
      Type Parameters:
      T - the type of property elements
      Parameters:
      type - the class whose field declaration order determines property ordering
      properties - the properties to reorder
      nameExtractor - a function to extract the property name from each element
      Returns:
      a new list with properties in deterministic order