Module jakarta.data

Interface SortableAttribute<T>

Type Parameters:
T - entity class of the static metamodel.
All Superinterfaces:
Attribute<T>
All Known Subinterfaces:
BooleanAttribute<T>, ComparableAttribute<T,V>, NumericAttribute<T,N>, TemporalAttribute<T,V>, TextAttribute<T>
All Known Implementing Classes:
SortableAttributeRecord, TextAttributeRecord

public interface SortableAttribute<T> extends Attribute<T>

Represents a entity attribute in the StaticMetamodel that is sortable, but incapable of order-based comparison.

A SortableAttribute may be used to sort query results. When an attribute type is a numeric type, NumericAttribute is preferred. When an attribute type is String, TextAttribute is preferred. When an attribute type is boolean or Boolean, BooleanAttribute is preferred. When an attribute type is a temporal type supported by TemporalAttribute, TemporalAttribute is preferred. When an attribute type (or, if primitive, its wrapper class) is a subtype of Comparable, use of ComparableAttribute is usually preferred, since a SortableAttribute cannot be used in order-based query restrictions. Direct use of SortableAttribute is appropriate for attributes of type byte[].

  • Method Summary

    Modifier and Type
    Method
    Description
    default Sort<T>
    asc()
    Obtain a request for an ascending Sort based on the entity attribute.
    default Sort<T>
    Obtain a request for a descending Sort based on the entity attribute.
    static <T, V> SortableAttribute<T>
    of(Class<T> entityClass, String name, Class<V> attributeType)
    Creates a static metamodel SortableAttribute representing the entity attribute with the specified name.

    Methods inherited from interface jakarta.data.metamodel.Attribute

    declaringType, name, type
  • Method Details

    • asc

      default Sort<T> asc()
      Obtain a request for an ascending Sort based on the entity attribute.
      Returns:
      a request for an ascending sort on the entity attribute.
    • desc

      default Sort<T> desc()
      Obtain a request for a descending Sort based on the entity attribute.
      Returns:
      a request for a descending sort on the entity attribute.
    • of

      static <T, V> SortableAttribute<T> of(Class<T> entityClass, String name, Class<V> attributeType)

      Creates a static metamodel SortableAttribute representing the entity attribute with the specified name.

      Type Parameters:
      T - entity class of the static metamodel.
      V - type of entity attribute (or wrapper type if primitive).
      Parameters:
      entityClass - the entity class.
      name - the name of the entity attribute.
      attributeType - type of the entity attribute.
      Returns:
      instance of SortableAttribute.
      Since:
      1.1