From 06ad636109787ac3f9f6996b4d36e6a7d5aa633d Mon Sep 17 00:00:00 2001 From: haiyangl Date: Mon, 16 Dec 2024 19:19:58 -0800 Subject: [PATCH] 2.1.7 --- CHANGES.md | 4 + README.md | 4 +- .../abacus-query-0.0.1-SNAPSHOT.pom | 2 +- pom.xml | 6 +- .../com/landawn/abacus/condition/Between.java | 2 +- .../com/landawn/abacus/condition/Binary.java | 2 +- .../com/landawn/abacus/condition/Cell.java | 7 +- .../abacus/condition/ConditionFactory.java | 73 +++--- .../landawn/abacus/condition/Criteria.java | 7 +- .../abacus/condition/CriteriaUtil.java | 4 +- .../landawn/abacus/condition/Expression.java | 7 +- .../java/com/landawn/abacus/condition/In.java | 15 +- .../landawn/abacus/condition/InSubQuery.java | 3 +- .../com/landawn/abacus/condition/Join.java | 5 +- .../landawn/abacus/condition/Junction.java | 2 +- .../com/landawn/abacus/condition/Limit.java | 1 - .../abacus/condition/NamedProperty.java | 16 +- .../landawn/abacus/condition/NotBetween.java | 2 +- .../com/landawn/abacus/condition/NotIn.java | 15 +- .../abacus/condition/NotInSubQuery.java | 3 +- .../landawn/abacus/condition/Operator.java | 2 +- .../landawn/abacus/condition/SubQuery.java | 5 +- .../abacus/util/DynamicSQLBuilder.java | 48 ++-- .../com/landawn/abacus/util/ParsedSql.java | 1 - .../com/landawn/abacus/util/QueryBean.java | 2 + .../com/landawn/abacus/util/QueryUtil.java | 4 +- .../com/landawn/abacus/util/SQLBuilder.java | 202 ++++++++-------- .../com/landawn/abacus/util/SQLMapper.java | 3 + .../com/landawn/abacus/util/SQLParser.java | 228 +++++++++--------- .../com/landawn/abacus/util/Selection.java | 24 -- 30 files changed, 330 insertions(+), 369 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 848fc8f..b97b646 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +## 2.1.7 + +* Improvements + ## 2.1.6 * Improvements diff --git a/README.md b/README.md index 37cda4a..cdc3786 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # abacus-query [![Maven Central](https://img.shields.io/maven-central/v/com.landawn/abacus-query.svg)](https://maven-badges.herokuapp.com/maven-central/com.landawn/abacus-query/) -[![Javadocs](https://img.shields.io/badge/javadoc-2.1.6-brightgreen.svg)](https://www.javadoc.io/doc/com.landawn/abacus-query/2.1.6/index.html) +[![Javadocs](https://img.shields.io/badge/javadoc-2.1.7-brightgreen.svg)](https://www.javadoc.io/doc/com.landawn/abacus-query/2.1.7/index.html) ## Download/Installation & [Changes](https://github.com/landawn/abacus-query/blob/master/CHANGES.md): @@ -10,7 +10,7 @@ * Gradle: ```gradle // JDK 1.8 or above: -compile 'com.landawn:abacus-query:2.1.6' +compile 'com.landawn:abacus-query:2.1.7' ``` diff --git a/maven/0.0.1-SNAPSHOT/abacus-query-0.0.1-SNAPSHOT.pom b/maven/0.0.1-SNAPSHOT/abacus-query-0.0.1-SNAPSHOT.pom index b13f9fa..6fcc164 100644 --- a/maven/0.0.1-SNAPSHOT/abacus-query-0.0.1-SNAPSHOT.pom +++ b/maven/0.0.1-SNAPSHOT/abacus-query-0.0.1-SNAPSHOT.pom @@ -77,7 +77,7 @@ com.landawn abacus-common - 5.6.5 + 5.6.8 diff --git a/pom.xml b/pom.xml index 4686bdd..a70a0f5 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.landawn abacus-query - 2.1.7 + 2.1.8 jar abacus-query @@ -25,14 +25,14 @@ com.landawn abacus-common - 5.6.5 + 5.6.8 provided org.projectlombok lombok - 1.18.34 + 1.18.36 provided diff --git a/src/main/java/com/landawn/abacus/condition/Between.java b/src/main/java/com/landawn/abacus/condition/Between.java index 216762d..224ef44 100644 --- a/src/main/java/com/landawn/abacus/condition/Between.java +++ b/src/main/java/com/landawn/abacus/condition/Between.java @@ -160,7 +160,7 @@ public void clearParameters() { @SuppressWarnings("unchecked") @Override public T copy() { - final Between copy = (Between) super.copy(); + final Between copy = super.copy(); if (minValue instanceof Condition) { copy.minValue = ((Condition) minValue).copy(); diff --git a/src/main/java/com/landawn/abacus/condition/Binary.java b/src/main/java/com/landawn/abacus/condition/Binary.java index efc157b..fe344d3 100644 --- a/src/main/java/com/landawn/abacus/condition/Binary.java +++ b/src/main/java/com/landawn/abacus/condition/Binary.java @@ -119,7 +119,7 @@ public void clearParameters() { @SuppressWarnings("unchecked") @Override public T copy() { - final Binary copy = (Binary) super.copy(); + final Binary copy = super.copy(); if (propValue instanceof Condition) { copy.propValue = ((Condition) propValue).copy(); diff --git a/src/main/java/com/landawn/abacus/condition/Cell.java b/src/main/java/com/landawn/abacus/condition/Cell.java index e8af317..9ce9a97 100644 --- a/src/main/java/com/landawn/abacus/condition/Cell.java +++ b/src/main/java/com/landawn/abacus/condition/Cell.java @@ -70,10 +70,9 @@ public void setCondition(final Condition condition) { * * @return */ - @SuppressWarnings("unchecked") @Override public List getParameters() { - return (condition == null) ? N. emptyList() : condition.getParameters(); + return (condition == null) ? N.emptyList() : condition.getParameters(); } /** @@ -94,7 +93,7 @@ public void clearParameters() { @SuppressWarnings("unchecked") @Override public T copy() { - final Cell copy = (Cell) super.copy(); + final Cell copy = super.copy(); if (condition != null) { copy.condition = condition.copy(); @@ -121,7 +120,7 @@ public String toString(final NamingPolicy namingPolicy) { @Override public int hashCode() { int h = 17; - h = (h * 31) + operator.hashCode(); + h = (h * 31) + ((operator == null) ? 0 : operator.hashCode()); return (h * 31) + ((condition == null) ? 0 : condition.hashCode()); } diff --git a/src/main/java/com/landawn/abacus/condition/ConditionFactory.java b/src/main/java/com/landawn/abacus/condition/ConditionFactory.java index a5e3d0c..02bcc70 100644 --- a/src/main/java/com/landawn/abacus/condition/ConditionFactory.java +++ b/src/main/java/com/landawn/abacus/condition/ConditionFactory.java @@ -188,23 +188,22 @@ public static Or eqOr(final String propName, final Collection propValues) { public static Or eqOr(final Map props) { N.checkArgNotEmpty(props, "props"); - final Collection selectPropNames = props.keySet(); - final Iterator iter = selectPropNames.iterator(); - - if (selectPropNames.size() == 1) { - final String propName = iter.next(); - return or(eq(propName, props.get(propName))); - } else if (selectPropNames.size() == 2) { - final String propName1 = iter.next(); - final String propName2 = iter.next(); - return eq(propName1, props.get(propName1)).or(eq(propName2, props.get(propName2))); + final Iterator> propIter = props.entrySet().iterator(); + + if (props.size() == 1) { + final Map.Entry prop = propIter.next(); + return or(eq(prop.getKey(), prop.getValue())); + } else if (props.size() == 2) { + final Map.Entry prop1 = propIter.next(); + final Map.Entry prop2 = propIter.next(); + return eq(prop1.getKey(), prop1.getValue()).or(eq(prop2.getKey(), prop2.getValue())); } else { - final Condition[] conds = new Condition[selectPropNames.size()]; - String propName = null; + final Condition[] conds = new Condition[props.size()]; + Map.Entry prop = null; - for (int i = 0, size = selectPropNames.size(); i < size; i++) { - propName = iter.next(); - conds[i] = CF.eq(propName, props.get(propName)); + for (int i = 0, size = props.size(); i < size; i++) { + prop = propIter.next(); + conds[i] = CF.eq(prop.getKey(), prop.getValue()); } return or(conds); @@ -289,27 +288,27 @@ public static Or eqOr(final String propName1, final Object propValue1, final Str public static And eqAnd(final Map props) { N.checkArgNotEmpty(props, "props"); - final Collection selectPropNames = props.keySet(); - final Iterator iter = selectPropNames.iterator(); + final Iterator> propIter = props.entrySet().iterator(); - if (selectPropNames.size() == 1) { - final String propName = iter.next(); - return and(eq(propName, props.get(propName))); - } else if (selectPropNames.size() == 2) { - final String propName1 = iter.next(); - final String propName2 = iter.next(); - return eq(propName1, props.get(propName1)).and(eq(propName2, props.get(propName2))); + if (props.size() == 1) { + final Map.Entry prop = propIter.next(); + return and(eq(prop.getKey(), prop.getValue())); + } else if (props.size() == 2) { + final Map.Entry prop1 = propIter.next(); + final Map.Entry prop2 = propIter.next(); + return eq(prop1.getKey(), prop1.getValue()).and(eq(prop2.getKey(), prop2.getValue())); } else { - final Condition[] conds = new Condition[selectPropNames.size()]; - String propName = null; + final Condition[] conds = new Condition[props.size()]; + Map.Entry prop = null; - for (int i = 0, size = selectPropNames.size(); i < size; i++) { - propName = iter.next(); - conds[i] = CF.eq(propName, props.get(propName)); + for (int i = 0, size = props.size(); i < size; i++) { + prop = propIter.next(); + conds[i] = CF.eq(prop.getKey(), prop.getValue()); } return and(conds); } + } /** @@ -1188,7 +1187,7 @@ public static GroupBy groupBy(final String propName, final SortDirection directi * @return */ public static GroupBy groupBy(final String propNameA, final SortDirection directionA, final String propNameB, final SortDirection directionB) { - return groupBy(N. asLinkedHashMap(propNameA, directionA, propNameB, directionB)); + return groupBy(N.asLinkedHashMap(propNameA, directionA, propNameB, directionB)); } /** @@ -1203,7 +1202,7 @@ public static GroupBy groupBy(final String propNameA, final SortDirection direct */ public static GroupBy groupBy(final String propNameA, final SortDirection directionA, final String propNameB, final SortDirection directionB, final String propNameC, final SortDirection directionC) { - return groupBy(N. asLinkedHashMap(propNameA, directionA, propNameB, directionB, propNameC, directionC)); + return groupBy(N.asLinkedHashMap(propNameA, directionA, propNameB, directionB, propNameC, directionC)); } /** @@ -1328,7 +1327,7 @@ public static OrderBy orderBy(final String propName, final SortDirection directi * @return */ public static OrderBy orderBy(final String propNameA, final SortDirection directionA, final String propNameB, final SortDirection directionB) { - return orderBy(N. asLinkedHashMap(propNameA, directionA, propNameB, directionB)); + return orderBy(N.asLinkedHashMap(propNameA, directionA, propNameB, directionB)); } /** @@ -1343,7 +1342,7 @@ public static OrderBy orderBy(final String propNameA, final SortDirection direct */ public static OrderBy orderBy(final String propNameA, final SortDirection directionA, final String propNameB, final SortDirection directionB, final String propNameC, final SortDirection directionC) { - return orderBy(N. asLinkedHashMap(propNameA, directionA, propNameB, directionB, propNameC, directionC)); + return orderBy(N.asLinkedHashMap(propNameA, directionA, propNameB, directionB, propNameC, directionC)); } /** @@ -2025,7 +2024,7 @@ public static Criteria groupBy(final Condition condition) { * @return */ @SafeVarargs - public static final Criteria groupBy(final String... propNames) { + public static Criteria groupBy(final String... propNames) { return CF.criteria().groupBy(propNames); } @@ -2090,7 +2089,7 @@ public static Criteria having(final String condition) { * @param propNames * @return */ - public static final Criteria orderByAsc(final String... propNames) { + public static Criteria orderByAsc(final String... propNames) { return CF.criteria().orderByAsc(propNames); } @@ -2108,7 +2107,7 @@ public static Criteria orderByAsc(final Collection propNames) { * @param propNames * @return */ - public static final Criteria orderByDesc(final String... propNames) { + public static Criteria orderByDesc(final String... propNames) { return CF.criteria().orderByDesc(propNames); } @@ -2136,7 +2135,7 @@ public static Criteria orderBy(final Condition condition) { * @return */ @SafeVarargs - public static final Criteria orderBy(final String... propNames) { + public static Criteria orderBy(final String... propNames) { return CF.criteria().orderBy(propNames); } diff --git a/src/main/java/com/landawn/abacus/condition/Criteria.java b/src/main/java/com/landawn/abacus/condition/Criteria.java index 4d11fc7..39d94fe 100644 --- a/src/main/java/com/landawn/abacus/condition/Criteria.java +++ b/src/main/java/com/landawn/abacus/condition/Criteria.java @@ -30,7 +30,7 @@ /** * At present, Supports * {@code Where, OrderBy, GroupBy, Having, Join, Limit, ForUpdate, Union, UnionAll, Intersect, Except} clause. Each - * {@code clause} is independent. A {@code clause} should not be included in another {@code clause}. If there more than + * {@code clause} is independent. A {@code clause} should not be included in another {@code clause}. If there are more than * one {@code clause}, they should be composed in one {@code Criteria} condition. * */ @@ -113,7 +113,6 @@ public Cell getHaving() { * * @return */ - @SuppressWarnings("unchecked") public List getAggregation() { List result = null; @@ -233,7 +232,6 @@ public void clear() { * * @return */ - @SuppressWarnings("unchecked") @Override public List getParameters() { if (conditionList.size() > 0) { @@ -758,7 +756,7 @@ public Criteria minus(final SubQuery subQuery) { @Override @SuppressWarnings("unchecked") public T copy() { - final Criteria result = (Criteria) super.copy(); + final Criteria result = super.copy(); result.conditionList = new ArrayList<>(); @@ -774,6 +772,7 @@ public T copy() { * @param namingPolicy * @return */ + @SuppressWarnings("StringConcatenationInLoop") @Override public String toString(final NamingPolicy namingPolicy) { final String preselect = Strings.isEmpty(this.preselect) ? Strings.EMPTY_STRING : WD.SPACE + this.preselect; //NOSONAR diff --git a/src/main/java/com/landawn/abacus/condition/CriteriaUtil.java b/src/main/java/com/landawn/abacus/condition/CriteriaUtil.java index 65d477b..9e87032 100644 --- a/src/main/java/com/landawn/abacus/condition/CriteriaUtil.java +++ b/src/main/java/com/landawn/abacus/condition/CriteriaUtil.java @@ -76,7 +76,7 @@ public static Set getClauseOperators() { * @return true, if is clause */ public static boolean isClause(final Operator operator) { - return (operator == null) ? false : clauseOperators.contains(operator); + return operator != null && clauseOperators.contains(operator); } /** @@ -114,7 +114,7 @@ public static boolean isClause(final Condition condition) { // } else { // return isClause(condition.getOperator()); // } - return (condition == null) ? false : isClause(condition.getOperator()); + return condition != null && isClause(condition.getOperator()); } /** diff --git a/src/main/java/com/landawn/abacus/condition/Expression.java b/src/main/java/com/landawn/abacus/condition/Expression.java index 597b42d..b61546b 100644 --- a/src/main/java/com/landawn/abacus/condition/Expression.java +++ b/src/main/java/com/landawn/abacus/condition/Expression.java @@ -73,7 +73,7 @@ */ public class Expression extends AbstractCondition { - static final String NULL_STRING = "null".intern(); + static final String NULL_STRING = "null"; static final char[] NULL_CHAR_ARRAY = NULL_STRING.toCharArray(); @@ -87,7 +87,7 @@ public class Expression extends AbstractCondition { private static final String LEFT_SHIFT = "<<"; - private static final String RIGTH_SHIFT = ">>"; + private static final String RIGHT_SHIFT = ">>"; private static final String NULL = "NULL"; @@ -421,7 +421,7 @@ public static String lShift(final Object... objects) { */ @SafeVarargs public static String rShift(final Object... objects) { - return link(RIGTH_SHIFT, objects); + return link(RIGHT_SHIFT, objects); } /** @@ -919,7 +919,6 @@ public static String upper(final String st) { * * @return */ - @SuppressWarnings("unchecked") @Override public List getParameters() { return N.emptyList(); diff --git a/src/main/java/com/landawn/abacus/condition/In.java b/src/main/java/com/landawn/abacus/condition/In.java index 7065120..7f279a0 100644 --- a/src/main/java/com/landawn/abacus/condition/In.java +++ b/src/main/java/com/landawn/abacus/condition/In.java @@ -67,7 +67,6 @@ public String getPropName() { * * @return */ - @SuppressWarnings("unchecked") public List getValues() { //NOSONAR return values; } @@ -114,7 +113,7 @@ public void clearParameters() { @SuppressWarnings("unchecked") @Override public T copy() { - final In copy = (In) super.copy(); + final In copy = super.copy(); copy.values = new ArrayList<>(values); @@ -128,13 +127,11 @@ public T copy() { */ @Override public String toString(final NamingPolicy namingPolicy) { - if (namingPolicy == NamingPolicy.NO_CHANGE) { - return propName + WD._SPACE + getOperator().toString() - + Joiner.with(WD.COMMA_SPACE, WD.SPACE_PARENTHESES_L, WD.PARENTHESES_R).reuseCachedBuffer().appendAll(values).toString(); - } else { - return namingPolicy.convert(propName) + WD._SPACE + getOperator().toString() - + Joiner.with(WD.COMMA_SPACE, WD.SPACE_PARENTHESES_L, WD.PARENTHESES_R).reuseCachedBuffer().appendAll(values).toString(); - } + //noinspection resource + return Joiner.with(WD.COMMA_SPACE, namingPolicy.convert(propName) + WD._SPACE + getOperator().toString() + WD.SPACE_PARENTHESES_L, WD.PARENTHESES_R) + .reuseCachedBuffer() + .appendAll(values) + .toString(); } /** diff --git a/src/main/java/com/landawn/abacus/condition/InSubQuery.java b/src/main/java/com/landawn/abacus/condition/InSubQuery.java index 6430885..6979aa5 100644 --- a/src/main/java/com/landawn/abacus/condition/InSubQuery.java +++ b/src/main/java/com/landawn/abacus/condition/InSubQuery.java @@ -97,7 +97,6 @@ public Collection getPropNames() { * * @return */ - @SuppressWarnings("unchecked") public SubQuery getSubQuery() { return subQuery; } @@ -137,7 +136,7 @@ public void clearParameters() { @SuppressWarnings("unchecked") @Override public T copy() { - final InSubQuery copy = (InSubQuery) super.copy(); + final InSubQuery copy = super.copy(); copy.subQuery = subQuery.copy(); diff --git a/src/main/java/com/landawn/abacus/condition/Join.java b/src/main/java/com/landawn/abacus/condition/Join.java index 70cb86a..aed91de 100644 --- a/src/main/java/com/landawn/abacus/condition/Join.java +++ b/src/main/java/com/landawn/abacus/condition/Join.java @@ -106,10 +106,9 @@ public T getCondition() { * * @return */ - @SuppressWarnings("unchecked") @Override public List getParameters() { - return (condition == null) ? N. emptyList() : condition.getParameters(); + return (condition == null) ? N.emptyList() : condition.getParameters(); } /** @@ -130,7 +129,7 @@ public void clearParameters() { @Override @SuppressWarnings("unchecked") public T copy() { - final Join copy = (Join) super.copy(); + final Join copy = super.copy(); if (joinEntities != null) { copy.joinEntities = new ArrayList<>(joinEntities); diff --git a/src/main/java/com/landawn/abacus/condition/Junction.java b/src/main/java/com/landawn/abacus/condition/Junction.java index 4a7c170..6424c3c 100644 --- a/src/main/java/com/landawn/abacus/condition/Junction.java +++ b/src/main/java/com/landawn/abacus/condition/Junction.java @@ -176,7 +176,7 @@ public void clearParameters() { @Override @SuppressWarnings("unchecked") public T copy() { - final Junction result = (Junction) super.copy(); + final Junction result = super.copy(); result.conditionList = new ArrayList<>(); diff --git a/src/main/java/com/landawn/abacus/condition/Limit.java b/src/main/java/com/landawn/abacus/condition/Limit.java index 545f7b6..ee2d985 100644 --- a/src/main/java/com/landawn/abacus/condition/Limit.java +++ b/src/main/java/com/landawn/abacus/condition/Limit.java @@ -102,7 +102,6 @@ public int getOffset() { * * @return */ - @SuppressWarnings("unchecked") @Override public List getParameters() { return N.emptyList(); diff --git a/src/main/java/com/landawn/abacus/condition/NamedProperty.java b/src/main/java/com/landawn/abacus/condition/NamedProperty.java index 7f9970d..756b981 100644 --- a/src/main/java/com/landawn/abacus/condition/NamedProperty.java +++ b/src/main/java/com/landawn/abacus/condition/NamedProperty.java @@ -32,18 +32,13 @@ public final class NamedProperty { // for Kryo final String propName; - // For Kryo - NamedProperty() { - propName = null; - } - /** * * * @param propName */ public NamedProperty(final String propName) { - this.propName = propName; + this.propName = N.requireNonNull(propName); } /** @@ -56,14 +51,7 @@ public static NamedProperty of(final String propName) { throw new IllegalArgumentException("the property name can't be null or empty string."); } - NamedProperty instance = instancePool.get(propName); - - if (instance == null) { - instance = new NamedProperty(propName); - instancePool.put(propName, instance); - } - - return instance; + return instancePool.computeIfAbsent(propName, NamedProperty::new); } /** diff --git a/src/main/java/com/landawn/abacus/condition/NotBetween.java b/src/main/java/com/landawn/abacus/condition/NotBetween.java index eb989ea..22da24f 100644 --- a/src/main/java/com/landawn/abacus/condition/NotBetween.java +++ b/src/main/java/com/landawn/abacus/condition/NotBetween.java @@ -160,7 +160,7 @@ public void clearParameters() { @SuppressWarnings("unchecked") @Override public T copy() { - final NotBetween copy = (NotBetween) super.copy(); + final NotBetween copy = super.copy(); if (minValue instanceof Condition) { copy.minValue = ((Condition) minValue).copy(); diff --git a/src/main/java/com/landawn/abacus/condition/NotIn.java b/src/main/java/com/landawn/abacus/condition/NotIn.java index c7040e2..5148b08 100644 --- a/src/main/java/com/landawn/abacus/condition/NotIn.java +++ b/src/main/java/com/landawn/abacus/condition/NotIn.java @@ -67,7 +67,6 @@ public String getPropName() { * * @return */ - @SuppressWarnings("unchecked") public List getValues() { //NOSONAR return values; } @@ -112,7 +111,7 @@ public void clearParameters() { @SuppressWarnings("unchecked") @Override public T copy() { - final NotIn copy = (NotIn) super.copy(); + final NotIn copy = super.copy(); copy.values = new ArrayList<>(values); @@ -126,13 +125,11 @@ public T copy() { */ @Override public String toString(final NamingPolicy namingPolicy) { - if (namingPolicy == NamingPolicy.NO_CHANGE) { - return propName + WD._SPACE + getOperator().toString() - + Joiner.with(WD.COMMA_SPACE, WD.SPACE_PARENTHESES_L, WD.PARENTHESES_R).reuseCachedBuffer().appendAll(values).toString(); - } else { - return namingPolicy.convert(propName) + WD._SPACE + getOperator().toString() - + Joiner.with(WD.COMMA_SPACE, WD.SPACE_PARENTHESES_L, WD.PARENTHESES_R).reuseCachedBuffer().appendAll(values).toString(); - } + //noinspection resource + return Joiner.with(WD.COMMA_SPACE, namingPolicy.convert(propName) + WD._SPACE + getOperator().toString() + WD.SPACE_PARENTHESES_L, WD.PARENTHESES_R) + .reuseCachedBuffer() + .appendAll(values) + .toString(); } /** diff --git a/src/main/java/com/landawn/abacus/condition/NotInSubQuery.java b/src/main/java/com/landawn/abacus/condition/NotInSubQuery.java index ca60128..45e70ab 100644 --- a/src/main/java/com/landawn/abacus/condition/NotInSubQuery.java +++ b/src/main/java/com/landawn/abacus/condition/NotInSubQuery.java @@ -98,7 +98,6 @@ public Collection getPropNames() { * * @return */ - @SuppressWarnings("unchecked") public SubQuery getSubQuery() { return subQuery; } @@ -136,7 +135,7 @@ public void clearParameters() { @SuppressWarnings("unchecked") @Override public T copy() { - final NotInSubQuery copy = (NotInSubQuery) super.copy(); + final NotInSubQuery copy = super.copy(); copy.subQuery = subQuery.copy(); diff --git a/src/main/java/com/landawn/abacus/condition/Operator.java b/src/main/java/com/landawn/abacus/condition/Operator.java index 0d83da4..8203c20 100644 --- a/src/main/java/com/landawn/abacus/condition/Operator.java +++ b/src/main/java/com/landawn/abacus/condition/Operator.java @@ -244,7 +244,7 @@ public enum Operator { * @return */ public static synchronized Operator getOperator(final String name) { - if (operatorMap.size() == 0) { + if (operatorMap.isEmpty()) { final Operator[] values = Operator.values(); for (final Operator value : values) { diff --git a/src/main/java/com/landawn/abacus/condition/SubQuery.java b/src/main/java/com/landawn/abacus/condition/SubQuery.java index 238f74c..640b0f7 100644 --- a/src/main/java/com/landawn/abacus/condition/SubQuery.java +++ b/src/main/java/com/landawn/abacus/condition/SubQuery.java @@ -178,10 +178,9 @@ public Condition getCondition() { * * @return */ - @SuppressWarnings("unchecked") @Override public List getParameters() { - return condition == null ? N. emptyList() : condition.getParameters(); + return condition == null ? N.emptyList() : condition.getParameters(); } /** @@ -202,7 +201,7 @@ public void clearParameters() { @Override @SuppressWarnings("unchecked") public T copy() { - final SubQuery result = (SubQuery) super.copy(); + final SubQuery result = super.copy(); if (propNames != null) { result.propNames = new ArrayList<>(propNames); diff --git a/src/main/java/com/landawn/abacus/util/DynamicSQLBuilder.java b/src/main/java/com/landawn/abacus/util/DynamicSQLBuilder.java index d6a951a..95488f0 100644 --- a/src/main/java/com/landawn/abacus/util/DynamicSQLBuilder.java +++ b/src/main/java/com/landawn/abacus/util/DynamicSQLBuilder.java @@ -376,7 +376,7 @@ public static class Select { * @return */ public Select append(final String column) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(", "); } else { sb.append("SELECT "); @@ -394,7 +394,7 @@ public Select append(final String column) { * @return */ public Select append(final String column, final String alias) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(", "); } else { sb.append("SELECT "); @@ -411,7 +411,7 @@ public Select append(final String column, final String alias) { * @return */ public Select append(final Collection columns) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(", "); } else { sb.append("SELECT "); @@ -429,7 +429,7 @@ public Select append(final Collection columns) { * @return */ public Select append(final Map columnsAndAliasMap) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(", "); } else { sb.append("SELECT "); @@ -449,7 +449,7 @@ public Select append(final Map columnsAndAliasMap) { */ public Select appendIf(final boolean b, final String str) { if (b) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(", "); } else { sb.append("SELECT "); @@ -470,7 +470,7 @@ public Select appendIf(final boolean b, final String str) { * @return */ public Select appendIfOrElse(final boolean b, final String strToAppendForTrue, final String strToAppendForFalse) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(", "); } else { sb.append("SELECT "); @@ -509,7 +509,7 @@ public static class From { * @return */ public From append(final String table) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(", "); } else { sb.append("FROM "); @@ -527,7 +527,7 @@ public From append(final String table) { * @return */ public From append(final String table, final String alias) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(", "); } else { sb.append("FROM"); @@ -607,7 +607,7 @@ public From fullJoin(final String table, final String on) { */ public From appendIf(final boolean b, final String str) { if (b) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(", "); } else { sb.append("FROM "); @@ -628,7 +628,7 @@ public From appendIf(final boolean b, final String str) { * @return */ public From appendIfOrElse(final boolean b, final String strToAppendForTrue, final String strToAppendForFalse) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(", "); } else { sb.append("FROM "); @@ -667,7 +667,7 @@ public static class Where { * @return */ public Where append(final String cond) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(" "); } else { sb.append("WHERE "); @@ -755,7 +755,7 @@ public Where or(final String cond) { */ public Where appendIf(final boolean b, final String str) { if (b) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(" "); } else { sb.append("WHERE "); @@ -776,7 +776,7 @@ public Where appendIf(final boolean b, final String str) { * @return */ public Where appendIfOrElse(final boolean b, final String strToAppendForTrue, final String strToAppendForFalse) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(" "); } else { sb.append("WHERE "); @@ -815,7 +815,7 @@ public static class GroupBy { * @return */ public GroupBy append(final String column) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(", "); } else { sb.append("GROUP BY "); @@ -832,7 +832,7 @@ public GroupBy append(final String column) { * @return */ public GroupBy append(final Collection columns) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(", "); } else { sb.append("GROUP BY "); @@ -852,7 +852,7 @@ public GroupBy append(final Collection columns) { */ public GroupBy appendIf(final boolean b, final String str) { if (b) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(", "); } else { sb.append("GROUP BY "); @@ -873,7 +873,7 @@ public GroupBy appendIf(final boolean b, final String str) { * @return */ public GroupBy appendIfOrElse(final boolean b, final String strToAppendForTrue, final String strToAppendForFalse) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(", "); } else { sb.append("GROUP BY "); @@ -912,7 +912,7 @@ public static class Having { * @return */ public Having append(final String cond) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(" "); } else { sb.append("HAVING "); @@ -954,7 +954,7 @@ public Having or(final String cond) { */ public Having appendIf(final boolean b, final String str) { if (b) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(" "); } else { sb.append("HAVING "); @@ -975,7 +975,7 @@ public Having appendIf(final boolean b, final String str) { * @return */ public Having appendIfOrElse(final boolean b, final String strToAppendForTrue, final String strToAppendForFalse) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(" "); } else { sb.append("HAVING "); @@ -1014,7 +1014,7 @@ public static class OrderBy { * @return */ public OrderBy append(final String column) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(", "); } else { sb.append("ORDER BY "); @@ -1031,7 +1031,7 @@ public OrderBy append(final String column) { * @return */ public OrderBy append(final Collection columns) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(", "); } else { sb.append("ORDER BY "); @@ -1051,7 +1051,7 @@ public OrderBy append(final Collection columns) { */ public OrderBy appendIf(final boolean b, final String str) { if (b) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(", "); } else { sb.append("ORDER BY "); @@ -1072,7 +1072,7 @@ public OrderBy appendIf(final boolean b, final String str) { * @return */ public OrderBy appendIfOrElse(final boolean b, final String strToAppendForTrue, final String strToAppendForFalse) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(", "); } else { sb.append("ORDER BY "); diff --git a/src/main/java/com/landawn/abacus/util/ParsedSql.java b/src/main/java/com/landawn/abacus/util/ParsedSql.java index 5ccb68b..dc4502f 100644 --- a/src/main/java/com/landawn/abacus/util/ParsedSql.java +++ b/src/main/java/com/landawn/abacus/util/ParsedSql.java @@ -67,7 +67,6 @@ public final class ParsedSql { private int couchbaseParameterCount; - @SuppressWarnings({ "unchecked" }) private ParsedSql(final String sql) { this.sql = sql.trim(); diff --git a/src/main/java/com/landawn/abacus/util/QueryBean.java b/src/main/java/com/landawn/abacus/util/QueryBean.java index 4f55a22..b742b48 100644 --- a/src/main/java/com/landawn/abacus/util/QueryBean.java +++ b/src/main/java/com/landawn/abacus/util/QueryBean.java @@ -368,8 +368,10 @@ public OrderBy toOrderBy() { String ret = null; if (firstEle.isPresent() && firstEle.get() instanceof Number) { + //noinspection resource,DuplicateExpressions ret = StreamEx.of(c).map(N::stringOf).join(", ", (column == null ? "" : column + " ") + op.sqlOperator + " (", ")"); } else { + //noinspection resource,DuplicateExpressions ret = StreamEx.of(c).map(it -> "'" + N.stringOf(it) + "'").join(", ", (column == null ? "" : column + " ") + op.sqlOperator + " (", ")"); } diff --git a/src/main/java/com/landawn/abacus/util/QueryUtil.java b/src/main/java/com/landawn/abacus/util/QueryUtil.java index 0c153aa..109786b 100644 --- a/src/main/java/com/landawn/abacus/util/QueryUtil.java +++ b/src/main/java/com/landawn/abacus/util/QueryUtil.java @@ -168,7 +168,7 @@ static ImmutableMap registerEntityPropColumnNameMap(final Class< final Type propType = propInfo.type.isCollection() ? propInfo.type.getElementType() : propInfo.type; if (propType.isBean() && (registeringClasses == null || !registeringClasses.contains(propType.clazz()))) { - final Set> newRegisteringClasses = registeringClasses == null ? N.> newLinkedHashSet() : registeringClasses; + final Set> newRegisteringClasses = registeringClasses == null ? N.newLinkedHashSet() : registeringClasses; newRegisteringClasses.add(entityClass); final Map subPropColumnNameMap = registerEntityPropColumnNameMap(propType.clazz(), namingPolicy, newRegisteringClasses); @@ -193,7 +193,7 @@ static ImmutableMap registerEntityPropColumnNameMap(final Class< // } if (N.isEmpty(propColumnNameMap)) { - propColumnNameMap = N. emptyMap(); + propColumnNameMap = N.emptyMap(); } final ImmutableMap result = ImmutableMap.wrap(propColumnNameMap); diff --git a/src/main/java/com/landawn/abacus/util/SQLBuilder.java b/src/main/java/com/landawn/abacus/util/SQLBuilder.java index f7c7834..14741a5 100644 --- a/src/main/java/com/landawn/abacus/util/SQLBuilder.java +++ b/src/main/java/com/landawn/abacus/util/SQLBuilder.java @@ -33,12 +33,8 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.function.BiConsumer; +import com.landawn.abacus.annotation.*; import com.landawn.abacus.annotation.Beta; -import com.landawn.abacus.annotation.Internal; -import com.landawn.abacus.annotation.NonUpdatable; -import com.landawn.abacus.annotation.ReadOnly; -import com.landawn.abacus.annotation.ReadOnlyId; -import com.landawn.abacus.annotation.Table; import com.landawn.abacus.condition.Between; import com.landawn.abacus.condition.Binary; import com.landawn.abacus.condition.Cell; @@ -252,6 +248,10 @@ public abstract class SQLBuilder { // NOSONAR static final String SPACE_AS_SPACE = WD.SPACE + WD.AS + WD.SPACE; + static final String SELECT_PART = "selectPart"; + static final String PROP_OR_COLUMN_NAMES = "propOrColumnNames"; + static final String PROP_OR_COLUMN_NAME_ALIASES = "propOrColumnNameAliases"; + private static final Set sqlKeyWords = N.newHashSet(1024); static { @@ -1047,7 +1047,7 @@ private SQLBuilder from(final String tableName, final String fromCause) { final boolean isForSelect = _op == OperationType.QUERY; if (N.notEmpty(_propOrColumnNames)) { - if (_entityClass != null && withAlias == false && _propOrColumnNames == QueryUtil.getSelectPropNames(_entityClass, false, null)) { // NOSONAR + if (_entityClass != null && !withAlias && _propOrColumnNames == QueryUtil.getSelectPropNames(_entityClass, false, null)) { // NOSONAR String fullSelectParts = fullSelectPartsPool.get(_namingPolicy).get(_entityClass); if (Strings.isEmpty(fullSelectParts)) { @@ -1111,10 +1111,8 @@ private SQLBuilder from(final String tableName, final String fromCause) { for (final Selection selection : _multiSelects) { selectionEntityClass = selection.entityClass(); - selectionBeanInfo = selectionEntityClass == null && ClassUtil.isBeanClass(selectionEntityClass) == false ? null - : ParserUtil.getBeanInfo(selectionEntityClass); - selectionPropColumnNameMap = selectionEntityClass == null && ClassUtil.isBeanClass(selectionEntityClass) == false ? null - : prop2ColumnNameMap(selectionEntityClass, _namingPolicy); + selectionBeanInfo = ClassUtil.isBeanClass(selectionEntityClass) ? ParserUtil.getBeanInfo(selectionEntityClass) : null; + selectionPropColumnNameMap = ClassUtil.isBeanClass(selectionEntityClass) ? prop2ColumnNameMap(selectionEntityClass, _namingPolicy) : null; selectionTableAlias = selection.tableAlias(); selectionClassAlias = selection.classAlias(); @@ -1148,7 +1146,7 @@ private void addPropColumnMapForAlias(final Class entityClass, final String a _aliasPropColumnNameMap = new HashMap<>(); } - if (N.isEmpty(_propColumnNameMap) && entityClass != null && ClassUtil.isBeanClass(entityClass)) { + if (N.isEmpty(_propColumnNameMap) && ClassUtil.isBeanClass(entityClass)) { _propColumnNameMap = prop2ColumnNameMap(entityClass, _namingPolicy); } @@ -1202,7 +1200,7 @@ public SQLBuilder join(final Class entityClass, final String alias) { _sb.append(_SPACE_JOIN_SPACE); if (Strings.isNotEmpty(alias)) { - _sb.append(getTableName(entityClass, _namingPolicy) + " " + alias); + _sb.append(getTableName(entityClass, _namingPolicy)).append(" ").append(alias); } else { _sb.append(getTableName(entityClass, _namingPolicy)); } @@ -1257,7 +1255,7 @@ public SQLBuilder innerJoin(final Class entityClass, final String alias) { _sb.append(_SPACE_INNER_JOIN_SPACE); if (Strings.isNotEmpty(alias)) { - _sb.append(getTableName(entityClass, _namingPolicy) + " " + alias); + _sb.append(getTableName(entityClass, _namingPolicy)).append(" ").append(alias); } else { _sb.append(getTableName(entityClass, _namingPolicy)); } @@ -1312,7 +1310,7 @@ public SQLBuilder leftJoin(final Class entityClass, final String alias) { _sb.append(_SPACE_LEFT_JOIN_SPACE); if (Strings.isNotEmpty(alias)) { - _sb.append(getTableName(entityClass, _namingPolicy) + " " + alias); + _sb.append(getTableName(entityClass, _namingPolicy)).append(" ").append(alias); } else { _sb.append(getTableName(entityClass, _namingPolicy)); } @@ -1367,7 +1365,7 @@ public SQLBuilder rightJoin(final Class entityClass, final String alias) { _sb.append(_SPACE_RIGHT_JOIN_SPACE); if (Strings.isNotEmpty(alias)) { - _sb.append(getTableName(entityClass, _namingPolicy) + " " + alias); + _sb.append(getTableName(entityClass, _namingPolicy)).append(" ").append(alias); } else { _sb.append(getTableName(entityClass, _namingPolicy)); } @@ -1422,7 +1420,7 @@ public SQLBuilder fullJoin(final Class entityClass, final String alias) { _sb.append(_SPACE_FULL_JOIN_SPACE); if (Strings.isNotEmpty(alias)) { - _sb.append(getTableName(entityClass, _namingPolicy) + " " + alias); + _sb.append(getTableName(entityClass, _namingPolicy)).append(" ").append(alias); } else { _sb.append(getTableName(entityClass, _namingPolicy)); } @@ -1477,7 +1475,7 @@ public SQLBuilder crossJoin(final Class entityClass, final String alias) { _sb.append(_SPACE_CROSS_JOIN_SPACE); if (Strings.isNotEmpty(alias)) { - _sb.append(getTableName(entityClass, _namingPolicy) + " " + alias); + _sb.append(getTableName(entityClass, _namingPolicy)).append(" ").append(alias); } else { _sb.append(getTableName(entityClass, _namingPolicy)); } @@ -1532,7 +1530,7 @@ public SQLBuilder naturalJoin(final Class entityClass, final String alias) { _sb.append(_SPACE_NATURAL_JOIN_SPACE); if (Strings.isNotEmpty(alias)) { - _sb.append(getTableName(entityClass, _namingPolicy) + " " + alias); + _sb.append(getTableName(entityClass, _namingPolicy)).append(" ").append(alias); } else { _sb.append(getTableName(entityClass, _namingPolicy)); } @@ -3209,7 +3207,7 @@ public void accept(final Throwables.BiConsumer entityClass, final Condition cond) first. - if (_sb.length() > 0) { + if (!_sb.isEmpty()) { return; } @@ -3227,15 +3225,10 @@ void init(final boolean setForUpdate) { } else if (_op == OperationType.DELETE) { final String newTableName = _tableName; - char[] deleteFromTableChars = tableDeleteFrom.get(newTableName); - - if (deleteFromTableChars == null) { - deleteFromTableChars = (WD.DELETE + WD.SPACE + WD.FROM + WD.SPACE + newTableName).toCharArray(); - tableDeleteFrom.put(newTableName, deleteFromTableChars); - } + char[] deleteFromTableChars = tableDeleteFrom.computeIfAbsent(newTableName, n -> (WD.DELETE + WD.SPACE + WD.FROM + WD.SPACE + n).toCharArray()); _sb.append(deleteFromTableChars); - } else if (_op == OperationType.QUERY && _hasFromBeenSet == false && _isForConditionOnly == false) { + } else if (_op == OperationType.QUERY && !_hasFromBeenSet && !_isForConditionOnly) { throw new RuntimeException("'from' methods has not been called for query: " + _op); } } @@ -3243,7 +3236,7 @@ void init(final boolean setForUpdate) { private void setEntityClass(final Class entityClass) { _entityClass = entityClass; - if (entityClass != null && ClassUtil.isBeanClass(entityClass)) { + if (ClassUtil.isBeanClass(entityClass)) { _entityInfo = ParserUtil.getBeanInfo(entityClass); _propColumnNameMap = prop2ColumnNameMap(entityClass, _namingPolicy); } else { @@ -3665,7 +3658,7 @@ private void appendCondition(final Condition cond) { } else if (this instanceof NSB) { _sb.append(NSB.select(subQuery.getSelectPropNames()).from(subQuery.getEntityClass()).append(subCond).sql()); } else { - throw new RuntimeException("Unsupproted subQuery condition: " + cond); + throw new RuntimeException("Unsupported subQuery condition: " + cond); } } else if (this instanceof SCSB) { _sb.append(SCSB.select(subQuery.getSelectPropNames()).from(subQuery.getEntityName()).append(subCond).sql()); @@ -3696,7 +3689,7 @@ private void appendCondition(final Condition cond) { } else if (this instanceof NSB) { _sb.append(NSB.select(subQuery.getSelectPropNames()).from(subQuery.getEntityName()).append(subCond).sql()); } else { - throw new RuntimeException("Unsupproted subQuery condition: " + cond); + throw new RuntimeException("Unsupported subQuery condition: " + cond); } } else if (cond instanceof Expression) { // ==== version 1 @@ -3724,7 +3717,7 @@ private void appendCondition(final Condition cond) { // ==== version 3 appendStringExpr(((Expression) cond).getLiteral(), false); } else { - throw new IllegalArgumentException("Unsupported condtion: " + cond.toString()); + throw new IllegalArgumentException("Unsupported condition: " + cond.toString()); } } @@ -3780,7 +3773,7 @@ private void appendColumnName(final Class entityClass, final BeanInfo entityI Tuple2 tp = propColumnNameMap == null ? null : propColumnNameMap.get(propName); if (tp != null) { - if (tp._2.booleanValue() && tableAlias != null && tableAlias.length() > 0) { + if (tp._2 && tableAlias != null && !tableAlias.isEmpty()) { _sb.append(tableAlias).append(WD._PERIOD); } @@ -3833,7 +3826,7 @@ private void appendColumnName(final Class entityClass, final BeanInfo entityI } } - if (_aliasPropColumnNameMap != null && _aliasPropColumnNameMap.size() > 0) { + if (_aliasPropColumnNameMap != null && !_aliasPropColumnNameMap.isEmpty()) { final int index = propName.indexOf('.'); if (index > 0) { @@ -3887,6 +3880,7 @@ private void appendColumnName(final Class entityClass, final BeanInfo entityI } if (index > 0) { + //noinspection ConstantValue appendColumnName(entityClass, entityInfo, propColumnNameMap, tableAlias, propName.substring(0, index).trim(), propName.substring(index + 4).trim(), withClassAlias, classAlias, isForSelect); } else { @@ -3981,13 +3975,13 @@ private String formalizeColumnName(final ImmutableMap tp = propColumnNameMap == null ? null : propColumnNameMap.get(propName); if (tp != null) { - if (tp._2.booleanValue() && _tableAlias != null && _tableAlias.length() > 0) { + if (tp._2 && _tableAlias != null && !_tableAlias.isEmpty()) { return _tableAlias + "." + tp._1; } return tp._1; } - if (_aliasPropColumnNameMap != null && _aliasPropColumnNameMap.size() > 0) { + if (_aliasPropColumnNameMap != null && !_aliasPropColumnNameMap.isEmpty()) { final int index = propName.indexOf('.'); if (index > 0) { @@ -4031,12 +4025,13 @@ private static void parseInsertEntity(final SQLBuilder instance, final Object en } } - private static Collection> toInsertPropsList(final Collection propsList) { + private static List> toInsertPropsList(final Collection propsList) { final Optional first = N.firstNonNull(propsList); if (first.isPresent() && first.get() instanceof Map) { return (List>) propsList; } + final Class entityClass = first.get().getClass(); final Collection propNames = QueryUtil.getInsertPropNames(entityClass, null); final List> newPropsList = new ArrayList<>(propsList.size()); @@ -4068,7 +4063,7 @@ static ImmutableMap> prop2ColumnNameMap(final Cl } enum SQLPolicy { - SQL, PARAMETERIZED_SQL, NAMED_SQL, IBATIS_SQL; + SQL, PARAMETERIZED_SQL, NAMED_SQL, IBATIS_SQL } /** @@ -4346,7 +4341,7 @@ public static SQLBuilder deleteFrom(final Class entityClass) { * @return */ public static SQLBuilder select(final String selectPart) { - N.checkArgNotEmpty(selectPart, "selectPart"); + N.checkArgNotEmpty(selectPart, SELECT_PART); final SQLBuilder instance = createInstance(); @@ -4362,7 +4357,7 @@ public static SQLBuilder select(final String selectPart) { */ @SafeVarargs public static SQLBuilder select(final String... propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -4378,7 +4373,7 @@ public static SQLBuilder select(final String... propOrColumnNames) { * @return */ public static SQLBuilder select(final Collection propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -4394,7 +4389,7 @@ public static SQLBuilder select(final Collection propOrColumnNames) { * @return */ public static SQLBuilder select(final Map propOrColumnNameAliases) { - N.checkArgNotEmpty(propOrColumnNameAliases, "propOrColumnNameAliases"); + N.checkArgNotEmpty(propOrColumnNameAliases, PROP_OR_COLUMN_NAME_ALIASES); final SQLBuilder instance = createInstance(); @@ -4534,6 +4529,7 @@ public static SQLBuilder selectFrom(final Class entityClass, final String ali final Set excludedPropNames) { if (hasSubEntityToInclude(entityClass, includeSubEntityProperties)) { final List selectTableNames = getSelectTableNames(entityClass, alias, excludedPropNames, NamingPolicy.LOWER_CASE_WITH_UNDERSCORE); + //noinspection ConstantValue return select(entityClass, includeSubEntityProperties, excludedPropNames).from(entityClass, selectTableNames); } @@ -4977,7 +4973,7 @@ public static SQLBuilder deleteFrom(final Class entityClass) { * @return */ public static SQLBuilder select(final String selectPart) { - N.checkArgNotEmpty(selectPart, "selectPart"); + N.checkArgNotEmpty(selectPart, SELECT_PART); final SQLBuilder instance = createInstance(); @@ -4993,7 +4989,7 @@ public static SQLBuilder select(final String selectPart) { */ @SafeVarargs public static SQLBuilder select(final String... propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -5009,7 +5005,7 @@ public static SQLBuilder select(final String... propOrColumnNames) { * @return */ public static SQLBuilder select(final Collection propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -5025,7 +5021,7 @@ public static SQLBuilder select(final Collection propOrColumnNames) { * @return */ public static SQLBuilder select(final Map propOrColumnNameAliases) { - N.checkArgNotEmpty(propOrColumnNameAliases, "propOrColumnNameAliases"); + N.checkArgNotEmpty(propOrColumnNameAliases, PROP_OR_COLUMN_NAME_ALIASES); final SQLBuilder instance = createInstance(); @@ -5165,6 +5161,7 @@ public static SQLBuilder selectFrom(final Class entityClass, final String ali final Set excludedPropNames) { if (hasSubEntityToInclude(entityClass, includeSubEntityProperties)) { final List selectTableNames = getSelectTableNames(entityClass, alias, excludedPropNames, NamingPolicy.UPPER_CASE_WITH_UNDERSCORE); + //noinspection ConstantValue return select(entityClass, includeSubEntityProperties, excludedPropNames).from(entityClass, selectTableNames); } @@ -5608,7 +5605,7 @@ public static SQLBuilder deleteFrom(final Class entityClass) { * @return */ public static SQLBuilder select(final String selectPart) { - N.checkArgNotEmpty(selectPart, "selectPart"); + N.checkArgNotEmpty(selectPart, SELECT_PART); final SQLBuilder instance = createInstance(); @@ -5624,7 +5621,7 @@ public static SQLBuilder select(final String selectPart) { */ @SafeVarargs public static SQLBuilder select(final String... propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -5640,7 +5637,7 @@ public static SQLBuilder select(final String... propOrColumnNames) { * @return */ public static SQLBuilder select(final Collection propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -5656,7 +5653,7 @@ public static SQLBuilder select(final Collection propOrColumnNames) { * @return */ public static SQLBuilder select(final Map propOrColumnNameAliases) { - N.checkArgNotEmpty(propOrColumnNameAliases, "propOrColumnNameAliases"); + N.checkArgNotEmpty(propOrColumnNameAliases, PROP_OR_COLUMN_NAME_ALIASES); final SQLBuilder instance = createInstance(); @@ -5796,6 +5793,7 @@ public static SQLBuilder selectFrom(final Class entityClass, final String ali final Set excludedPropNames) { if (hasSubEntityToInclude(entityClass, includeSubEntityProperties)) { final List selectTableNames = getSelectTableNames(entityClass, alias, excludedPropNames, NamingPolicy.LOWER_CAMEL_CASE); + //noinspection ConstantValue return select(entityClass, includeSubEntityProperties, excludedPropNames).from(entityClass, selectTableNames); } @@ -6238,7 +6236,7 @@ public static SQLBuilder deleteFrom(final Class entityClass) { * @return */ public static SQLBuilder select(final String selectPart) { - N.checkArgNotEmpty(selectPart, "selectPart"); + N.checkArgNotEmpty(selectPart, SELECT_PART); final SQLBuilder instance = createInstance(); @@ -6254,7 +6252,7 @@ public static SQLBuilder select(final String selectPart) { */ @SafeVarargs public static SQLBuilder select(final String... propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -6270,7 +6268,7 @@ public static SQLBuilder select(final String... propOrColumnNames) { * @return */ public static SQLBuilder select(final Collection propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -6286,7 +6284,7 @@ public static SQLBuilder select(final Collection propOrColumnNames) { * @return */ public static SQLBuilder select(final Map propOrColumnNameAliases) { - N.checkArgNotEmpty(propOrColumnNameAliases, "propOrColumnNameAliases"); + N.checkArgNotEmpty(propOrColumnNameAliases, PROP_OR_COLUMN_NAME_ALIASES); final SQLBuilder instance = createInstance(); @@ -6426,6 +6424,7 @@ public static SQLBuilder selectFrom(final Class entityClass, final String ali final Set excludedPropNames) { if (hasSubEntityToInclude(entityClass, includeSubEntityProperties)) { final List selectTableNames = getSelectTableNames(entityClass, alias, excludedPropNames, NamingPolicy.NO_CHANGE); + //noinspection ConstantValue return select(entityClass, includeSubEntityProperties, excludedPropNames).from(entityClass, selectTableNames); } @@ -6866,7 +6865,7 @@ public static SQLBuilder deleteFrom(final Class entityClass) { * @return */ public static SQLBuilder select(final String selectPart) { - N.checkArgNotEmpty(selectPart, "selectPart"); + N.checkArgNotEmpty(selectPart, SELECT_PART); final SQLBuilder instance = createInstance(); @@ -6882,7 +6881,7 @@ public static SQLBuilder select(final String selectPart) { */ @SafeVarargs public static SQLBuilder select(final String... propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -6898,7 +6897,7 @@ public static SQLBuilder select(final String... propOrColumnNames) { * @return */ public static SQLBuilder select(final Collection propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -6914,7 +6913,7 @@ public static SQLBuilder select(final Collection propOrColumnNames) { * @return */ public static SQLBuilder select(final Map propOrColumnNameAliases) { - N.checkArgNotEmpty(propOrColumnNameAliases, "propOrColumnNameAliases"); + N.checkArgNotEmpty(propOrColumnNameAliases, PROP_OR_COLUMN_NAME_ALIASES); final SQLBuilder instance = createInstance(); @@ -7054,6 +7053,7 @@ public static SQLBuilder selectFrom(final Class entityClass, final String ali final Set excludedPropNames) { if (hasSubEntityToInclude(entityClass, includeSubEntityProperties)) { final List selectTableNames = getSelectTableNames(entityClass, alias, excludedPropNames, NamingPolicy.LOWER_CASE_WITH_UNDERSCORE); + //noinspection ConstantValue return select(entityClass, includeSubEntityProperties, excludedPropNames).from(entityClass, selectTableNames); } @@ -7494,7 +7494,7 @@ public static SQLBuilder deleteFrom(final Class entityClass) { * @return */ public static SQLBuilder select(final String selectPart) { - N.checkArgNotEmpty(selectPart, "selectPart"); + N.checkArgNotEmpty(selectPart, SELECT_PART); final SQLBuilder instance = createInstance(); @@ -7510,7 +7510,7 @@ public static SQLBuilder select(final String selectPart) { */ @SafeVarargs public static SQLBuilder select(final String... propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -7526,7 +7526,7 @@ public static SQLBuilder select(final String... propOrColumnNames) { * @return */ public static SQLBuilder select(final Collection propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -7542,7 +7542,7 @@ public static SQLBuilder select(final Collection propOrColumnNames) { * @return */ public static SQLBuilder select(final Map propOrColumnNameAliases) { - N.checkArgNotEmpty(propOrColumnNameAliases, "propOrColumnNameAliases"); + N.checkArgNotEmpty(propOrColumnNameAliases, PROP_OR_COLUMN_NAME_ALIASES); final SQLBuilder instance = createInstance(); @@ -7682,6 +7682,7 @@ public static SQLBuilder selectFrom(final Class entityClass, final String ali final Set excludedPropNames) { if (hasSubEntityToInclude(entityClass, includeSubEntityProperties)) { final List selectTableNames = getSelectTableNames(entityClass, alias, excludedPropNames, NamingPolicy.UPPER_CASE_WITH_UNDERSCORE); + //noinspection ConstantValue return select(entityClass, includeSubEntityProperties, excludedPropNames).from(entityClass, selectTableNames); } @@ -8122,7 +8123,7 @@ public static SQLBuilder deleteFrom(final Class entityClass) { * @return */ public static SQLBuilder select(final String selectPart) { - N.checkArgNotEmpty(selectPart, "selectPart"); + N.checkArgNotEmpty(selectPart, SELECT_PART); final SQLBuilder instance = createInstance(); @@ -8138,7 +8139,7 @@ public static SQLBuilder select(final String selectPart) { */ @SafeVarargs public static SQLBuilder select(final String... propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -8154,7 +8155,7 @@ public static SQLBuilder select(final String... propOrColumnNames) { * @return */ public static SQLBuilder select(final Collection propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -8170,7 +8171,7 @@ public static SQLBuilder select(final Collection propOrColumnNames) { * @return */ public static SQLBuilder select(final Map propOrColumnNameAliases) { - N.checkArgNotEmpty(propOrColumnNameAliases, "propOrColumnNameAliases"); + N.checkArgNotEmpty(propOrColumnNameAliases, PROP_OR_COLUMN_NAME_ALIASES); final SQLBuilder instance = createInstance(); @@ -8310,6 +8311,7 @@ public static SQLBuilder selectFrom(final Class entityClass, final String ali final Set excludedPropNames) { if (hasSubEntityToInclude(entityClass, includeSubEntityProperties)) { final List selectTableNames = getSelectTableNames(entityClass, alias, excludedPropNames, NamingPolicy.LOWER_CAMEL_CASE); + //noinspection ConstantValue return select(entityClass, includeSubEntityProperties, excludedPropNames).from(entityClass, selectTableNames); } @@ -8755,7 +8757,7 @@ public static SQLBuilder deleteFrom(final Class entityClass) { * @return */ public static SQLBuilder select(final String selectPart) { - N.checkArgNotEmpty(selectPart, "selectPart"); + N.checkArgNotEmpty(selectPart, SELECT_PART); final SQLBuilder instance = createInstance(); @@ -8771,7 +8773,7 @@ public static SQLBuilder select(final String selectPart) { */ @SafeVarargs public static SQLBuilder select(final String... propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -8787,7 +8789,7 @@ public static SQLBuilder select(final String... propOrColumnNames) { * @return */ public static SQLBuilder select(final Collection propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -8803,7 +8805,7 @@ public static SQLBuilder select(final Collection propOrColumnNames) { * @return */ public static SQLBuilder select(final Map propOrColumnNameAliases) { - N.checkArgNotEmpty(propOrColumnNameAliases, "propOrColumnNameAliases"); + N.checkArgNotEmpty(propOrColumnNameAliases, PROP_OR_COLUMN_NAME_ALIASES); final SQLBuilder instance = createInstance(); @@ -8943,6 +8945,7 @@ public static SQLBuilder selectFrom(final Class entityClass, final String ali final Set excludedPropNames) { if (hasSubEntityToInclude(entityClass, includeSubEntityProperties)) { final List selectTableNames = getSelectTableNames(entityClass, alias, excludedPropNames, NamingPolicy.NO_CHANGE); + //noinspection ConstantValue return select(entityClass, includeSubEntityProperties, excludedPropNames).from(entityClass, selectTableNames); } @@ -9389,7 +9392,7 @@ public static SQLBuilder deleteFrom(final Class entityClass) { * @return */ public static SQLBuilder select(final String selectPart) { - N.checkArgNotEmpty(selectPart, "selectPart"); + N.checkArgNotEmpty(selectPart, SELECT_PART); final SQLBuilder instance = createInstance(); @@ -9405,7 +9408,7 @@ public static SQLBuilder select(final String selectPart) { */ @SafeVarargs public static SQLBuilder select(final String... propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -9421,7 +9424,7 @@ public static SQLBuilder select(final String... propOrColumnNames) { * @return */ public static SQLBuilder select(final Collection propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -9437,7 +9440,7 @@ public static SQLBuilder select(final Collection propOrColumnNames) { * @return */ public static SQLBuilder select(final Map propOrColumnNameAliases) { - N.checkArgNotEmpty(propOrColumnNameAliases, "propOrColumnNameAliases"); + N.checkArgNotEmpty(propOrColumnNameAliases, PROP_OR_COLUMN_NAME_ALIASES); final SQLBuilder instance = createInstance(); @@ -9577,6 +9580,7 @@ public static SQLBuilder selectFrom(final Class entityClass, final String ali final Set excludedPropNames) { if (hasSubEntityToInclude(entityClass, includeSubEntityProperties)) { final List selectTableNames = getSelectTableNames(entityClass, alias, excludedPropNames, NamingPolicy.LOWER_CASE_WITH_UNDERSCORE); + //noinspection ConstantValue return select(entityClass, includeSubEntityProperties, excludedPropNames).from(entityClass, selectTableNames); } @@ -10022,7 +10026,7 @@ public static SQLBuilder deleteFrom(final Class entityClass) { * @return */ public static SQLBuilder select(final String selectPart) { - N.checkArgNotEmpty(selectPart, "selectPart"); + N.checkArgNotEmpty(selectPart, SELECT_PART); final SQLBuilder instance = createInstance(); @@ -10038,7 +10042,7 @@ public static SQLBuilder select(final String selectPart) { */ @SafeVarargs public static SQLBuilder select(final String... propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -10054,7 +10058,7 @@ public static SQLBuilder select(final String... propOrColumnNames) { * @return */ public static SQLBuilder select(final Collection propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -10070,7 +10074,7 @@ public static SQLBuilder select(final Collection propOrColumnNames) { * @return */ public static SQLBuilder select(final Map propOrColumnNameAliases) { - N.checkArgNotEmpty(propOrColumnNameAliases, "propOrColumnNameAliases"); + N.checkArgNotEmpty(propOrColumnNameAliases, PROP_OR_COLUMN_NAME_ALIASES); final SQLBuilder instance = createInstance(); @@ -10210,6 +10214,7 @@ public static SQLBuilder selectFrom(final Class entityClass, final String ali final Set excludedPropNames) { if (hasSubEntityToInclude(entityClass, includeSubEntityProperties)) { final List selectTableNames = getSelectTableNames(entityClass, alias, excludedPropNames, NamingPolicy.UPPER_CASE_WITH_UNDERSCORE); + //noinspection ConstantValue return select(entityClass, includeSubEntityProperties, excludedPropNames).from(entityClass, selectTableNames); } @@ -10655,7 +10660,7 @@ public static SQLBuilder deleteFrom(final Class entityClass) { * @return */ public static SQLBuilder select(final String selectPart) { - N.checkArgNotEmpty(selectPart, "selectPart"); + N.checkArgNotEmpty(selectPart, SELECT_PART); final SQLBuilder instance = createInstance(); @@ -10671,7 +10676,7 @@ public static SQLBuilder select(final String selectPart) { */ @SafeVarargs public static SQLBuilder select(final String... propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -10687,7 +10692,7 @@ public static SQLBuilder select(final String... propOrColumnNames) { * @return */ public static SQLBuilder select(final Collection propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -10703,7 +10708,7 @@ public static SQLBuilder select(final Collection propOrColumnNames) { * @return */ public static SQLBuilder select(final Map propOrColumnNameAliases) { - N.checkArgNotEmpty(propOrColumnNameAliases, "propOrColumnNameAliases"); + N.checkArgNotEmpty(propOrColumnNameAliases, PROP_OR_COLUMN_NAME_ALIASES); final SQLBuilder instance = createInstance(); @@ -10843,6 +10848,7 @@ public static SQLBuilder selectFrom(final Class entityClass, final String ali final Set excludedPropNames) { if (hasSubEntityToInclude(entityClass, includeSubEntityProperties)) { final List selectTableNames = getSelectTableNames(entityClass, alias, excludedPropNames, NamingPolicy.LOWER_CAMEL_CASE); + //noinspection ConstantValue return select(entityClass, includeSubEntityProperties, excludedPropNames).from(entityClass, selectTableNames); } @@ -11285,7 +11291,7 @@ public static SQLBuilder deleteFrom(final Class entityClass) { * @return */ public static SQLBuilder select(final String selectPart) { - N.checkArgNotEmpty(selectPart, "selectPart"); + N.checkArgNotEmpty(selectPart, SELECT_PART); final SQLBuilder instance = createInstance(); @@ -11301,7 +11307,7 @@ public static SQLBuilder select(final String selectPart) { */ @SafeVarargs public static SQLBuilder select(final String... propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -11317,7 +11323,7 @@ public static SQLBuilder select(final String... propOrColumnNames) { * @return */ public static SQLBuilder select(final Collection propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -11333,7 +11339,7 @@ public static SQLBuilder select(final Collection propOrColumnNames) { * @return */ public static SQLBuilder select(final Map propOrColumnNameAliases) { - N.checkArgNotEmpty(propOrColumnNameAliases, "propOrColumnNameAliases"); + N.checkArgNotEmpty(propOrColumnNameAliases, PROP_OR_COLUMN_NAME_ALIASES); final SQLBuilder instance = createInstance(); @@ -11473,6 +11479,7 @@ public static SQLBuilder selectFrom(final Class entityClass, final String ali final Set excludedPropNames) { if (hasSubEntityToInclude(entityClass, includeSubEntityProperties)) { final List selectTableNames = getSelectTableNames(entityClass, alias, excludedPropNames, NamingPolicy.NO_CHANGE); + //noinspection ConstantValue return select(entityClass, includeSubEntityProperties, excludedPropNames).from(entityClass, selectTableNames); } @@ -11915,7 +11922,7 @@ public static SQLBuilder deleteFrom(final Class entityClass) { * @return */ public static SQLBuilder select(final String selectPart) { - N.checkArgNotEmpty(selectPart, "selectPart"); + N.checkArgNotEmpty(selectPart, SELECT_PART); final SQLBuilder instance = createInstance(); @@ -11931,7 +11938,7 @@ public static SQLBuilder select(final String selectPart) { */ @SafeVarargs public static SQLBuilder select(final String... propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -11947,7 +11954,7 @@ public static SQLBuilder select(final String... propOrColumnNames) { * @return */ public static SQLBuilder select(final Collection propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -11963,7 +11970,7 @@ public static SQLBuilder select(final Collection propOrColumnNames) { * @return */ public static SQLBuilder select(final Map propOrColumnNameAliases) { - N.checkArgNotEmpty(propOrColumnNameAliases, "propOrColumnNameAliases"); + N.checkArgNotEmpty(propOrColumnNameAliases, PROP_OR_COLUMN_NAME_ALIASES); final SQLBuilder instance = createInstance(); @@ -12103,6 +12110,7 @@ public static SQLBuilder selectFrom(final Class entityClass, final String ali final Set excludedPropNames) { if (hasSubEntityToInclude(entityClass, includeSubEntityProperties)) { final List selectTableNames = getSelectTableNames(entityClass, alias, excludedPropNames, NamingPolicy.LOWER_CASE_WITH_UNDERSCORE); + //noinspection ConstantValue return select(entityClass, includeSubEntityProperties, excludedPropNames).from(entityClass, selectTableNames); } @@ -12545,7 +12553,7 @@ public static SQLBuilder deleteFrom(final Class entityClass) { * @return */ public static SQLBuilder select(final String selectPart) { - N.checkArgNotEmpty(selectPart, "selectPart"); + N.checkArgNotEmpty(selectPart, SELECT_PART); final SQLBuilder instance = createInstance(); @@ -12561,7 +12569,7 @@ public static SQLBuilder select(final String selectPart) { */ @SafeVarargs public static SQLBuilder select(final String... propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -12577,7 +12585,7 @@ public static SQLBuilder select(final String... propOrColumnNames) { * @return */ public static SQLBuilder select(final Collection propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -12593,7 +12601,7 @@ public static SQLBuilder select(final Collection propOrColumnNames) { * @return */ public static SQLBuilder select(final Map propOrColumnNameAliases) { - N.checkArgNotEmpty(propOrColumnNameAliases, "propOrColumnNameAliases"); + N.checkArgNotEmpty(propOrColumnNameAliases, PROP_OR_COLUMN_NAME_ALIASES); final SQLBuilder instance = createInstance(); @@ -12733,6 +12741,7 @@ public static SQLBuilder selectFrom(final Class entityClass, final String ali final Set excludedPropNames) { if (hasSubEntityToInclude(entityClass, includeSubEntityProperties)) { final List selectTableNames = getSelectTableNames(entityClass, alias, excludedPropNames, NamingPolicy.UPPER_CASE_WITH_UNDERSCORE); + //noinspection ConstantValue return select(entityClass, includeSubEntityProperties, excludedPropNames).from(entityClass, selectTableNames); } @@ -13175,7 +13184,7 @@ public static SQLBuilder deleteFrom(final Class entityClass) { * @return */ public static SQLBuilder select(final String selectPart) { - N.checkArgNotEmpty(selectPart, "selectPart"); + N.checkArgNotEmpty(selectPart, SELECT_PART); final SQLBuilder instance = createInstance(); @@ -13191,7 +13200,7 @@ public static SQLBuilder select(final String selectPart) { */ @SafeVarargs public static SQLBuilder select(final String... propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -13207,7 +13216,7 @@ public static SQLBuilder select(final String... propOrColumnNames) { * @return */ public static SQLBuilder select(final Collection propOrColumnNames) { - N.checkArgNotEmpty(propOrColumnNames, "propOrColumnNames"); + N.checkArgNotEmpty(propOrColumnNames, PROP_OR_COLUMN_NAMES); final SQLBuilder instance = createInstance(); @@ -13223,7 +13232,7 @@ public static SQLBuilder select(final Collection propOrColumnNames) { * @return */ public static SQLBuilder select(final Map propOrColumnNameAliases) { - N.checkArgNotEmpty(propOrColumnNameAliases, "propOrColumnNameAliases"); + N.checkArgNotEmpty(propOrColumnNameAliases, PROP_OR_COLUMN_NAME_ALIASES); final SQLBuilder instance = createInstance(); @@ -13363,6 +13372,7 @@ public static SQLBuilder selectFrom(final Class entityClass, final String ali final Set excludedPropNames) { if (hasSubEntityToInclude(entityClass, includeSubEntityProperties)) { final List selectTableNames = getSelectTableNames(entityClass, alias, excludedPropNames, NamingPolicy.LOWER_CAMEL_CASE); + //noinspection ConstantValue return select(entityClass, includeSubEntityProperties, excludedPropNames).from(entityClass, selectTableNames); } diff --git a/src/main/java/com/landawn/abacus/util/SQLMapper.java b/src/main/java/com/landawn/abacus/util/SQLMapper.java index fd827d2..58a8568 100644 --- a/src/main/java/com/landawn/abacus/util/SQLMapper.java +++ b/src/main/java/com/landawn/abacus/util/SQLMapper.java @@ -27,6 +27,7 @@ import java.util.Map; import java.util.Set; +import com.landawn.abacus.annotation.SuppressFBWarnings; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; @@ -227,6 +228,7 @@ public SQLMapper copy() { * * @param file */ + @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE") public void saveTo(final File file) { try (OutputStream os = new FileOutputStream(file)) { @@ -253,6 +255,7 @@ public void saveTo(final File file) { doc.appendChild(sqlMapperNode); if (!file.exists()) { + //noinspection ResultOfMethodCallIgnored file.createNewFile(); //NOSONAR } diff --git a/src/main/java/com/landawn/abacus/util/SQLParser.java b/src/main/java/com/landawn/abacus/util/SQLParser.java index 7ebbe60..0739b34 100644 --- a/src/main/java/com/landawn/abacus/util/SQLParser.java +++ b/src/main/java/com/landawn/abacus/util/SQLParser.java @@ -32,93 +32,87 @@ public final class SQLParser { private static final char ENTER_2 = '\r'; - private static final Set seperators = N.newHashSet(); + private static final Set separators = N.newHashSet(); static { - seperators.add(TAB); - seperators.add(ENTER); - seperators.add(ENTER_2); - seperators.add(' '); - seperators.add('?'); - seperators.add(','); - seperators.add('~'); - seperators.add('!'); - seperators.add('@'); - seperators.add('^'); - seperators.add('#'); - seperators.add("!!"); - seperators.add(';'); - seperators.add('('); - seperators.add(')'); - seperators.add('='); - seperators.add("=="); - seperators.add(":="); - seperators.add("^="); - seperators.add("~="); - seperators.add("+="); - seperators.add("-="); - seperators.add("*="); - seperators.add("/="); - seperators.add("%="); - seperators.add("&="); - seperators.add("|="); - seperators.add("!="); - seperators.add("!<"); - seperators.add("!>"); - seperators.add('>'); - seperators.add(">>"); - seperators.add(">="); - seperators.add("@>"); - seperators.add("&>"); - seperators.add(">^"); - seperators.add('<'); - seperators.add("<<"); - seperators.add("<="); - seperators.add("<@"); - seperators.add("&<"); - seperators.add("<^"); - seperators.add('+'); - seperators.add('-'); - seperators.add('%'); - seperators.add('/'); - seperators.add('*'); - seperators.add('&'); - seperators.add("&&"); - seperators.add('|'); - seperators.add("||"); - seperators.add("|/"); - seperators.add("||/"); - seperators.add('^'); - seperators.add('~'); - seperators.add('!'); - seperators.add("->"); - seperators.add('#'); - seperators.add("##"); - seperators.add("@@"); - seperators.add("@-@"); - seperators.add("@@@"); - seperators.add("->>"); - seperators.add("<->"); - seperators.add("<=>"); - seperators.add(">>="); - seperators.add("<<="); - seperators.add("<<|"); - seperators.add("|>>"); - seperators.add("&<|"); - seperators.add("|&>"); - seperators.add("|>>"); - seperators.add("(+)"); - seperators.add("?#"); - seperators.add("?-"); - seperators.add("?-"); - seperators.add("?|"); - seperators.add("?-|"); - seperators.add("?||"); - seperators.add("~*"); - seperators.add("!~"); - seperators.add("!~*"); - seperators.add("^-="); - seperators.add("|*="); + separators.add(TAB); + separators.add(ENTER); + separators.add(ENTER_2); + separators.add(' '); + separators.add('?'); + separators.add(','); + separators.add('~'); + separators.add('!'); + separators.add('@'); + separators.add('^'); + separators.add('#'); + separators.add("!!"); + separators.add(';'); + separators.add('('); + separators.add(')'); + separators.add('='); + separators.add("=="); + separators.add(":="); + separators.add("^="); + separators.add("~="); + separators.add("+="); + separators.add("-="); + separators.add("*="); + separators.add("/="); + separators.add("%="); + separators.add("&="); + separators.add("|="); + separators.add("!="); + separators.add("!<"); + separators.add("!>"); + separators.add('>'); + separators.add(">>"); + separators.add(">="); + separators.add("@>"); + separators.add("&>"); + separators.add(">^"); + separators.add('<'); + separators.add("<<"); + separators.add("<="); + separators.add("<@"); + separators.add("&<"); + separators.add("<^"); + separators.add('+'); + separators.add('-'); + separators.add('%'); + separators.add('/'); + separators.add('*'); + separators.add('&'); + separators.add("&&"); + separators.add('|'); + separators.add("||"); + separators.add("|/"); + separators.add("||/"); + separators.add("->"); + separators.add("##"); + separators.add("@@"); + separators.add("@-@"); + separators.add("@@@"); + separators.add("->>"); + separators.add("<->"); + separators.add("<=>"); + separators.add(">>="); + separators.add("<<="); + separators.add("<<|"); + separators.add("&<|"); + separators.add("|&>"); + separators.add("|>>"); + separators.add("(+)"); + separators.add("?#"); + separators.add("?-"); + separators.add("?|"); + separators.add("?-|"); + separators.add("?||"); + separators.add("~*"); + separators.add("!~"); + separators.add("!~*"); + separators.add("^-="); + separators.add("|*="); } private static final Map compositeWords = new ObjectPool<>(64); @@ -128,7 +122,6 @@ public final class SQLParser { compositeWords.put(WD.RIGHT_JOIN, new String[] { "RIGHT", "JOIN" }); compositeWords.put(WD.FULL_JOIN, new String[] { "FULL", "JOIN" }); compositeWords.put(WD.CROSS_JOIN, new String[] { "CROSS", "JOIN" }); - compositeWords.put(WD.INNER_JOIN, new String[] { "INNER", "JOIN" }); compositeWords.put(WD.NATURAL_JOIN, new String[] { "NATURAL", "JOIN" }); compositeWords.put(WD.INNER_JOIN, new String[] { "INNER", "JOIN" }); compositeWords.put(WD.GROUP_BY, new String[] { "GROUP", "BY" }); @@ -200,7 +193,7 @@ public static List parse(final String sql) { quoteChar = 0; } } else if (c == '-' && index < sqlLength - 1 && sql.charAt(index + 1) == '-') { - if (sb.length() > 0) { + if (!sb.isEmpty()) { words.add(sb.toString()); sb.setLength(0); } @@ -246,7 +239,7 @@ public static List parse(final String sql) { } } } else if (c == '/' && index < sqlLength - 1 && sql.charAt(index + 1) == '*') { - if (sb.length() > 0) { + if (!sb.isEmpty()) { words.add(sb.toString()); sb.setLength(0); } @@ -281,16 +274,16 @@ public static List parse(final String sql) { } } } - } else if (isSeperator(sql, sqlLength, index, c)) { - if (sb.length() > 0) { + } else if (isSeparator(sql, sqlLength, index, c)) { + if (!sb.isEmpty()) { words.add(sb.toString()); sb.setLength(0); } - if ((index < (sqlLength - 2)) && seperators.contains(temp = sql.substring(index, index + 3))) { + if ((index < (sqlLength - 2)) && separators.contains(temp = sql.substring(index, index + 3))) { words.add(temp); index += 2; - } else if ((index < (sqlLength - 1)) && seperators.contains(temp = sql.substring(index, index + 2))) { + } else if ((index < (sqlLength - 1)) && separators.contains(temp = sql.substring(index, index + 2))) { words.add(temp); index += 1; } else if (c == WD._SPACE || c == TAB || c == ENTER || c == ENTER_2) { @@ -309,7 +302,7 @@ public static List parse(final String sql) { } } - if (sb.length() > 0) { + if (!sb.isEmpty()) { words.add(sb.toString()); sb.setLength(0); } @@ -335,6 +328,7 @@ public static int indexWord(final String sql, final String word, final int fromI compositeWords.put(word, subWords); } + //noinspection IfStatementWithIdenticalBranches if ((subWords == null) || (subWords.length <= 1)) { int result = N.INDEX_NOT_FOUND; @@ -363,8 +357,8 @@ public static int indexWord(final String sql, final String word, final int fromI sb.setLength(0); quoteChar = 0; } - } else if (isSeperator(sql, sqlLength, index, c)) { - if (sb.length() > 0) { + } else if (isSeparator(sql, sqlLength, index, c)) { + if (!sb.isEmpty()) { temp = sb.toString(); if (word.equals(temp) || (!caseSensitive && word.equalsIgnoreCase(temp))) { @@ -379,7 +373,7 @@ public static int indexWord(final String sql, final String word, final int fromI continue; } - if ((index < (sqlLength - 2)) && seperators.contains(temp = sql.substring(index, index + 3))) { + if ((index < (sqlLength - 2)) && separators.contains(temp = sql.substring(index, index + 3))) { if (word.equals(temp) || (!caseSensitive && word.equalsIgnoreCase(temp))) { result = index; @@ -387,7 +381,7 @@ public static int indexWord(final String sql, final String word, final int fromI } index += 2; - } else if ((index < (sqlLength - 1)) && seperators.contains(temp = sql.substring(index, index + 2))) { + } else if ((index < (sqlLength - 1)) && separators.contains(temp = sql.substring(index, index + 2))) { if (word.equals(temp) || (!caseSensitive && word.equalsIgnoreCase(temp))) { result = index; @@ -409,7 +403,7 @@ public static int indexWord(final String sql, final String word, final int fromI } } - if (result < 0 && sb.length() > 0) { + if (result < 0 && !sb.isEmpty()) { temp = sb.toString(); if (word.equals(temp) || (!caseSensitive && word.equalsIgnoreCase(temp))) { @@ -468,16 +462,16 @@ public static String nextWord(final String sql, final int fromIndex) { if (c == quoteChar) { break; } - } else if (isSeperator(sql, sqlLength, index, c)) { - if (sb.length() > 0) { + } else if (isSeparator(sql, sqlLength, index, c)) { + if (!sb.isEmpty()) { break; } else if (c == WD._SPACE || c == TAB || c == ENTER || c == ENTER_2) { // skip white char continue; } - if (((index < (sqlLength - 2)) && seperators.contains(temp = sql.substring(index, index + 3))) - || ((index < (sqlLength - 1)) && seperators.contains(temp = sql.substring(index, index + 2)))) { + if (((index < (sqlLength - 2)) && separators.contains(temp = sql.substring(index, index + 3))) + || ((index < (sqlLength - 1)) && separators.contains(temp = sql.substring(index, index + 2)))) { sb.append(temp); } else { sb.append(c); @@ -493,7 +487,7 @@ public static String nextWord(final String sql, final int fromIndex) { } } - final String st = (sb.length() == 0) ? "" : sb.toString(); + final String st = (sb.isEmpty()) ? "" : sb.toString(); Objectory.recycle(sb); return st; @@ -501,44 +495,44 @@ public static String nextWord(final String sql, final int fromIndex) { /** * - * @param seperator + * @param separator */ - public static void registerSeperator(final char seperator) { - N.checkArgPositive(seperator, "seperator"); + public static void registerSeparator(final char separator) { + N.checkArgPositive(separator, "separator"); - seperators.add(seperator); + separators.add(separator); } /** * - * @param seperator + * @param separator */ - public static void registerSeperator(final String seperator) { - N.checkArgNotNull(seperator, "seperator"); + public static void registerSeparator(final String separator) { + N.checkArgNotNull(separator, "separator"); - seperators.add(seperator); + separators.add(separator); - if (seperator.length() == 1) { - seperators.add(seperator.charAt(0)); + if (separator.length() == 1) { + separators.add(separator.charAt(0)); } } /** - * Checks if is seperator. + * Checks if is separator. * * @param str * @param len * @param index * @param ch - * @return true, if is seperator + * @return true, if is separator */ - public static boolean isSeperator(final String str, final int len, final int index, final char ch) { + public static boolean isSeparator(final String str, final int len, final int index, final char ch) { // for Ibatis/Mybatis if (ch == '#' && index < len - 1 && str.charAt(index + 1) == '{') { return false; } - return seperators.contains(ch); + return separators.contains(ch); } /** diff --git a/src/main/java/com/landawn/abacus/util/Selection.java b/src/main/java/com/landawn/abacus/util/Selection.java index 272183d..def2090 100644 --- a/src/main/java/com/landawn/abacus/util/Selection.java +++ b/src/main/java/com/landawn/abacus/util/Selection.java @@ -28,28 +28,9 @@ import lombok.NoArgsConstructor; import lombok.experimental.Accessors; -/** - * - * - */ @Data @Accessors(fluent = true) - -/** - * - */ @NoArgsConstructor - -/** - * - * - * @param entityClass - * @param tableAlias - * @param classAlias - * @param selectPropNames - * @param includeSubEntityProperties - * @param excludedPropNames - */ @AllArgsConstructor public final class Selection { private Class entityClass; @@ -59,11 +40,6 @@ public final class Selection { boolean includeSubEntityProperties; private Set excludedPropNames; - /** - * - * - * @return - */ public static MultiSelectionBuilder multiSelectionBuilder() { return new MultiSelectionBuilder(); }