Skip to content

Commit

Permalink
Improve JavaDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
echebbi committed Jan 25, 2018
1 parent 8129192 commit c44ee7e
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}. <br>
* <br>
* See {@link fr.kazejiyu.generic.datatable.core} for further details.
*
* @author Emmanuel CHEBBI
*/
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/fr/kazejiyu/generic/datatable/core/Rows.java
Original file line number Diff line number Diff line change
Expand Up @@ -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}. <br>
* <br>
* See {@link fr.kazejiyu.generic.datatable.core} for further details.
*
* @author Emmanuel CHEBBI
*/
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/fr/kazejiyu/generic/datatable/core/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -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}. <br>
* <br>
* See {@link fr.kazejiyu.generic.datatable.core} for further details.
*
* @author Emmanuel CHEBBI
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ public static ColumnOfStringsId[] s(ColumnId<String> id, ColumnId<String>... ids
* @param id
* The column id to wrap.
*
* @return a new {@code ColumnId}
* @return a new {@code ColumnId}
*
* @param <T> The type of the column's elements.
*/
public static <T extends Number> ColumnOfNumbersId<T> n(ColumnId<T> id) {
return new ColumnOfNumbersId<>(id);
Expand All @@ -150,6 +152,8 @@ public static <T extends Number> ColumnOfNumbersId<T> n(ColumnId<T> id) {
* The other ids.
*
* @return a new {@code ColumnId}
*
* @param <T> The type of the column's elements.
*/
@SafeVarargs
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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<ColumnId<?>> idsOfColumnsToKeep) {
for(final ColumnId<?> columnToKeep : idsOfColumnsToKeep)
if( ! table.columns().contains(columnToKeep) )
Expand Down
Original file line number Diff line number Diff line change
@@ -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}. <br>
* <br>
* See {@link fr.kazejiyu.generic.datatable.core} for further documentation.
*
* @author Emmanuel CHEBBI
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,59 @@
/**
* Describes a Table data structure..
* Describes a Table data structure.
*
* <h3>ColumnId</h3>
*
* The term <em>id</em> refers to instances of {@link fr.kazejiyu.generic.datatable.core.impl.ColumnId ColumnId}. <br>
* 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. <br>
* <br>
* For instance, the following id references any column which name is "age" and which stores integers: <br>
* <br>
* {@code ColumnId<Integer> age = id("name", Integer.class);}
*
* <h3>Populating a Table</h3>
*
* Creation of a new {@link fr.kazejiyu.generic.datatable.core.Table Table} consists of an easy one-liner : <br>
* <br>
* {@code Table people = new DataTable();} <br>
* <br>
* A table can be filled either by adding new columns :
*
* <pre>people.columns()
* .create("Name", String.class, "Luc", "Baptiste", "Marie")
* .create("Age", Integer.class, 23, 32, 42);}</pre>
*
* or by adding new rows :
*
* <pre>people.rows()
* .create("Julie", 12)
* .create("Mathieu", 67);</pre>
*
* <h3>Depopulating a Table</h3>
*
* A table can be emptied either by removing columns:
*
* <pre>people.columns()
* .remove("age");</pre>
*
* <h3>Querying a Table</h3>
*
* 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:
*
* <pre>ColumnId&lt;Integer&gt; AGE = id(Integer.class, "age");
*ColumnId&lt;String&gt; NAME = id(String.class, "name");
*
*Table adultsWhoseNameEndsWithLetterE(Table people) {
* return people.filter(row -&gt;
* row.get(AGE) &gt; 18 &amp;&amp;
* row.get(NAME).startsWith("E")
* );
*}</pre>
*
* 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;
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Describes a SQL-like DSL to query the content of a {@link fr.kazejiyu.generic.datatable.core.Table Table}.
*
* <h3>SQL-like DSL</h3>
*
* The API can be used as follows:
*
* <pre>ColumnId&lt;Integer&gt; AGE = id(Integer.class, "age");
*ColumnId&lt;String&gt; NAME = id(String.class, "name");
*ColumnId&lt;String&gt; 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();
*}</pre>
*
* @author Emmanuel CHEBBI
*/
package fr.kazejiyu.generic.datatable.query;

0 comments on commit c44ee7e

Please sign in to comment.