Skip to content

Instantly share code, notes, and snippets.

@ZergyPoo
Created November 6, 2019 00:38
Show Gist options
  • Save ZergyPoo/9442469217473403ebad5ef5e8841d79 to your computer and use it in GitHub Desktop.
Save ZergyPoo/9442469217473403ebad5ef5e8841d79 to your computer and use it in GitHub Desktop.
public class OrderBy {
@TestVisible
private String orderDirection;
private String fieldName;
public OrderBy(String orderDirection, String fieldName) {
this.orderDirection = orderDirection;
this.fieldName = fieldName;
}
public OrderBy(String orderDirection, Schema.SObjectField field) {
this(orderDirection, field.getDescribe().getName());
}
public OrderBy(Schema.SObjectField field) {
this('ASC', field);
}
public String generateString() {
return String.format(
'{0} {1}',
new List<String> {
this.fieldName,
this.orderDirection
}
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment