Refactor tidy grammar in server/expression classes

This commit is contained in:
Rob Bygrave committed 2022-03-22 16:48:47 +13:00
1 parent de4140aaac
commit baddc76961
21 files changed
+48 -74

No files matched your search

@@ -35,7 +35,7 @@ public final class CacheIdLookupMany<T> implements CacheIdLookup<T> {
@Override
public List<T> removeHits(BeanCacheResult<T> cacheResult) {
Set<Object> hitIds = new HashSet<>();
List<T> beans = new ArrayList<>(hitIds.size());
List<T> beans = new ArrayList<>();
for (BeanCacheResult.Entry<T> hit : cacheResult.hits()) {
hitIds.add(hit.getKey());
beans.add(hit.getBean());
@@ -40,7 +40,7 @@ abstract class AbstractTextExpression extends AbstractExpression {
@Override
public void queryBindKey(BindValuesKey key) {
// do nothing, only execute against document store
};
}
@Override
public boolean isSameByBind(SpiExpression other) {
@@ -4,8 +4,6 @@ import io.ebeaninternal.api.BindValuesKey;
import io.ebeaninternal.api.SpiExpression;
import io.ebeaninternal.api.SpiExpressionRequest;
import java.io.IOException;
/**
* Bitwise expression.
*/
@@ -25,7 +23,7 @@ final class BitwiseExpression extends AbstractExpression {
}
@Override
public void writeDocQuery(DocQueryContext context) throws IOException {
public void writeDocQuery(DocQueryContext context) {
throw new IllegalStateException("Not supported for document queries");
}
@@ -47,12 +47,12 @@ final class DefaultExampleExpression implements SpiExpression, ExampleExpression
private final EntityBean entity;
/**
* Set to true to use case insensitive expressions.
* Set to true to use case-insensitive expressions.
*/
private boolean caseInsensitive;
/**
* The type of like (RAW, STARTS_WITH, ENDS_WITH etc)
* The type of like (RAW, STARTS_WITH, ENDS_WITH)
*/
private LikeType likeType;
@@ -62,7 +62,7 @@ final class DefaultExampleExpression implements SpiExpression, ExampleExpression
private boolean includeZeros;
/**
* The non null bean properties and found and together added as a list of
* The non-null bean properties and found and together added as a list of
* expressions (like or equal to expressions).
*/
private ArrayList<SpiExpression> list;
@@ -71,8 +71,8 @@ final class DefaultExampleExpression implements SpiExpression, ExampleExpression
/**
* Construct the query by example expression.
*
* @param entity the example entity with non null property values
* @param caseInsensitive if true use case insensitive expressions
* @param entity the example entity with non-null property values
* @param caseInsensitive if true use case-insensitive expressions
* @param likeType the type of Like wild card used
*/
DefaultExampleExpression(EntityBean entity, boolean caseInsensitive, LikeType likeType) {
@@ -303,9 +303,7 @@ final class DefaultExampleExpression implements SpiExpression, ExampleExpression
*/
private boolean isZero(Object value) {
if (value instanceof Number) {
if (((Number) value).doubleValue() == 0) {
return true;
}
return ((Number) value).doubleValue() == 0;
}
return false;
}
@@ -186,7 +186,7 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
/**
* Case Insensitive Equal To - property equal to the given value (typically
* using a lower() function to make it case insensitive).
* using a lower() function to make it case-insensitive).
*/
@Override
public Expression ieq(String propertyName, String value) {
@@ -198,7 +198,7 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
/**
* Case Insensitive Equal To - property equal to the given value (typically
* using a lower() function to make it case insensitive).
* using a lower() function to make it case-insensitive).
*/
@Override
public Expression ine(String propertyName, String value) {
@@ -336,7 +336,7 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
}
/**
* Case insensitive {@link #exampleLike(Object)}
* Case-insensitive {@link #exampleLike(Object)}
*/
@Override
public ExampleExpression iexampleLike(Object example) {
@@ -344,7 +344,7 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
}
/**
* Create the query by Example expression which is case sensitive and using
* Create the query by Example expression which is case-sensitive and using
* LikeType.RAW (you need to add you own wildcards % and _).
*/
@Override
@@ -375,9 +375,9 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
}
/**
* Case insensitive Like - property like value where the value contains the
* SQL wild card characters % (percentage) and _ (underscore). Typically uses
* a lower() function to make the expression case insensitive.
* Case-insensitive Like - property like value where the value contains the
* SQL wild card characters % (percentage) and _ (underscore). Typically, uses
* a lower() function to make the expression case-insensitive.
*/
@Override
public Expression ilike(String propertyName, String value) {
@@ -397,8 +397,8 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
}
/**
* Case insensitive Starts With - property like value%. Typically uses a
* lower() function to make the expression case insensitive.
* Case-insensitive Starts With - property like value%. Typically, uses a
* lower() function to make the expression case-insensitive.
*/
@Override
public Expression istartsWith(String propertyName, String value) {
@@ -414,8 +414,8 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
}
/**
* Case insensitive Ends With - property like %value. Typically uses a lower()
* function to make the expression case insensitive.
* Case-insensitive Ends With - property like %value. Typically, uses a lower()
* function to make the expression case-insensitive.
*/
@Override
public Expression iendsWith(String propertyName, String value) {
@@ -431,8 +431,8 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
}
/**
* Case insensitive Contains - property like %value%. Typically uses a lower()
* function to make the expression case insensitive.
* Case-insensitive Contains - property like %value%. Typically, uses a lower()
* function to make the expression case-insensitive.
*/
@Override
public Expression icontains(String propertyName, String value) {
@@ -162,7 +162,7 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
writeDocQuery(context, null);
} else {
// this is a Top level "text" expressions so we may need to wrap in Bool SHOULD etc.
// this is a Top level "text" expressions, so we may need to wrap in Bool SHOULD etc.
if (list.isEmpty()) {
throw new IllegalStateException("empty expression list?");
}
@@ -71,7 +71,7 @@ public interface DocQueryContext {
void writeIn(String propertyName, Object[] values, boolean not) throws IOException;
/**
* Write an Id in expression.
* Write an ID in expression.
*/
void writeIds(Collection<?> idCollection) throws IOException;
@@ -131,7 +131,7 @@ public interface DocQueryContext {
void writeTextQueryString(String search, TextQueryString options) throws IOException;
/**
* Start a Bool which may contain some of Must, Must Not, Should.
* Start a Bool which may contain Must, Must Not, Should.
*/
void startBoolGroup() throws IOException;
@@ -1,19 +1,11 @@
package io.ebeaninternal.server.expression;
import io.ebean.event.BeanQueryRequest;
import io.ebeaninternal.api.BindValuesKey;
import io.ebeaninternal.api.ManyWhereJoins;
import io.ebeaninternal.api.NaturalKeyQueryData;
import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.api.SpiExpression;
import io.ebeaninternal.api.SpiExpressionRequest;
import io.ebeaninternal.api.SpiExpressionValidation;
import io.ebeaninternal.api.SpiQuery;
import io.ebeaninternal.api.*;
import io.ebeaninternal.api.SpiQuery.Type;
import io.ebeaninternal.server.deploy.BeanDescriptor;
import io.ebeaninternal.server.query.CQuery;
import java.io.IOException;
import java.util.List;
final class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreExpression {
@@ -52,7 +44,7 @@ final class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreE
}
@Override
public void writeDocQuery(DocQueryContext context) throws IOException {
public void writeDocQuery(DocQueryContext context) {
throw new IllegalStateException("Not supported");
}
@@ -77,7 +69,7 @@ final class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreE
/**
* Compile/build the sub query.
*/
protected CQuery<?> compileSubQuery(BeanQueryRequest<?> queryRequest) {
CQuery<?> compileSubQuery(BeanQueryRequest<?> queryRequest) {
SpiEbeanServer ebeanServer = (SpiEbeanServer) queryRequest.database();
return ebeanServer.compileQuery(Type.SQ_EXISTS, subQuery, queryRequest.transaction());
}
@@ -51,7 +51,7 @@ final class IdExpression extends NonPrepareExpression implements SpiExpression {
@Override
public void addBindValues(SpiExpressionRequest request) {
// 'flatten' EmbeddedId and multiple Id cases
// 'flatten' EmbeddedId and multiple ID cases
// into an array of the underlying scalar field values
DefaultExpressionRequest r = (DefaultExpressionRequest) request;
Object[] bindIdValues = r.getBeanDescriptor().bindIdValues(value);
@@ -4,7 +4,7 @@ import java.util.Collection;
import java.util.Set;
/**
* Id IN expression common for cache handling.
* ID IN expression common for cache handling.
*/
public interface IdInCommon {
@@ -18,7 +18,7 @@ import java.util.List;
import java.util.Set;
/**
* In a collection of Id values.
* In a collection of ID values.
*/
public final class IdInExpression extends NonPrepareExpression implements IdInCommon {
@@ -73,7 +73,7 @@ public final class IdInExpression extends NonPrepareExpression implements IdInCo
if (idCollection.isEmpty()) {
return;
}
// Bind the Id values including EmbeddedId and multiple Id
// Bind the ID values including EmbeddedId and multiple ID
DefaultExpressionRequest r = (DefaultExpressionRequest) request;
BeanDescriptor<?> descriptor = r.getBeanDescriptor();
@@ -82,7 +82,7 @@ public final class IdInExpression extends NonPrepareExpression implements IdInCo
}
/**
* For use with deleting non attached detail beans during stateless update.
* For use with deleting non-attached detail beans during stateless update.
*/
public void addSqlNoAlias(SpiExpressionRequest request) {
@@ -116,7 +116,7 @@ public final class IdInExpression extends NonPrepareExpression implements IdInCo
}
/**
* Incorporates the number of Id values to bind.
* Incorporates the number of ID values to bind.
*/
@Override
public void queryPlanHash(StringBuilder builder) {
@@ -9,7 +9,6 @@ import io.ebeaninternal.api.SpiExpression;
import io.ebeaninternal.api.SpiExpressionRequest;
import io.ebeaninternal.server.persist.MultiValueWrapper;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -54,7 +53,7 @@ final class InPairsExpression extends AbstractExpression {
}
@Override
public void writeDocQuery(DocQueryContext context) throws IOException {
public void writeDocQuery(DocQueryContext context) {
throw new RuntimeException("Not supported with document query");
}
@@ -1,15 +1,10 @@
package io.ebeaninternal.server.expression;
import io.ebean.event.BeanQueryRequest;
import io.ebeaninternal.api.BindValuesKey;
import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.api.SpiExpression;
import io.ebeaninternal.api.SpiExpressionRequest;
import io.ebeaninternal.api.SpiQuery;
import io.ebeaninternal.api.*;
import io.ebeaninternal.api.SpiQuery.Type;
import io.ebeaninternal.server.query.CQuery;
import java.io.IOException;
import java.util.List;
/**
@@ -42,7 +37,7 @@ final class InQueryExpression extends AbstractExpression implements UnsupportedD
}
@Override
public void writeDocQuery(DocQueryContext context) throws IOException {
public void writeDocQuery(DocQueryContext context) {
throw new IllegalStateException("Not supported");
}
@@ -48,7 +48,7 @@ final class IsEmptyExpression extends AbstractExpression {
}
}
public final String getPropName() {
public String getPropName() {
return propName;
}
@@ -868,7 +868,7 @@ final class JunctionExpression<T> implements SpiJunction<T>, SpiExpression, Expr
}
@Override
public Query<T> select(FetchGroup fetchGroup) {
public Query<T> select(FetchGroup<T> fetchGroup) {
return exprList.select(fetchGroup);
}
@@ -14,7 +14,7 @@ import io.ebeaninternal.server.deploy.BeanDescriptor;
import java.io.IOException;
/**
* A logical And or Or for joining two expressions.
* A logical And or, Or for joining two expressions.
*/
abstract class LogicExpression implements SpiExpression {
@@ -1,16 +1,9 @@
package io.ebeaninternal.server.expression;
import io.ebean.event.BeanQueryRequest;
import io.ebeaninternal.api.BindValuesKey;
import io.ebeaninternal.api.ManyWhereJoins;
import io.ebeaninternal.api.NaturalKeyQueryData;
import io.ebeaninternal.api.SpiExpression;
import io.ebeaninternal.api.SpiExpressionRequest;
import io.ebeaninternal.api.SpiExpressionValidation;
import io.ebeaninternal.api.*;
import io.ebeaninternal.server.deploy.BeanDescriptor;
import java.io.IOException;
/**
* Effectively an expression that has no effect.
*/
@@ -40,7 +33,7 @@ final class NoopExpression implements SpiExpression {
}
@Override
public void writeDocQuery(DocQueryContext context) throws IOException {
public void writeDocQuery(DocQueryContext context) {
}
@Override
@@ -16,7 +16,7 @@ final class RawExpressionBuilder {
*/
static RawExpression buildSingle(String raw, Object value) {
if (isExpand(value, raw, BP_1)) {
Collection val = (Collection) value;
Collection<?> val = (Collection<?>) value;
raw = raw.replace(BP_1, expand(val));
return new RawExpression(raw, val.toArray());
}
@@ -50,8 +50,7 @@ final class RawExpressionBuilder {
return "?" + (i + 1);
}
private static String expand(Collection values) {
private static String expand(Collection<?> values) {
StringBuilder sqlExpand = new StringBuilder(values.size() * 2);
for (int i = 0; i < values.size(); i++) {
if (i > 0) {
@@ -72,7 +71,7 @@ final class RawExpressionBuilder {
if (!isExpand(values[i], raw, match)) {
params.add(values[i]);
} else {
Collection val = (Collection) values[i];
Collection<?> val = (Collection<?>) values[i];
params.addAll(val);
raw = raw.replace(match, expand(val));
}
@@ -10,7 +10,7 @@ import java.util.Objects;
final class Same {
/**
* Return true if both values are null or both an not null.
* Return true if both values are null or both not null.
*/
static boolean sameByNull(Object v1, Object v2) {
return (v1 == null) == (v2 == null);
@@ -55,7 +55,7 @@ public final class SimpleExpression extends AbstractValueExpression {
}
}
public final String getPropName() {
public String getPropName() {
return propName;
}
@@ -21,7 +21,7 @@ Expressions for building WHERE clauses.
<p>
In the code above the LIKE and GREATER THAN Expressions are added to the where clause.
The way this works is that where() returns an ExpressionList which has methods on
it to create the standard expressions (EQUAL TO, LIKE etc).
it to create the standard expressions (EQUAL TO, LIKE etc.)
</p>
<p>
I expect most people to add their expressions in this way. The Expr expression factory