[LIB-10] SerialVersionUID for Serializable classes
[snooker-score-api.git] / src / main / java / org / hedgecode / snooker / compare / SeedingComparators.java
1 /*
2  * Copyright (c) 2017-2020. Developed by Hedgecode.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.hedgecode.snooker.compare;
18
19 import java.util.Comparator;
20
21 import org.hedgecode.snooker.api.Seeding;
22
23 /**
24  * Set of Comparators for {@link Seeding}.
25  * 1. Sorting by Event {@link EventComparator};
26  * 2. Sorting by Player {@link PlayerComparator};
27  * 3. Sorting by Seeding Number {@link SeedingComparator}.
28  *
29  * @author Dmitry Samoshin aka gotty
30  */
31 public enum SeedingComparators {
32
33     EVENT   ( new EventComparator() ),
34     PLAYER  ( new PlayerComparator() ),
35     SEEDING ( new SeedingComparator() );
36
37     private Comparator<Seeding> comparator;
38
39     SeedingComparators(Comparator<Seeding> comparator) {
40         this.comparator = comparator;
41     }
42
43     public Comparator<Seeding> comparator() {
44         return comparator;
45     }
46
47     static class EventComparator implements Comparator<Seeding> {
48
49         @Override
50         public int compare(Seeding seeding1, Seeding seeding2) {
51             return seeding1.eventId() - seeding2.eventId();
52         }
53
54     }
55
56     static class PlayerComparator implements Comparator<Seeding> {
57
58         @Override
59         public int compare(Seeding seeding1, Seeding seeding2) {
60             return seeding1.playerId() - seeding2.playerId();
61         }
62
63     }
64
65     static class SeedingComparator implements Comparator<Seeding> {
66
67         @Override
68         public int compare(Seeding seeding1, Seeding seeding2) {
69             return seeding1.seeding() - seeding2.seeding();
70         }
71
72     }
73
74 }