No effective change - code cleanup - simplify if

This commit is contained in:
Robin Bygrave
2015-07-31 14:51:34 +12:00
parent 069b83b78d
commit 53cf6c162c
8 changed files with 17 additions and 71 deletions
@@ -98,16 +98,7 @@ class DRawSqlParser {
}
private boolean hasPlaceHolders() {
if (placeHolderWhere > -1) {
return true;
}
if (placeHolderAndWhere > -1) {
return true;
}
if (placeHolderHaving > -1) {
return true;
}
return placeHolderAndHaving > -1;
return placeHolderWhere > -1 || placeHolderAndWhere > -1 || placeHolderHaving > -1 || placeHolderAndHaving > -1;
}
/**
@@ -94,11 +94,8 @@ public class TunedQueryInfo implements Serializable {
* Return true if the fetches are essentially the same.
*/
public boolean isSame(OrmQueryDetail newQueryDetail) {
if (tunedDetail == null) {
return false;
}
return tunedDetail.isAutoFetchEqual(newQueryDetail);
}
return tunedDetail != null && tunedDetail.isAutoFetchEqual(newQueryDetail);
}
/**
* Tune the query by replacing its OrmQueryDetail with a tuned one.
@@ -90,13 +90,11 @@ public class DRawSqlSelectBuilder {
debug("Parsing sql-select in " + getErrName());
}
if (hasPlaceHolders()) {
} else {
// parse the sql for the keywords...
// select, from, where, having, group by, order by
parseSqlFindKeywords(true);
}
if (!hasPlaceHolders()) {
// parse the sql for the keywords...
// select, from, where, having, group by, order by
parseSqlFindKeywords(true);
}
List<DRawSqlColumnInfo> selectColumns = findSelectColumns(meta.getColumnMapping());
whereExprPos = findWhereExprPosition();
@@ -140,16 +138,7 @@ public class DRawSqlSelectBuilder {
}
private boolean hasPlaceHolders() {
if (placeHolderWhere > -1) {
return true;
}
if (placeHolderAndWhere > -1) {
return true;
}
if (placeHolderHaving > -1) {
return true;
}
return placeHolderAndHaving > -1;
return placeHolderWhere > -1 || placeHolderAndWhere > -1 || placeHolderHaving > -1 || placeHolderAndHaving > -1;
}
/**
@@ -212,10 +212,7 @@ public final class DRawSqlSelectColumnsParser {
}
private boolean isMatch(BeanProperty prop, String columnLabel) {
if (columnLabel.equalsIgnoreCase(prop.getDbColumn())) {
return true;
}
return columnLabel.equalsIgnoreCase(prop.getName());
return columnLabel.equalsIgnoreCase(prop.getDbColumn()) || columnLabel.equalsIgnoreCase(prop.getName());
}
private int nextComma() {
@@ -161,14 +161,8 @@ public abstract class DeployParser {
* return true if the char is a letter, digit or underscore.
*/
private boolean isWordPart(char ch) {
if (Character.isLetterOrDigit(ch)) {
return true;
} else if (ch == UNDERSCORE) {
return true;
} else return ch == PERIOD;
}
return Character.isLetterOrDigit(ch) || ch == UNDERSCORE || ch == PERIOD;
}
private boolean isWordStart(char ch) {
return Character.isLetter(ch);
@@ -9,15 +9,7 @@ public class DmlUtil {
/**
* Return true if the value is null or a Numeric 0 (for primitive int's and long's) or Option empty.
*/
public static boolean isNullOrZero(Object value){
if (value == null){
return true;
}
if (value instanceof Number){
return ((Number)value).longValue() == 0l;
}
return false;
}
public static boolean isNullOrZero(Object value) {
return value == null || value instanceof Number && ((Number) value).longValue() == 0l;
}
}
@@ -127,11 +127,7 @@ public class OrmQueryDetail implements Serializable {
}
public boolean containsProperty(String property) {
if (baseProps == null) {
return true;
} else {
return baseProps.isIncluded(property);
}
return baseProps == null || baseProps.isIncluded(property);
}
/**
@@ -135,17 +135,7 @@ public class SimpleTextParser {
}
private boolean isWordTerminator(char c, boolean isOperator) {
if (Character.isWhitespace(c)) {
return true;
}
if (isOperator(c)) {
return !isOperator;
}
if (c == '(') {
return true;
}
return isOperator;
return Character.isWhitespace(c) || (isOperator(c) ? !isOperator : c == '(' || isOperator);
}
private boolean isOperator(char c) {