mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Merge branch 'release/collection-isempty-1' of https://github.com/DevFactory/avaje-ebeanorm into DevFactory-release/collection-isempty-1
Conflicts: src/main/java/com/avaje/ebeaninternal/server/query/DefaultDbSqlContext.java
This commit is contained in:
@@ -49,7 +49,7 @@ final class DRawSqlColumnsParser {
|
||||
if (split.length > 1) {
|
||||
ArrayList<String> tmp = new ArrayList<String>(split.length);
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
if (split[i].trim().length() > 0) {
|
||||
if (!split[i].trim().isEmpty()) {
|
||||
tmp.add(split[i].trim());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ public final class Ebean {
|
||||
// look to see if there is a default server defined
|
||||
String defaultName = PrimaryServer.getDefaultServerName();
|
||||
logger.debug("defaultName:" + defaultName);
|
||||
if (defaultName != null && defaultName.trim().length() > 0) {
|
||||
if (defaultName != null && !defaultName.trim().isEmpty()) {
|
||||
defaultServer = getWithCreate(defaultName.trim());
|
||||
}
|
||||
}
|
||||
@@ -182,7 +182,7 @@ public final class Ebean {
|
||||
}
|
||||
|
||||
private EbeanServer get(String name) {
|
||||
if (name == null || name.length() == 0) {
|
||||
if (name == null || name.isEmpty()) {
|
||||
return defaultServer;
|
||||
}
|
||||
// non-synchronized read
|
||||
|
||||
@@ -400,6 +400,6 @@ public final class OrderBy<T> implements Serializable {
|
||||
}
|
||||
|
||||
private boolean isEmptyString(String s) {
|
||||
return s == null || s.length() == 0;
|
||||
return s == null || s.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,6 @@ class PrimaryServer {
|
||||
* Return true if the string is null or empty.
|
||||
*/
|
||||
private static boolean isEmpty(String value) {
|
||||
return value == null || value.trim().length() == 0;
|
||||
return value == null || value.trim().isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ public abstract class AbstractNamingConvention implements NamingConvention {
|
||||
* Checks string is null or empty .
|
||||
*/
|
||||
protected boolean isEmpty(String s) {
|
||||
return s == null || s.trim().length() == 0;
|
||||
return s == null || s.trim().isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2460,7 +2460,7 @@ public class ServerConfig {
|
||||
String[] split = classNames.split("[ ,;]");
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
String cn = split[i].trim();
|
||||
if (cn.length() > 0 && !"class".equalsIgnoreCase(cn)) {
|
||||
if (!cn.isEmpty() && !"class".equalsIgnoreCase(cn)) {
|
||||
try {
|
||||
classes.add(Class.forName(cn));
|
||||
} catch (ClassNotFoundException e) {
|
||||
|
||||
@@ -146,6 +146,6 @@ public final class TableName {
|
||||
* @return true, if is valid
|
||||
*/
|
||||
public boolean isValid() {
|
||||
return name != null && name.length() > 0;
|
||||
return name != null && !name.isEmpty();
|
||||
}
|
||||
}
|
||||
@@ -492,7 +492,7 @@ public class DatabasePlatform {
|
||||
*/
|
||||
public String convertQuotedIdentifiers(String dbName) {
|
||||
// Ignore null values e.g. schema name or catalog
|
||||
if (dbName != null && dbName.length() > 0) {
|
||||
if (dbName != null && !dbName.isEmpty()) {
|
||||
if (dbName.charAt(0) == BACK_TICK) {
|
||||
if (dbName.charAt(dbName.length() - 1) == BACK_TICK) {
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ public class PathProperties implements FetchPath {
|
||||
String path = entry.getKey();
|
||||
String props = entry.getValue().getPropertiesAsString();
|
||||
|
||||
if (path == null || path.length() == 0) {
|
||||
if (path == null || path.isEmpty()) {
|
||||
query.select(props);
|
||||
} else {
|
||||
query.fetch(path, props);
|
||||
|
||||
@@ -108,7 +108,7 @@ class PathPropertiesParser {
|
||||
|
||||
private void addCurrentProperty() {
|
||||
String w = currentWord();
|
||||
if (w.length() > 0) {
|
||||
if (!w.isEmpty()) {
|
||||
currentPathProps.addProperty(w);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public final class TimeStringParser implements StringParser {
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public Object parse(String value) {
|
||||
if (value == null || value.trim().length() == 0) {
|
||||
if (value == null || value.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ public class StringHelper {
|
||||
String listDelimiter, String nameValueSeparator) {
|
||||
|
||||
HashMap<String, String> params = new HashMap<String, String>();
|
||||
if ((allNameValuePairs == null) || (allNameValuePairs.length() == 0)) {
|
||||
if ((allNameValuePairs == null) || (allNameValuePairs.isEmpty())) {
|
||||
return params;
|
||||
}
|
||||
// trim off any leading listDelimiter...
|
||||
@@ -155,7 +155,7 @@ public class StringHelper {
|
||||
* Return true if the value is null or an empty string.
|
||||
*/
|
||||
public static boolean isNull(String value) {
|
||||
return value == null || value.trim().length() == 0;
|
||||
return value == null || value.trim().isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,7 +189,7 @@ public class StringHelper {
|
||||
// there is a key without a value?
|
||||
String key = allNameValuePairs.substring(pos, delimPos);
|
||||
key = key.trim();
|
||||
if (key.length() > 0) {
|
||||
if (!key.isEmpty()) {
|
||||
map.put(key, null);
|
||||
}
|
||||
return getKeyValue(map, delimPos + 1, allNameValuePairs, listDelimiter,
|
||||
@@ -251,7 +251,7 @@ public class StringHelper {
|
||||
if (endPos == -1) {
|
||||
if (startPos <= str.length()) {
|
||||
String lastValue = str.substring(startPos, str.length());
|
||||
if (keepEmpties || lastValue.length() != 0) {
|
||||
if (keepEmpties || !lastValue.isEmpty()) {
|
||||
list.add(lastValue);
|
||||
}
|
||||
}
|
||||
@@ -260,7 +260,7 @@ public class StringHelper {
|
||||
} else {
|
||||
// get the delimited value... add it..
|
||||
String value = str.substring(startPos, endPos);
|
||||
if (keepEmpties || value.length() != 0) {
|
||||
if (keepEmpties || !value.isEmpty()) {
|
||||
list.add(value);
|
||||
}
|
||||
// recursively search as we are not at the end yet...
|
||||
|
||||
@@ -40,7 +40,7 @@ public class ExtraDdlXmlReader {
|
||||
* @param platforms The platforms (comma delimited) this script should run for
|
||||
*/
|
||||
public static boolean matchPlatform(String platformName, String platforms) {
|
||||
if (platforms == null || platforms.trim().length() == 0) {
|
||||
if (platforms == null || platforms.trim().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
String[] names = platforms.split("[,;]");
|
||||
|
||||
@@ -1141,7 +1141,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
|
||||
// already assigned (So custom or UUID)
|
||||
return;
|
||||
}
|
||||
if (desc.propertiesId().size() == 0) {
|
||||
if (desc.propertiesId().isEmpty()) {
|
||||
// bean doesn't have an Id property
|
||||
if (desc.isBaseTableType() && desc.getBeanFinder() == null) {
|
||||
// expecting an id property
|
||||
|
||||
@@ -283,7 +283,7 @@ public class DeployBeanDescriptor<T> {
|
||||
docStoreUpdate = docStore.update();
|
||||
docStoreDelete = docStore.delete();
|
||||
String doc = docStore.doc();
|
||||
if (doc.length() > 0) {
|
||||
if (!doc.isEmpty()) {
|
||||
docStorePathProperties = PathProperties.parse(doc);
|
||||
}
|
||||
}
|
||||
@@ -388,7 +388,7 @@ public class DeployBeanDescriptor<T> {
|
||||
public void setCache(Cache cache) {
|
||||
|
||||
String naturalKey = null;
|
||||
if (cache.naturalKey().length() > 0) {
|
||||
if (!cache.naturalKey().isEmpty()) {
|
||||
// find the property and mark as natural key property
|
||||
String propName = cache.naturalKey().trim();
|
||||
DeployBeanProperty beanProperty = getBeanProperty(propName);
|
||||
@@ -835,7 +835,7 @@ public class DeployBeanDescriptor<T> {
|
||||
return null;
|
||||
}
|
||||
String selectClause = sb.toString();
|
||||
if (selectClause.length() == 0) {
|
||||
if (selectClause.isEmpty()) {
|
||||
throw new IllegalStateException("Bean " + getFullName() + " has no properties?");
|
||||
}
|
||||
return selectClause.substring(0, selectClause.length() - 1);
|
||||
|
||||
@@ -386,7 +386,7 @@ public class DeployBeanProperty {
|
||||
* Set a specific DB column definition.
|
||||
*/
|
||||
public void setDbColumnDefn(String dbColumnDefn) {
|
||||
if (dbColumnDefn == null || dbColumnDefn.trim().length() == 0) {
|
||||
if (dbColumnDefn == null || dbColumnDefn.trim().isEmpty()) {
|
||||
this.dbColumnDefn = null;
|
||||
} else {
|
||||
this.dbColumnDefn = InternString.intern(dbColumnDefn);
|
||||
|
||||
+2
-2
@@ -178,7 +178,7 @@ public class DeployBeanPropertyAssocMany<T> extends DeployBeanPropertyAssoc<T> {
|
||||
* Set the default mapKey to use when returning a Map.
|
||||
*/
|
||||
public void setMapKey(String mapKey) {
|
||||
if (mapKey != null && mapKey.length() > 0) {
|
||||
if (mapKey != null && !mapKey.isEmpty()) {
|
||||
this.mapKey = mapKey;
|
||||
}
|
||||
}
|
||||
@@ -188,7 +188,7 @@ public class DeployBeanPropertyAssocMany<T> extends DeployBeanPropertyAssoc<T> {
|
||||
* list, set or map.
|
||||
*/
|
||||
public void setFetchOrderBy(String orderBy) {
|
||||
if (orderBy != null && orderBy.length() > 0) {
|
||||
if (orderBy != null && !orderBy.isEmpty()) {
|
||||
fetchOrderBy = orderBy;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public abstract class AnnotationBase {
|
||||
* Checks string is null or empty .
|
||||
*/
|
||||
protected boolean isEmpty(String s) {
|
||||
return s == null || s.trim().length() == 0;
|
||||
return s == null || s.trim().isEmpty();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ public class DeployInheritInfo {
|
||||
public void setDiscriminatorValue(String value) {
|
||||
if (value != null) {
|
||||
value = value.trim();
|
||||
if (value.length() != 0) {
|
||||
if (!value.isEmpty()) {
|
||||
discriminatorStringValue = value;
|
||||
// convert the value if desired
|
||||
if (discriminatorType == Types.INTEGER) {
|
||||
|
||||
@@ -70,7 +70,7 @@ public class SqlReservedWords {
|
||||
public static synchronized void addKeyword(String keyword){
|
||||
if (keyword != null){
|
||||
keyword = keyword.trim().toUpperCase();
|
||||
if (keyword.length() > 0){
|
||||
if (!keyword.isEmpty()){
|
||||
keywords.add(keyword);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class StringHelper {
|
||||
String listDelimiter, String nameValueSeparator) {
|
||||
|
||||
HashMap<String, String> params = new HashMap<String, String>();
|
||||
if ((allNameValuePairs == null) || (allNameValuePairs.length() == 0)) {
|
||||
if ((allNameValuePairs == null) || (allNameValuePairs.isEmpty())) {
|
||||
return params;
|
||||
}
|
||||
// trim off any leading listDelimiter...
|
||||
@@ -56,7 +56,7 @@ public class StringHelper {
|
||||
* Return true if the value is null or an empty string.
|
||||
*/
|
||||
public static boolean isNull(String value) {
|
||||
return value == null || value.trim().length() == 0;
|
||||
return value == null || value.trim().isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +90,7 @@ public class StringHelper {
|
||||
// there is a key without a value?
|
||||
String key = allNameValuePairs.substring(pos, delimPos);
|
||||
key = key.trim();
|
||||
if (key.length() > 0) {
|
||||
if (!key.isEmpty()) {
|
||||
map.put(key, null);
|
||||
}
|
||||
return getKeyValue(map, delimPos + 1, allNameValuePairs, listDelimiter,
|
||||
|
||||
@@ -466,7 +466,7 @@ public class CQueryBuilder {
|
||||
String inheritanceWhere = select.getInheritanceWhereSql();
|
||||
|
||||
boolean hasWhere = false;
|
||||
if (inheritanceWhere.length() > 0) {
|
||||
if (!inheritanceWhere.isEmpty()) {
|
||||
sb.append(" where");
|
||||
sb.append(inheritanceWhere);
|
||||
hasWhere = true;
|
||||
@@ -571,7 +571,7 @@ public class CQueryBuilder {
|
||||
}
|
||||
|
||||
private boolean isEmpty(String s) {
|
||||
return s == null || s.length() == 0;
|
||||
return s == null || s.isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public class CQueryBuilderRawSql {
|
||||
}
|
||||
|
||||
private boolean isEmpty(String s) {
|
||||
return s == null || s.length() == 0;
|
||||
return s == null || s.isEmpty();
|
||||
}
|
||||
|
||||
private String getOrderBy(CQueryPredicates predicates, RawSql.Sql sql) {
|
||||
|
||||
@@ -295,7 +295,7 @@ public class CQueryPredicates {
|
||||
}
|
||||
|
||||
private boolean isEmpty(String s) {
|
||||
return s == null || s.length() == 0;
|
||||
return s == null || s.isEmpty();
|
||||
}
|
||||
|
||||
private String parse(String expr, DeployParser deployParser) {
|
||||
|
||||
@@ -126,6 +126,7 @@ public class DefaultDbSqlContext implements DbSqlContext {
|
||||
|
||||
sb.append(a2);
|
||||
sb.append(" on ");
|
||||
|
||||
for (int i = 0; i < cols.length; i++) {
|
||||
TableJoinColumn pair = cols[i];
|
||||
if (i > 0) {
|
||||
@@ -136,8 +137,9 @@ public class DefaultDbSqlContext implements DbSqlContext {
|
||||
sb.append(a1).append(".").append(pair.getLocalDbColumn());
|
||||
}
|
||||
|
||||
|
||||
// add on any inheritance where clause
|
||||
if (inheritance != null && inheritance.length() > 0) {
|
||||
if (inheritance != null && !inheritance.isEmpty()) {
|
||||
sb.append(" and ").append(a2).append(".").append(inheritance);
|
||||
}
|
||||
|
||||
|
||||
@@ -417,7 +417,7 @@ public class SqlTreeBuilder {
|
||||
// This makes sense for transient properties used to
|
||||
// hold sum() count() type values (with SqlSelect)
|
||||
for (String propName : queryProps.getSelectProperties()) {
|
||||
if (propName.length() > 0) {
|
||||
if (!propName.isEmpty()) {
|
||||
addProperty(selectProps, desc, queryProps, propName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1161,7 +1161,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
|
||||
@Override
|
||||
public DefaultOrmQuery<T> order(String orderByClause) {
|
||||
if (orderByClause == null || orderByClause.trim().length() == 0) {
|
||||
if (orderByClause == null || orderByClause.trim().isEmpty()) {
|
||||
this.orderBy = null;
|
||||
} else {
|
||||
this.orderBy = new OrderBy<T>(this, orderByClause);
|
||||
|
||||
@@ -134,7 +134,7 @@ public class OrmQueryDetailParser {
|
||||
}
|
||||
}
|
||||
String whereClause = sb.toString().trim();
|
||||
if (whereClause.length() > 0) {
|
||||
if (!whereClause.isEmpty()) {
|
||||
rawWhereClause = whereClause;
|
||||
}
|
||||
|
||||
|
||||
@@ -236,7 +236,7 @@ public class OrmQueryProperties implements Serializable {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void configureBeanQuery(SpiQuery<?> query) {
|
||||
|
||||
if (trimmedProperties != null && trimmedProperties.length() > 0) {
|
||||
if (trimmedProperties != null && !trimmedProperties.isEmpty()) {
|
||||
query.select(trimmedProperties);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -122,7 +122,7 @@ public class OrmQueryPropertiesParser {
|
||||
String temp;
|
||||
for (int i = 0; i < res.length; i++) {
|
||||
temp = res[i].trim();
|
||||
if (temp.length() > 0) {
|
||||
if (!temp.isEmpty()) {
|
||||
if (count > 0) {
|
||||
sb.append(",");
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ public class TCsvReader<T> implements CsvReader<T> {
|
||||
|
||||
strValue = strValue.trim();
|
||||
|
||||
if (strValue.length() == 0) {
|
||||
if (strValue.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ScalarTypeChar extends ScalarTypeBaseVarchar<Character> {
|
||||
|
||||
public Character read(DataReader dataReader) throws SQLException {
|
||||
String string = dataReader.getString();
|
||||
if (string == null || string.length() == 0) {
|
||||
if (string == null || string.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
return string.charAt(0);
|
||||
|
||||
@@ -86,7 +86,7 @@ public class BindParamsParser {
|
||||
|
||||
if (params.isSameBindHash()) {
|
||||
String preparedSql = params.getPreparedSql();
|
||||
if (preparedSql != null && preparedSql.length() > 0) {
|
||||
if (preparedSql != null && !preparedSql.isEmpty()) {
|
||||
// the sql has already been parsed and positionedParameters are set in order
|
||||
return preparedSql;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public final class SortByClauseParser {
|
||||
}
|
||||
|
||||
private Property parseSection(String section) {
|
||||
if (section.length() == 0) {
|
||||
if (section.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
String[] words = section.split(" ");
|
||||
|
||||
+1
-1
@@ -321,7 +321,7 @@ public abstract class DocStoreBeanBaseAdapter<T> implements DocStoreBeanAdapter<
|
||||
* Return the supplied value or default to the bean name lower case.
|
||||
*/
|
||||
protected String derive(BeanType<?> desc, String suppliedValue) {
|
||||
return (suppliedValue != null && suppliedValue.length() > 0) ? suppliedValue : desc.getName().toLowerCase();
|
||||
return (suppliedValue != null && !suppliedValue.isEmpty()) ? suppliedValue : desc.getName().toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user