From 93dc2ba50524c19c0ee1cd9b7d9283f9b2bc7437 Mon Sep 17 00:00:00 2001 From: Otavio Santana Date: Wed, 4 May 2022 18:05:41 +0100 Subject: [PATCH] Update documentation in the column condition Signed-off-by: Otavio Santana --- .../jakarta/nosql/column/ColumnCondition.java | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) diff --git a/api/communication/communication-column/src/main/java/jakarta/nosql/column/ColumnCondition.java b/api/communication/communication-column/src/main/java/jakarta/nosql/column/ColumnCondition.java index 415d7e889..ab2876dcc 100644 --- a/api/communication/communication-column/src/main/java/jakarta/nosql/column/ColumnCondition.java +++ b/api/communication/communication-column/src/main/java/jakarta/nosql/column/ColumnCondition.java @@ -20,6 +20,7 @@ import jakarta.nosql.Condition; import jakarta.nosql.ServiceLoaderProvider; +import java.util.Objects; import java.util.function.BiFunction; /** @@ -82,6 +83,21 @@ static ColumnCondition eq(Column column) { return ServiceLoaderProvider.get(ColumnConditionProvider.class).apply(column, Condition.EQUALS); } + /** + * an alias method to {@link ColumnCondition#eq(Column)} where it will create a {@link Column} + * instance first and then apply te condition. + * @param name the name of the column + * @param value the column information + * @return a {@link ColumnCondition} with {@link Condition#EQUALS} + * @throws NullPointerException when either name or value is null + */ + static ColumnCondition eq(String name, Object value) { + Objects.requireNonNull(name, "name is required"); + Objects.requireNonNull(value, "value is required"); + return ServiceLoaderProvider.get(ColumnConditionProvider.class) + .apply(Column.of(name, value), Condition.EQUALS); + } + /** * Creates a {@link ColumnCondition} that has a {@link Condition#GREATER_THAN}, it means a select will scanning to a * column family that has the same name and the value greater than informed in this column. @@ -94,6 +110,20 @@ static ColumnCondition gt(Column column) { return ServiceLoaderProvider.get(ColumnConditionProvider.class).apply(column, Condition.GREATER_THAN); } + /** + * an alias method to {@link ColumnCondition#gt(Column)} where it will create a {@link Column} + * instance first and then apply te condition. + * @param name the name of the column + * @param value the column information + * @return a {@link ColumnCondition} with {@link Condition#GREATER_THAN} + * @throws NullPointerException when either name or value is null + */ + static ColumnCondition gt(String name, Object value) { + Objects.requireNonNull(name, "name is required"); + Objects.requireNonNull(value, "value is required"); + return ServiceLoaderProvider.get(ColumnConditionProvider.class) + .apply(Column.of(name, value), Condition.GREATER_THAN); + } /** * Creates a {@link ColumnCondition} that has a {@link Condition#GREATER_EQUALS_THAN}, * it means a select will scanning to a column family that has the same name and the value @@ -107,6 +137,21 @@ static ColumnCondition gte(Column column) { return ServiceLoaderProvider.get(ColumnConditionProvider.class).apply(column, Condition.GREATER_EQUALS_THAN); } + /** + * an alias method to {@link ColumnCondition#gte(Column)} where it will create a {@link Column} + * instance first and then apply te condition. + * @param name the name of the column + * @param value the column information + * @return a {@link ColumnCondition} with {@link Condition#GREATER_EQUALS_THAN} + * @throws NullPointerException when either name or value is null + */ + static ColumnCondition gte(String name, Object value) { + Objects.requireNonNull(name, "name is required"); + Objects.requireNonNull(value, "value is required"); + return ServiceLoaderProvider.get(ColumnConditionProvider.class) + .apply(Column.of(name, value), Condition.GREATER_EQUALS_THAN); + } + /** * Creates a {@link ColumnCondition} that has a {@link Condition#LESSER_THAN}, it means a select will scanning to a * column family that has the same name and the value lesser than informed in this column. @@ -119,6 +164,21 @@ static ColumnCondition lt(Column column) { return ServiceLoaderProvider.get(ColumnConditionProvider.class).apply(column, Condition.LESSER_THAN); } + /** + * an alias method to {@link ColumnCondition#lt(Column)} where it will create a {@link Column} + * instance first and then apply te condition. + * @param name the name of the column + * @param value the column information + * @return a {@link ColumnCondition} with {@link Condition#LESSER_THAN} + * @throws NullPointerException when either name or value is null + */ + static ColumnCondition lt(String name, Object value) { + Objects.requireNonNull(name, "name is required"); + Objects.requireNonNull(value, "value is required"); + return ServiceLoaderProvider.get(ColumnConditionProvider.class) + .apply(Column.of(name, value), Condition.LESSER_THAN); + } + /** * Creates a {@link ColumnCondition} that has a {@link Condition#LESSER_EQUALS_THAN}, * it means a select will scanning to a column family that has the same name and the value @@ -132,6 +192,21 @@ static ColumnCondition lte(Column column) { return ServiceLoaderProvider.get(ColumnConditionProvider.class).apply(column, Condition.LESSER_EQUALS_THAN); } + /** + * an alias method to {@link ColumnCondition#lte(Column)} where it will create a {@link Column} + * instance first and then apply te condition. + * @param name the name of the column + * @param value the column information + * @return a {@link ColumnCondition} with {@link Condition#LESSER_EQUALS_THAN} + * @throws NullPointerException when either name or value is null + */ + static ColumnCondition lte(String name, Object value) { + Objects.requireNonNull(name, "name is required"); + Objects.requireNonNull(value, "value is required"); + return ServiceLoaderProvider.get(ColumnConditionProvider.class) + .apply(Column.of(name, value), Condition.LESSER_EQUALS_THAN); + } + /** * Creates a {@link ColumnCondition} that has a {@link Condition#IN}, it means a select will scanning to a * column family that has the same name and the value is within informed in this column. @@ -145,6 +220,21 @@ static ColumnCondition in(Column column) { return ServiceLoaderProvider.get(ColumnConditionProvider.class).in(column); } + /** + * an alias method to {@link ColumnCondition#in(Column)} where it will create a {@link Column} + * instance first and then apply te condition. + * @param name the name of the column + * @param value the column information + * @return a {@link ColumnCondition} with {@link Condition#IN} + * @throws NullPointerException when either name or value is null + */ + static ColumnCondition in(String name, Object value) { + Objects.requireNonNull(name, "name is required"); + Objects.requireNonNull(value, "value is required"); + return ServiceLoaderProvider.get(ColumnConditionProvider.class) + .in(Column.of(name, value)); + } + /** * Creates a {@link ColumnCondition} that has a {@link Condition#LIKE}, it means a select will scanning to a * column family that has the same name and the value is like than informed in this column. @@ -157,6 +247,21 @@ static ColumnCondition like(Column column) { return ServiceLoaderProvider.get(ColumnConditionProvider.class).apply(column, Condition.LIKE); } + /** + * an alias method to {@link ColumnCondition#like(Column)} where it will create a {@link Column} + * instance first and then apply te condition. + * @param name the name of the column + * @param value the column information + * @return a {@link ColumnCondition} with {@link Condition#LIKE} + * @throws NullPointerException when either name or value is null + */ + static ColumnCondition like(String name, Object value) { + Objects.requireNonNull(name, "name is required"); + Objects.requireNonNull(value, "value is required"); + return ServiceLoaderProvider.get(ColumnConditionProvider.class) + .apply(Column.of(name, value), Condition.LIKE); + } + /** * Creates a {@link ColumnCondition} that has a {@link Condition#BETWEEN}, * it means a select will scanning to a column family that is between two values informed @@ -174,6 +279,21 @@ static ColumnCondition between(Column column) { return ServiceLoaderProvider.get(ColumnConditionProvider.class).between(column); } + /** + * an alias method to {@link ColumnCondition#between(Column)} (Column)} where it will create a {@link Column} + * instance first and then apply te condition. + * @param name the name of the column + * @param value the column information + * @return a {@link ColumnCondition} with {@link Condition#BETWEEN} + * @throws NullPointerException when either name or value is null + */ + static ColumnCondition between(String name, Object value) { + Objects.requireNonNull(name, "name is required"); + Objects.requireNonNull(value, "value is required"); + return ServiceLoaderProvider.get(ColumnConditionProvider.class) + .between(Column.of(name, value)); + } + /** * Returns a new {@link ColumnCondition} aggregating ,as ¨AND", all the conditions as just one condition.