diff --git a/src/main/java/fr/kazejiyu/generic/datatable/core/Columns.java b/src/main/java/fr/kazejiyu/generic/datatable/core/Columns.java index 0cb479f..9a42ab0 100644 --- a/src/main/java/fr/kazejiyu/generic/datatable/core/Columns.java +++ b/src/main/java/fr/kazejiyu/generic/datatable/core/Columns.java @@ -27,7 +27,9 @@ import fr.kazejiyu.generic.datatable.exceptions.InconsistentColumnSizeException; /** - * A collection of {@link Column} that belongs to a {@link Table}. + * A collection of {@link Column} that belongs to a {@link Table}.
+ *
+ * See {@link fr.kazejiyu.generic.datatable.core} for further details. * * @author Emmanuel CHEBBI */ diff --git a/src/main/java/fr/kazejiyu/generic/datatable/core/Rows.java b/src/main/java/fr/kazejiyu/generic/datatable/core/Rows.java index 98faca8..743c3cb 100644 --- a/src/main/java/fr/kazejiyu/generic/datatable/core/Rows.java +++ b/src/main/java/fr/kazejiyu/generic/datatable/core/Rows.java @@ -23,7 +23,9 @@ import fr.kazejiyu.generic.datatable.exceptions.InconsistentRowSizeException; /** - * An ordered collection of {@link Row}s that belongs to a {@link Table}. + * An ordered collection of {@link Row}s that belongs to a {@link Table}.
+ *
+ * See {@link fr.kazejiyu.generic.datatable.core} for further details. * * @author Emmanuel CHEBBI */ diff --git a/src/main/java/fr/kazejiyu/generic/datatable/core/Table.java b/src/main/java/fr/kazejiyu/generic/datatable/core/Table.java index 3225e52..afd148f 100644 --- a/src/main/java/fr/kazejiyu/generic/datatable/core/Table.java +++ b/src/main/java/fr/kazejiyu/generic/datatable/core/Table.java @@ -23,7 +23,9 @@ import fr.kazejiyu.generic.datatable.exceptions.HeaderNotFoundException; /** - * A table containing {@link Rows} and {@link Columns}. + * A table containing {@link Rows} and {@link Columns}.
+ *
+ * See {@link fr.kazejiyu.generic.datatable.core} for further details. * * @author Emmanuel CHEBBI */ diff --git a/src/main/java/fr/kazejiyu/generic/datatable/core/impl/ColumnId.java b/src/main/java/fr/kazejiyu/generic/datatable/core/impl/ColumnId.java index 6d9cc8d..dc71f7c 100644 --- a/src/main/java/fr/kazejiyu/generic/datatable/core/impl/ColumnId.java +++ b/src/main/java/fr/kazejiyu/generic/datatable/core/impl/ColumnId.java @@ -135,7 +135,9 @@ public static ColumnOfStringsId[] s(ColumnId id, ColumnId... ids * @param id * The column id to wrap. * - * @return a new {@code ColumnId} + * @return a new {@code ColumnId} + * + * @param The type of the column's elements. */ public static ColumnOfNumbersId n(ColumnId id) { return new ColumnOfNumbersId<>(id); @@ -150,6 +152,8 @@ public static ColumnOfNumbersId n(ColumnId id) { * The other ids. * * @return a new {@code ColumnId} + * + * @param The type of the column's elements. */ @SafeVarargs @SuppressWarnings("unchecked") diff --git a/src/main/java/fr/kazejiyu/generic/datatable/core/impl/TablePreconditions.java b/src/main/java/fr/kazejiyu/generic/datatable/core/impl/TablePreconditions.java index 59ea4ae..335753e 100644 --- a/src/main/java/fr/kazejiyu/generic/datatable/core/impl/TablePreconditions.java +++ b/src/main/java/fr/kazejiyu/generic/datatable/core/impl/TablePreconditions.java @@ -14,14 +14,14 @@ public TablePreconditions(DataTable table) { this.table = table; } - /** @throws HeaderNotFoundException if an element of {@ode columnsToKeep} does not match any column */ + /** @throws HeaderNotFoundException if an element of {@code columnsToKeep} does not match any column */ void assertAreExistingHeaders(LinkedHashSet columnsToKeep) { for(final String columnToKeep : columnsToKeep) if( ! table.columns().contains(columnToKeep) ) throw new HeaderNotFoundException("The header " + columnToKeep + " does not exist in the table"); } - /** @throws ColumnIdNotFoundException if an element of {@ode idsOfColumnsToKeep} does not match any column */ + /** @throws ColumnIdNotFoundException if an element of {@code idsOfColumnsToKeep} does not match any column */ public void assertAreExistingIds(LinkedHashSet> idsOfColumnsToKeep) { for(final ColumnId columnToKeep : idsOfColumnsToKeep) if( ! table.columns().contains(columnToKeep) ) diff --git a/src/main/java/fr/kazejiyu/generic/datatable/core/impl/package-info.java b/src/main/java/fr/kazejiyu/generic/datatable/core/impl/package-info.java index 5839266..88d8dd3 100644 --- a/src/main/java/fr/kazejiyu/generic/datatable/core/impl/package-info.java +++ b/src/main/java/fr/kazejiyu/generic/datatable/core/impl/package-info.java @@ -1,5 +1,7 @@ /** - * Implementation of {@link fr.kazejiyu.generic.datatable.core.Table Table} that relies on {@code GlazedLists}. + * Concrete implementation of a {@link fr.kazejiyu.generic.datatable.core.Table Table}.
+ *
+ * See {@link fr.kazejiyu.generic.datatable.core} for further documentation. * * @author Emmanuel CHEBBI */ diff --git a/src/main/java/fr/kazejiyu/generic/datatable/core/package-info.java b/src/main/java/fr/kazejiyu/generic/datatable/core/package-info.java index febcfe4..7d9df2d 100644 --- a/src/main/java/fr/kazejiyu/generic/datatable/core/package-info.java +++ b/src/main/java/fr/kazejiyu/generic/datatable/core/package-info.java @@ -1,6 +1,59 @@ /** - * Describes a Table data structure.. + * Describes a Table data structure. * + *

ColumnId

+ * + * The term id refers to instances of {@link fr.kazejiyu.generic.datatable.core.impl.ColumnId ColumnId}.
+ * An id is a trick used to reference a table's column in a type-safe way and can be created with the + * {@link fr.kazejiyu.generic.datatable.core.impl.ColumnId#id(String, Class) ColumnId.id(String,Class)} static method.
+ *
+ * For instance, the following id references any column which name is "age" and which stores integers:
+ *
+ * {@code ColumnId age = id("name", Integer.class);} + * + *

Populating a Table

+ * + * Creation of a new {@link fr.kazejiyu.generic.datatable.core.Table Table} consists of an easy one-liner :
+ *
+ * {@code Table people = new DataTable();}
+ *
+ * A table can be filled either by adding new columns : + * + *
people.columns()
+ *   .create("Name", String.class, "Luc", "Baptiste", "Marie")
+ *   .create("Age", Integer.class, 23, 32, 42);}
+ * + * or by adding new rows : + * + *
people.rows()
+ *    .create("Julie", 12)
+ *    .create("Mathieu", 67);
+ * + *

Depopulating a Table

+ * + * A table can be emptied either by removing columns: + * + *
people.columns()
+ *    .remove("age");
+ * + *

Querying a Table

+ * + * The {@link Table#filter(ca.odell.glazedlists.matchers.Matcher) Table.filter(Matcher)} makes easy to retrieve + * the rows of a table that match a specific criterion: + * + *
ColumnId<Integer> AGE = id(Integer.class, "age");
+ *ColumnId<String> NAME = id(String.class, "name");
+ *
+ *Table adultsWhoseNameEndsWithLetterE(Table people) {
+ *    return people.filter(row ->
+ *        row.get(AGE) > 18 &&
+ *        row.get(NAME).startsWith("E")
+ *    );
+ *}
+ * + * For more complex cases, the API also defines a SQL-like DSL that makes possible to apply a same filter on mutliple + * columns. See {@link fr.kazejiyu.generic.datatable.query} for an overview. + * * @author Emmanuel CHEBBI */ package fr.kazejiyu.generic.datatable.core; \ No newline at end of file diff --git a/src/main/java/fr/kazejiyu/generic/datatable/query/impl/package-info.java b/src/main/java/fr/kazejiyu/generic/datatable/query/impl/package-info.java index b5e1b48..2427ad9 100644 --- a/src/main/java/fr/kazejiyu/generic/datatable/query/impl/package-info.java +++ b/src/main/java/fr/kazejiyu/generic/datatable/query/impl/package-info.java @@ -1,5 +1,5 @@ /** - * Provides a SQL-like DSL to query the content of a {@link fr.kazejiyu.generic.datatable.core.Table Table}. + * Concrete implementation of a {@link fr.kazejiyu.generic.datatable.query.Query Query}. * * @author Emmanuel CHEBBI */ diff --git a/src/main/java/fr/kazejiyu/generic/datatable/query/package-info.java b/src/main/java/fr/kazejiyu/generic/datatable/query/package-info.java new file mode 100644 index 0000000..bf2c38a --- /dev/null +++ b/src/main/java/fr/kazejiyu/generic/datatable/query/package-info.java @@ -0,0 +1,23 @@ +/** + * Describes a SQL-like DSL to query the content of a {@link fr.kazejiyu.generic.datatable.core.Table Table}. + * + *

SQL-like DSL

+ * + * The API can be used as follows: + * + *
ColumnId<Integer> AGE = id(Integer.class, "age");
+ *ColumnId<String> NAME = id(String.class, "name");
+ *ColumnId<String> SURENAME = id(String.class, "surename");
+ *
+ *Table europeanAdultsWhoseNameEndsWithLetterE(Table people) {
+ *    return Query
+ *        .from(people)
+ *        .where(s(NAME, SURENAME)).endsWith("e")
+ *        .and(AGE).gt(18)
+ *        .and(COUNTRY).match(Country::isInEurope)
+ *        .select();
+ *}
+ * + * @author Emmanuel CHEBBI + */ +package fr.kazejiyu.generic.datatable.query; \ No newline at end of file