@@ -514,23 +514,6 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr
514514 );
515515 return this ;
516516 }
517- /**
518- * Remove existing ordering and set a field to be sorted on. This may be a direct field or a field
519- * related through an object lookup or master-detail relationship.
520- * Use the set to store unique field names, since we only want to sort
521- * by the same field one time. The sort expressions are stored in a list
522- * so that they are applied to the SOQL in the same order that they
523- * were added in.
524- * @param fieldName The string value of the field to be sorted on
525- * @param SortOrder the direction to be sorted on (ASCENDING or DESCENDING)
526- * @param nullsLast whether to sort null values last (NULLS LAST keyword included).
527- **/
528- public fflib_QueryFactory setOrdering (String fieldName , SortOrder direction , Boolean nullsLast ){
529- order = new List <Ordering > {
530- new Ordering (getFieldToken (fieldName ), direction , nullsLast )
531- };
532- return this ;
533- }
534517
535518 /**
536519 * Add a field to be sorted on. This may be a direct field or a field
@@ -550,25 +533,26 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr
550533 return this ;
551534 }
552535
553- /**
554- * Remove existing ordering and set a field to be sorted on. This may be a direct field or a field
536+ /**
537+ * Add a field to be sorted on. This may be a direct field or a field
555538 * related through an object lookup or master-detail relationship.
556539 * Use the set to store unique field names, since we only want to sort
557540 * by the same field one time. The sort expressions are stored in a list
558541 * so that they are applied to the SOQL in the same order that they
559542 * were added in.
560- * @param field The SObjectfield to sort. This can only be a direct reference.
543+ * The "NULLS FIRST" keywords will be included by default. If "NULLS LAST"
544+ * is required, use one of the overloaded addOrdering methods which include this parameter.
545+ * @param fieldName The string value of the field to be sorted on
561546 * @param SortOrder the direction to be sorted on (ASCENDING or DESCENDING)
562- * @param nullsLast whether to sort null values last (NULLS LAST keyword included).
563- **/
564- public fflib_QueryFactory setOrdering (SObjectField field , SortOrder direction , Boolean nullsLast ){
565- order = new List <Ordering > {
566- new Ordering (new QueryField (field ), direction , nullsLast )
567- };
547+ **/
548+ public fflib_QueryFactory addOrdering (String fieldName , SortOrder direction ){
549+ order .add (
550+ new Ordering (getFieldToken (fieldName ), direction )
551+ );
568552 return this ;
569553 }
570554
571- /**
555+ /**
572556 * Add a field to be sorted on. This may be a direct field or a field
573557 * related through an object lookup or master-detail relationship.
574558 * Use the set to store unique field names, since we only want to sort
@@ -577,46 +561,43 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr
577561 * were added in.
578562 * The "NULLS FIRST" keywords will be included by default. If "NULLS LAST"
579563 * is required, use one of the overloaded addOrdering methods which include this parameter.
580- * @param fieldName The string value of the field to be sorted on
564+ * @param field The SObjectfield to sort. This can only be a direct reference.
581565 * @param SortOrder the direction to be sorted on (ASCENDING or DESCENDING)
582- **/
583- public fflib_QueryFactory addOrdering (String fieldName , SortOrder direction ){
566+ **/
567+ public fflib_QueryFactory addOrdering (SObjectField field , SortOrder direction ){
584568 order .add (
585569 new Ordering (getFieldPath (fieldName ), direction )
586570 );
587571 return this ;
588572 }
589-
590- /**
573+ /**
591574 * Remove existing ordering and set a field to be sorted on. This may be a direct field or a field
592575 * related through an object lookup or master-detail relationship.
593576 * Use the set to store unique field names, since we only want to sort
594577 * by the same field one time. The sort expressions are stored in a list
595578 * so that they are applied to the SOQL in the same order that they
596579 * were added in.
597- * The "NULLS FIRST" keywords will be included by default. If "NULLS LAST"
598- * is required, use one of the overloaded addOrdering methods which include this parameter.
599580 * @param fieldName The string value of the field to be sorted on
600581 * @param SortOrder the direction to be sorted on (ASCENDING or DESCENDING)
582+ * @param nullsLast whether to sort null values last (NULLS LAST keyword included).
601583 **/
602- public fflib_QueryFactory setOrdering (String fieldName , SortOrder direction ){
603- order = new List < Ordering > {
604- new Ordering (getFieldToken (fieldName ), direction )
605- };
584+ public fflib_QueryFactory setOrdering (String fieldName , SortOrder direction , Boolean nullsLast ){
585+ setOrdering (
586+ new Ordering (getFieldToken (fieldName ), direction , nullsLast )
587+ );
606588 return this ;
607589 }
608590
609591 /**
610- * Add a field to be sorted on. This may be a direct field or a field
592+ * Remove existing ordering and set a field to be sorted on. This may be a direct field or a field
611593 * related through an object lookup or master-detail relationship.
612594 * Use the set to store unique field names, since we only want to sort
613595 * by the same field one time. The sort expressions are stored in a list
614596 * so that they are applied to the SOQL in the same order that they
615597 * were added in.
616- * The "NULLS FIRST" keywords will be included by default. If "NULLS LAST"
617- * is required, use one of the overloaded addOrdering methods which include this parameter.
618598 * @param field The SObjectfield to sort. This can only be a direct reference.
619599 * @param SortOrder the direction to be sorted on (ASCENDING or DESCENDING)
600+ * @param nullsLast whether to sort null values last (NULLS LAST keyword included).
620601 **/
621602 public fflib_QueryFactory addOrdering (SObjectField field , SortOrder direction ){
622603 order .add (
@@ -625,6 +606,25 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr
625606 return this ;
626607 }
627608
609+ /**
610+ * Remove existing ordering and set a field to be sorted on. This may be a direct field or a field
611+ * related through an object lookup or master-detail relationship.
612+ * Use the set to store unique field names, since we only want to sort
613+ * by the same field one time. The sort expressions are stored in a list
614+ * so that they are applied to the SOQL in the same order that they
615+ * were added in.
616+ * The "NULLS FIRST" keywords will be included by default. If "NULLS LAST"
617+ * is required, use one of the overloaded addOrdering methods which include this parameter.
618+ * @param fieldName The string value of the field to be sorted on
619+ * @param SortOrder the direction to be sorted on (ASCENDING or DESCENDING)
620+ **/
621+ public fflib_QueryFactory setOrdering (String fieldName , SortOrder direction ){
622+ setOrdering (
623+ new Ordering (getFieldToken (fieldName ), direction )
624+ );
625+ return this ;
626+ }
627+
628628 /**
629629 * Remove existing ordering and set a field to be sorted on. This may be a direct field or a field
630630 * related through an object lookup or master-detail relationship.
@@ -638,9 +638,9 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr
638638 * @param SortOrder the direction to be sorted on (ASCENDING or DESCENDING)
639639 **/
640640 public fflib_QueryFactory setOrdering (SObjectField field , SortOrder direction ){
641- order = new List < Ordering > {
642- new Ordering (new QueryField ( field ) , direction )
643- } ;
641+ setOrdering (
642+ new Ordering (field , direction )
643+ ) ;
644644 return this ;
645645 }
646646
0 commit comments