#1153 - Refactor move SplitName into io.ebean.util

This commit is contained in:
rob bygrave committed 2017-10-05 00:41:32 +13:00
1 parent d366336ee5
commit 0bf4c84bc8
26 files changed
+26 -19

No files matched your search

@@ -9,6 +9,7 @@ import io.ebean.config.dbplatform.SqlLimitResponse;
import io.ebean.config.dbplatform.SqlLimiter;
import io.ebean.event.readaudit.ReadAuditQueryPlan;
import io.ebean.text.PathProperties;
import io.ebean.util.SplitName;
import io.ebean.util.StringHelper;
import io.ebeaninternal.api.ManyWhereJoins;
import io.ebeaninternal.api.SpiQuery;
@@ -1,81 +0,0 @@
package io.ebeaninternal.server.query;
/**
* Helper for dot notation property paths.
*/
public class SplitName {
private static final char PERIOD = '.';
/**
* Add the two name sections together in dot notation.
*/
public static String add(String prefix, String name) {
if (prefix != null) {
return prefix + "." + name;
} else {
return name;
}
}
/**
* Return the number of occurrences of char in name.
*/
public static int count(String name) {
int count = 0;
for (int i = 0; i < name.length(); i++) {
if (PERIOD == name.charAt(i)) {
count++;
}
}
return count;
}
/**
* Return the parent part of the path.
*/
public static String parent(String name) {
if (name == null) {
return null;
} else {
String[] s = split(name, true);
return s[0];
}
}
/**
* Return the name split by last.
*/
public static String[] split(String name) {
return split(name, true);
}
/**
* Return the first part of the name.
*/
public static String begin(String name) {
return splitBegin(name)[0];
}
public static String[] splitBegin(String name) {
return split(name, false);
}
private static String[] split(String name, boolean last) {
int pos = last ? name.lastIndexOf('.') : name.indexOf('.');
if (pos == -1) {
if (last) {
return new String[]{null, name};
} else {
return new String[]{name, null};
}
} else {
String s0 = name.substring(0, pos);
String s1 = name.substring(pos + 1);
return new String[]{s0, s1};
}
}
}
@@ -1,5 +1,6 @@
package io.ebeaninternal.server.query;
import io.ebean.util.SplitName;
import io.ebeaninternal.server.deploy.BeanDescriptor;
import io.ebeaninternal.server.el.ElPropertyDeploy;
@@ -1,5 +1,6 @@
package io.ebeaninternal.server.query;
import io.ebean.util.SplitName;
import io.ebeaninternal.api.ManyWhereJoins;
import io.ebeaninternal.api.PropertyJoin;
import io.ebeaninternal.api.SpiQuery;
@@ -5,6 +5,7 @@ import io.ebean.bean.BeanCollection;
import io.ebean.bean.EntityBean;
import io.ebean.bean.EntityBeanIntercept;
import io.ebean.bean.PersistenceContext;
import io.ebean.util.SplitName;
import io.ebean.util.StringHelper;
import io.ebeaninternal.api.SpiQuery;
import io.ebeaninternal.api.SpiQuery.Mode;
@@ -2,6 +2,7 @@ package io.ebeaninternal.server.query;
import io.ebean.Version;
import io.ebean.bean.EntityBean;
import io.ebean.util.SplitName;
import io.ebeaninternal.api.SpiQuery;
import io.ebeaninternal.server.deploy.BeanPropertyAssoc;
import io.ebeaninternal.server.deploy.BeanPropertyAssocMany;
@@ -2,6 +2,7 @@ package io.ebeaninternal.server.query;
import io.ebean.Version;
import io.ebean.bean.EntityBean;
import io.ebean.util.SplitName;
import io.ebeaninternal.api.SpiQuery;
import io.ebeaninternal.server.deploy.BeanPropertyAssoc;
import io.ebeaninternal.server.deploy.BeanPropertyAssocMany;