mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Refactor tidy SqlTreeNodeBean
This commit is contained in:
@@ -46,12 +46,12 @@ class SqlTreeLoadBean implements SqlTreeLoad {
|
||||
this.temporalMode = node.temporalMode;
|
||||
this.temporalVersions = node.temporalVersions;
|
||||
this.nodeBeanProp = node.nodeBeanProp;
|
||||
this.readId = node.readId;//!aggregationRoot && withId && desc.hasId();
|
||||
this.readId = node.readId;
|
||||
this.readIdNormal = readId && !temporalVersions;
|
||||
this.disableLazyLoad = node.disableLazyLoad;// disableLazyLoad || !readIdNormal || desc.isRawSqlBased();
|
||||
this.partialObject = node.partialObject;//props.isPartialObject();
|
||||
this.properties = node.properties;//props.getProps();
|
||||
this.pathMap = node.pathMap;//createPathMap(prefix, desc);
|
||||
this.disableLazyLoad = node.disableLazyLoad;
|
||||
this.partialObject = node.partialObject;
|
||||
this.properties = node.properties;
|
||||
this.pathMap = node.pathMap;
|
||||
this.children = node.createLoadChildren();
|
||||
}
|
||||
|
||||
|
||||
@@ -15,14 +15,13 @@ import java.util.*;
|
||||
class SqlTreeNodeBean implements SqlTreeNode {
|
||||
|
||||
private static final SqlTreeLoad[] NO_LOAD_CHILDREN = new SqlTreeLoad[0];
|
||||
private static final SqlTreeNode[] NO_CHILDREN = new SqlTreeNode[0];
|
||||
|
||||
final STreeType desc;
|
||||
final IdBinder idBinder;
|
||||
/**
|
||||
* The children which will be other SelectBean or SelectProxyBean.
|
||||
*/
|
||||
final SqlTreeNode[] children;
|
||||
final List<SqlTreeNode> children;
|
||||
/**
|
||||
* Set to true if this is a partial object fetch.
|
||||
*/
|
||||
@@ -94,8 +93,8 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
this.disableLazyLoad = disableLazyLoad || !readIdNormal || desc.isRawSqlBased();
|
||||
this.partialObject = props.isPartialObject();
|
||||
this.properties = props.getProps();
|
||||
this.children = myChildren == null ? NO_CHILDREN : myChildren.toArray(new SqlTreeNode[0]);
|
||||
pathMap = createPathMap(prefix, desc);
|
||||
this.children = myChildren == null ? Collections.emptyList() : myChildren;
|
||||
this.pathMap = createPathMap(prefix, desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -104,10 +103,10 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
}
|
||||
|
||||
protected SqlTreeLoad[] createLoadChildren() {
|
||||
if (children.length == 0) {
|
||||
if (children.isEmpty()) {
|
||||
return NO_LOAD_CHILDREN;
|
||||
}
|
||||
List<SqlTreeLoad> loadChildren = new ArrayList<>(children.length);
|
||||
List<SqlTreeLoad> loadChildren = new ArrayList<>(children.size());
|
||||
for (SqlTreeNode child : children) {
|
||||
SqlTreeLoad load = child.createLoad();
|
||||
if (load != null) {
|
||||
@@ -119,19 +118,19 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
|
||||
@Override
|
||||
public final boolean isSingleProperty() {
|
||||
return properties != null && properties.length == 1 && children.length == 0;
|
||||
return properties != null && properties.length == 1 && children.isEmpty();
|
||||
}
|
||||
|
||||
private Map<String, String> createPathMap(String prefix, STreeType desc) {
|
||||
HashMap<String, String> m = new HashMap<>();
|
||||
for (STreePropertyAssocMany many : desc.propsMany()) {
|
||||
String name = many.name();
|
||||
m.put(name, getPath(prefix, name));
|
||||
m.put(name, path(prefix, name));
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
private String getPath(String prefix, String propertyName) {
|
||||
private String path(String prefix, String propertyName) {
|
||||
if (prefix == null) {
|
||||
return propertyName;
|
||||
} else {
|
||||
@@ -144,7 +143,7 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
if (readId) {
|
||||
if (inheritInfo != null) {
|
||||
// discriminator column always proceeds id column
|
||||
selectChain.add(getPath(prefix, inheritInfo.getDiscriminatorColumn()));
|
||||
selectChain.add(path(prefix, inheritInfo.getDiscriminatorColumn()));
|
||||
}
|
||||
idBinder.buildRawSqlSelectChain(prefix, selectChain);
|
||||
}
|
||||
@@ -399,7 +398,7 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void unselectLobs() {
|
||||
|
||||
Reference in New Issue
Block a user