No effective change - format only

This commit is contained in:
Robin Bygrave
2015-08-01 08:54:49 +12:00
parent f50b18556e
commit 4f2d669897
34 changed files with 1283 additions and 1291 deletions
@@ -16,62 +16,62 @@ import com.avaje.ebeaninternal.server.el.ElPropertyValue;
*/
public class CQueryOrderBy {
private final BeanDescriptor<?> desc;
private final SpiQuery<?> query;
/**
* Create the logical order by clause.
*/
public static String parse(BeanDescriptor<?> desc, SpiQuery<?> query) {
return new CQueryOrderBy(desc, query).parseInternal();
}
private CQueryOrderBy(BeanDescriptor<?> desc, SpiQuery<?> query) {
this.desc = desc;
this.query = query;
}
private String parseInternal() {
OrderBy<?> orderBy = query.getOrderBy();
if (orderBy == null){
return null;
}
StringBuilder sb = new StringBuilder();
private final BeanDescriptor<?> desc;
List<Property> properties = orderBy.getProperties();
if (properties.isEmpty()){
// order by clause removed by filterMany()
return null;
}
for (int i = 0; i < properties.size(); i++) {
if (i > 0){
sb.append(", ");
}
Property p = properties.get(i);
String expression = parseProperty(p);
sb.append(expression);
}
return sb.toString();
private final SpiQuery<?> query;
/**
* Create the logical order by clause.
*/
public static String parse(BeanDescriptor<?> desc, SpiQuery<?> query) {
return new CQueryOrderBy(desc, query).parseInternal();
}
private CQueryOrderBy(BeanDescriptor<?> desc, SpiQuery<?> query) {
this.desc = desc;
this.query = query;
}
private String parseInternal() {
OrderBy<?> orderBy = query.getOrderBy();
if (orderBy == null) {
return null;
}
private String parseProperty(Property p) {
String propName = p.getProperty();
ElPropertyValue el = desc.getElGetValue(propName);
if (el == null){
return p.toStringFormat();
}
BeanProperty beanProperty = el.getBeanProperty();
if (beanProperty instanceof BeanPropertyAssoc<?>){
BeanPropertyAssoc<?> ap = (BeanPropertyAssoc<?>)beanProperty;
IdBinder idBinder = ap.getTargetDescriptor().getIdBinder();
return idBinder.getOrderBy(el.getElName(), p.isAscending());
}
return p.toStringFormat();
StringBuilder sb = new StringBuilder();
List<Property> properties = orderBy.getProperties();
if (properties.isEmpty()) {
// order by clause removed by filterMany()
return null;
}
for (int i = 0; i < properties.size(); i++) {
if (i > 0) {
sb.append(", ");
}
Property p = properties.get(i);
String expression = parseProperty(p);
sb.append(expression);
}
return sb.toString();
}
private String parseProperty(Property p) {
String propName = p.getProperty();
ElPropertyValue el = desc.getElGetValue(propName);
if (el == null) {
return p.toStringFormat();
}
BeanProperty beanProperty = el.getBeanProperty();
if (beanProperty instanceof BeanPropertyAssoc<?>) {
BeanPropertyAssoc<?> ap = (BeanPropertyAssoc<?>) beanProperty;
IdBinder idBinder = ap.getTargetDescriptor().getIdBinder();
return idBinder.getOrderBy(el.getElName(), p.isAscending());
}
return p.toStringFormat();
}
}