1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.metainf.model;
17
18 import com.google.common.collect.ImmutableList;
19 import org.kuali.common.util.metainf.spring.MetaInfDataLocation;
20 import org.kuali.common.util.metainf.spring.MetaInfDataType;
21
22 import java.util.Collections;
23 import java.util.Comparator;
24 import java.util.List;
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 public class MetaInfResourceConfigurablePathComparator implements Comparator<MetaInfResource> {
42
43 private ConfigurablePathComparator comparator = ConfigurablePathComparator.builder().build();
44
45 @Override
46 public int compare(MetaInfResource one, MetaInfResource two) {
47 return comparator.compare(one.getLocation(), two.getLocation());
48 }
49
50 public static Builder builder() {
51 return new Builder();
52 }
53
54 public static class Builder {
55
56
57 private List<String> qualifierOrder = Collections.emptyList();
58 private List<MetaInfDataLocation> locationOrder = Collections.emptyList();
59 private List<MetaInfDataType> typeOrder = Collections.emptyList();
60
61 public Builder qualifierOrder(List<String> qualifierOrder) {
62 this.qualifierOrder = qualifierOrder;
63 return this;
64 }
65
66 public Builder locationOrder(List<MetaInfDataLocation> locationOrder) {
67 this.locationOrder = locationOrder;
68 return this;
69 }
70
71 public Builder typeOrder(List<MetaInfDataType> typeOrder) {
72 this.typeOrder = typeOrder;
73 return this;
74 }
75
76 public MetaInfResourceConfigurablePathComparator build() {
77 this.qualifierOrder = ImmutableList.copyOf(qualifierOrder);
78 this.locationOrder = ImmutableList.copyOf(locationOrder);
79 this.typeOrder = ImmutableList.copyOf(typeOrder);
80 return new MetaInfResourceConfigurablePathComparator(this);
81 }
82
83 }
84
85 private MetaInfResourceConfigurablePathComparator(Builder builder) {
86 ConfigurablePathComparator.Builder comparatorBuilder = ConfigurablePathComparator.builder();
87 comparatorBuilder = comparatorBuilder.qualifierOrder(builder.qualifierOrder);
88 comparatorBuilder = comparatorBuilder.locationOrder(builder.locationOrder);
89 comparatorBuilder = comparatorBuilder.typeOrder(builder.typeOrder);
90 comparator = comparatorBuilder.build();
91 }
92
93 }