Class SerdeSourceGenPropertyOrder

java.lang.Object
io.micronaut.serde.processor.sourcegen.SerdeSourceGenPropertyOrder

@Internal public final class SerdeSourceGenPropertyOrder extends Object
Orders the properties a generated serializer writes the way the runtime object serializer orders them.

The runtime serializer writes the properties named by a type-level property order first, in that order, followed by the remaining properties in declaration order, and moves XML attribute properties in front of the element properties without changing their relative order. An alphabetic property order sorts every property by its serialized name.

Since:
3.2
  • Method Details

    • order

      public static <T> List<T> order(io.micronaut.inject.ast.ClassElement element, List<T> properties, Function<T,String> serializedName, Function<T,String> originalName, Predicate<T> xmlAttribute)
      Orders the properties for serialization.
      Type Parameters:
      T - The property type
      Parameters:
      element - The serialized type
      properties - The properties in declaration order
      serializedName - The serialized name of a property
      originalName - The declared name of a property
      xmlAttribute - Whether a property is written as an XML attribute
      Returns:
      The properties in write order
    • hasExplicitOrder

      public static boolean hasExplicitOrder(io.micronaut.inject.ast.ClassElement element)
      Whether the type declares a property order the generated serializer applies.
      Parameters:
      element - The serialized type
      Returns:
      true if a property order is declared on the type