Record Class FieldUpdate<T>

java.lang.Object
java.lang.Record
io.john.amiscaray.quak.data.update.FieldUpdate<T>
Type Parameters:
T - The entity class this applies to.
Record Components:
fieldName - The name of the field to update.
updates - The changes made to the value of the field.

public record FieldUpdate<T>(String fieldName, List<UpdateExpression<T>> updates) extends Record
A class representing a single database update operation. Often used with the static methods of UpdateExpression for semantic field updates:
 
import static io.john.amiscaray.quak.data.update.UpdateExpression.*;

public class Test {
    public void test() {
         dbProxy.updateAll(Employee.class,
             FieldUpdate.<Number>forField("salary")
                 .apply(multiply(1.5))
                 .apply(add(2000))
                 .build()
          );
    }
}
  • Constructor Details

    • FieldUpdate

      public FieldUpdate(String fieldName, List<UpdateExpression<T>> updates)
      Creates an instance of a FieldUpdate record class.
      Parameters:
      fieldName - the value for the fieldName record component
      updates - the value for the updates record component
  • Method Details

    • forField

      public static <T> FieldUpdate.FieldUpdateBuilder<T> forField(String fieldName)
      Creates a builder for a field with a given name.
      Type Parameters:
      T - The type of the field being updated.
      Parameters:
      fieldName - The name of the field to update.
      Returns:
      A builder for a field update.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • fieldName

      public String fieldName()
      Returns the value of the fieldName record component.
      Returns:
      the value of the fieldName record component
    • updates

      public List<UpdateExpression<T>> updates()
      Returns the value of the updates record component.
      Returns:
      the value of the updates record component