Package acdp.design

Class CustomTable

java.lang.Object
acdp.design.CustomTable
All Implemented Interfaces:
Iterable<Row>

public abstract class CustomTable extends Object implements Iterable<Row>
Defines the super class of a custom table class. (See the section "Weakly and Strongly Typed" in the description of the Table interface to learn about the motivation of a custom table class.)

At a minimum, a concrete custom table class declares for each column a variable (typically with the final modifier) referencing that column, for example,

 final Column<String> myStringColumn = CL.typeString();
 final Column<String> myStringArrayColumn =
                         CL.ofArray(Scheme.OUTROW, 58, ST.beString());
 final Column<Ref> myRefColumn = CL.ofRef()
The column variable can be declared as a class variable, hence, with a static modifier under the same condition that a table variable can be declared as a class variable in a custom database. See the description of the CustomDatabase class for details.

Besides the column declarations, the table must provide the table definition at the time of object creation by invoking the initialize method, see example below. (The table definition is the characteristic sequence of columns of a table, see the description of the Table interface.)

If you plan to use the Setup Tool for creating the database layout and all backing files of the database then make sure that the table class is declared with a public access level modifier and that it is annotated with the @SetupTable annotation. Furthermore, the table class must have a no-arg public constructor and all column declarations in the table class need to have a public access level modifier and must be annotated with the @SetupColumn annotation, for example,

 @SetupTable({ "My String Column, My String Array Column, My Ref Column" })
 class MyTable {
    @SetupColumn("My String Column")
    final Column<String> myStringColumn = CL.ofString();
    @SetupColumn("My String Array Column")
    final Column<String> myStringArrayColumn =
                          CL.ofArray(Scheme.OUTROW, 58, ST.beString());
    @SetupColumn(value = "My Ref Column", refdTable = "My Referenced Table")
    final Column<Ref> myRefColumn = CL.ofRef()
    
    MyTable() {
        initialize(myStringColumn, myStringArrayColumn, myRefColumn);
    }
 }

Note that the write operations (insert, update, etc.) are not declared final. Concrete table classes can overwrite these methods and restrict their use. For example, clients of a concrete table class could be prevented from inserting values that were not previously checked for their domain-specific validity.

Author:
Beat Hörmann