mirror of https://github.com/tasks/tasks
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.4 KiB
Java
44 lines
1.4 KiB
Java
15 years ago
|
package com.todoroo.andlib.data.sql;
|
||
|
|
||
|
import static com.todoroo.andlib.data.sql.Constants.JOIN;
|
||
|
import static com.todoroo.andlib.data.sql.Constants.ON;
|
||
|
import static com.todoroo.andlib.data.sql.Constants.SPACE;
|
||
|
|
||
|
public class Join {
|
||
|
private final Table joinTable;
|
||
|
private final JoinType joinType;
|
||
|
private final Criterion[] criterions;
|
||
|
|
||
|
private Join(Table table, JoinType joinType, Criterion... criterions) {
|
||
|
joinTable = table;
|
||
|
this.joinType = joinType;
|
||
|
this.criterions = criterions;
|
||
|
}
|
||
|
|
||
|
public static Join inner(Table expression, Criterion... criterions) {
|
||
|
return new Join(expression, JoinType.INNER, criterions);
|
||
|
}
|
||
|
|
||
|
public static Join left(Table table, Criterion... criterions) {
|
||
|
return new Join(table, JoinType.LEFT, criterions);
|
||
|
}
|
||
|
|
||
|
public static Join right(Table table, Criterion... criterions) {
|
||
|
return new Join(table, JoinType.RIGHT, criterions);
|
||
|
}
|
||
|
|
||
|
public static Join out(Table table, Criterion... criterions) {
|
||
|
return new Join(table, JoinType.OUT, criterions);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public String toString() {
|
||
|
StringBuilder sb = new StringBuilder();
|
||
|
sb.append(joinType).append(SPACE).append(JOIN).append(SPACE).append(joinTable).append(SPACE).append(ON);
|
||
|
for (Criterion criterion : criterions) {
|
||
|
sb.append(SPACE).append(criterion);
|
||
|
}
|
||
|
return sb.toString();
|
||
|
}
|
||
|
}
|