java.lang.Object
ece.ing3.java.projet.database.sql.clauses.OrderBy

public class OrderBy extends Object
Order By clause helper.

Provides a convenient way to build Order By clause, reactive-style. Nesting is not allowed.


Order By clauses can be chained using and(OrderBy) or the shortcut method and(String, Order), to avoid creating unnecessary Order By clauses.

OrderBy supports Reactive-style programming to create more compact code.
As such,

 OrderBy o = new OrderBy( "col1", Order.DESC );
 o.and( "col2", Order.ASC );
 String v = o.toString();
 

can be written

 String v = ( new OrderBy( "col1", Order.DESC ) ).and( "col2", Order.ASC ).toString();
 
Author:
Virgile, Nicolas, Louis-Félix
  • Constructor Details

    • OrderBy

      public OrderBy()
      Creates a new chainable, empty Order By clause.
    • OrderBy

      public OrderBy(String column, Order order)
      Creates a new chainable Order By clause.
      Parameters:
      column - Column to target
      order - Order to target
  • Method Details

    • and

      public OrderBy and(OrderBy condition)
      Chain another Order By condition.
      Parameters:
      condition - Condition to chain
      Returns:
      This Order By clause helper
    • and

      public OrderBy and(String column, Order order)
      Chain another Order By condition using the provided values.
      Parameters:
      column - Column to target
      order - Order to target
      Returns:
      This Order By clause helper
    • toString

      public String toString()
      Gets the corresponding SQL Order By clause.
      Overrides:
      toString in class Object
      Returns:
      SQL Order By clause