64 lines
1004 B
Java
64 lines
1004 B
Java
package +zoccolo+.jpa;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public class OrderBuilder {
|
|
|
|
public static enum OrderType {
|
|
ASC("asc"), DESC("desc");
|
|
|
|
private String value;
|
|
|
|
private OrderType(String value) {
|
|
this.value = value;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return this.value.toString();
|
|
}
|
|
}
|
|
|
|
private List<Order> orders;
|
|
|
|
public OrderBuilder() {
|
|
orders = new ArrayList<Order>();
|
|
}
|
|
|
|
public OrderBuilder add(final String order) {
|
|
orders.add(new Order() {
|
|
public String getOrder() {
|
|
return order;
|
|
}
|
|
|
|
public String getAsc() {
|
|
return OrderType.ASC.toString();
|
|
}
|
|
});
|
|
return this;
|
|
}
|
|
|
|
public OrderBuilder add(final String order, final String asc) {
|
|
orders.add(new Order() {
|
|
public String getOrder() {
|
|
return order;
|
|
}
|
|
|
|
public String getAsc() {
|
|
return asc;
|
|
}
|
|
});
|
|
return this;
|
|
}
|
|
|
|
public List<Order> getOrders() {
|
|
return orders;
|
|
}
|
|
|
|
public Order[] toArray() {
|
|
return orders.toArray(new Order[] {});
|
|
}
|
|
|
|
}
|