File tree Expand file tree Collapse file tree
src/main/java/graphql/schema Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33import com .google .common .collect .ImmutableList ;
44import graphql .Internal ;
55
6- import java .util .ArrayList ;
76import java .util .Collection ;
87import java .util .Comparator ;
98import java .util .List ;
109
1110@ Internal
1211public class GraphqlTypeComparators {
1312
13+ private static final Comparator <? super GraphQLSchemaElement > BY_NAME_ASCENDING =
14+ Comparator .comparing (graphQLSchemaElement ->
15+ ((GraphQLNamedSchemaElement ) graphQLSchemaElement ).getName ());
16+
1417 /**
1518 * This sorts the list of {@link graphql.schema.GraphQLType} objects (by name) and allocates a new sorted
1619 * list back.
@@ -22,9 +25,7 @@ public class GraphqlTypeComparators {
2225 * @return a new allocated list of sorted things
2326 */
2427 public static <T extends GraphQLSchemaElement > List <T > sortTypes (Comparator <? super GraphQLSchemaElement > comparator , Collection <T > types ) {
25- List <T > sorted = new ArrayList <>(types );
26- sorted .sort (comparator );
27- return ImmutableList .copyOf (sorted );
28+ return ImmutableList .sortedCopyOf (comparator , types );
2829 }
2930
3031 /**
@@ -42,7 +43,7 @@ public static Comparator<? super GraphQLSchemaElement> asIsOrder() {
4243 * @return a comparator that compares {@link graphql.schema.GraphQLType} objects by ascending name
4344 */
4445 public static Comparator <? super GraphQLSchemaElement > byNameAsc () {
45- return Comparator . comparing ( graphQLSchemaElement -> (( GraphQLNamedSchemaElement ) graphQLSchemaElement ). getName ()) ;
46+ return BY_NAME_ASCENDING ;
4647 }
4748
4849}
You can’t perform that action at this time.
0 commit comments