예제 #1
0
 private void drawAux(String indent, StringBuilder builder) {
   builder.append(value);
   for (List<Node<T>> it = children; !it.isEmpty(); it = it.tail()) {
     final boolean isLast = it.tail().isEmpty();
     builder.append('\n').append(indent).append(isLast ? "└──" : "├──");
     it.head().drawAux(indent + (isLast ? "   " : "│  "), builder);
   }
 }
예제 #2
0
 @Override
 protected <T> CharSequence createSQLJoin(
     final Function<Class, EntityInfo> func,
     final Map<Class, String> joinTabalis,
     final EntityInfo<T> info) {
   boolean morejoin = false;
   if (this.joinEntity == null) {
     if (this.joinClass != null) this.joinEntity = func.apply(this.joinClass);
     if (this.nodes != null) {
       for (FilterNode node : this.nodes) {
         if (node instanceof FilterJoinNode) {
           FilterJoinNode joinNode = ((FilterJoinNode) node);
           if (joinNode.joinClass != null) {
             joinNode.joinEntity = func.apply(joinNode.joinClass);
             if (this.joinClass != null && this.joinClass != joinNode.joinClass) morejoin = true;
           }
         }
       }
     }
   }
   StringBuilder sb = new StringBuilder();
   if (this.joinClass != null) {
     sb.append(createElementSQLJoin(joinTabalis, info, this));
   }
   if (morejoin) {
     Set<Class> set = new HashSet<>();
     if (this.joinClass != null) set.add(this.joinClass);
     for (FilterNode node : this.nodes) {
       if (node instanceof FilterJoinNode) {
         FilterJoinNode joinNode = ((FilterJoinNode) node);
         if (!set.contains(joinNode.joinClass)) {
           CharSequence cs = createElementSQLJoin(joinTabalis, info, joinNode);
           if (cs != null) {
             sb.append(cs);
             set.add(joinNode.joinClass);
           }
         }
       }
     }
   }
   return sb;
 }
예제 #3
0
 private static CharSequence createElementSQLJoin(
     final Map<Class, String> joinTabalis, final EntityInfo info, final FilterJoinNode node) {
   if (node.joinClass == null) return null;
   StringBuilder sb = new StringBuilder();
   String[] joinColumns = node.joinColumns;
   sb.append(" INNER JOIN ")
       .append(node.joinEntity.getTable())
       .append(" ")
       .append(joinTabalis.get(node.joinClass))
       .append(" ON ")
       .append(info.getSQLColumn("a", joinColumns[0]))
       .append(" = ")
       .append(node.joinEntity.getSQLColumn(joinTabalis.get(node.joinClass), joinColumns[0]));
   for (int i = 1; i < joinColumns.length; i++) {
     sb.append(" AND ")
         .append(info.getSQLColumn("a", joinColumns[i]))
         .append(" = ")
         .append(node.joinEntity.getSQLColumn(joinTabalis.get(node.joinClass), joinColumns[i]));
   }
   return sb;
 }
예제 #4
0
 @Override
 public String draw() {
   StringBuilder builder = new StringBuilder();
   drawAux("", builder);
   return builder.toString();
 }