Interface Tuple


public interface Tuple
Tuple defines an interface for generic query result projection

Usage example:

 
 List<Tuple> result = query.from(employee).select(employee.firstName, employee.lastName).fetch();
 for (Tuple row : result) {
     System.out.println("firstName " + row.get(employee.firstName));
     System.out.println("lastName " + row.get(employee.lastName));
 }
 
 
Author:
tiwe
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    All Tuples should override equals and hashCode.
    <T> T
    get(int index, Class<T> type)
    Get a Tuple element by index
    <T> T
    get(Expression<T> expr)
    Get a tuple element by expression
    int
    All Tuples should override equals and hashCode.
    int
    Get the size of the Tuple
    Get the content as an Object array
  • Method Details

    • get

      @Nullable <T> T get(int index, Class<T> type)
      Get a Tuple element by index
      Type Parameters:
      T - type of element
      Parameters:
      index - zero based index
      type - type of element
      Returns:
      element in array
    • get

      @Nullable <T> T get(Expression<T> expr)
      Get a tuple element by expression
      Type Parameters:
      T - type of element
      Parameters:
      expr - expression key
      Returns:
      result element that matches the expression
    • size

      int size()
      Get the size of the Tuple
      Returns:
      row element count
    • toArray

      Object[] toArray()
      Get the content as an Object array
      Returns:
      tuple in array form
    • equals

      boolean equals(Object o)
      All Tuples should override equals and hashCode. For compatibility across different Tuple implementations, equality check should use java.util.Arrays#equals(Object[], Object[]) with #toArray() as parameters.
      Overrides:
      equals in class Object
    • hashCode

      int hashCode()
      All Tuples should override equals and hashCode. For compatibility across different Tuple implementations, hashCode should use java.util.Arrays#hashCode(Object[]) with #toArray() as parameter.
      Overrides:
      hashCode in class Object