View Javadoc
1   /*
2    * Licensed under the Apache License, Version 2.0 (the "License");
3    * you may not use this file except in compliance with the License.
4    * You may obtain a copy of the License at
5    *
6    * http://www.apache.org/licenses/LICENSE-2.0
7    *
8    * Unless required by applicable law or agreed to in writing, software
9    * distributed under the License is distributed on an "AS IS" BASIS,
10   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11   * See the License for the specific language governing permissions and
12   * limitations under the License.
13   */
14  package org.basepom.mojo.duplicatefinder;
15  
16  import static com.google.common.base.Preconditions.checkState;
17  
18  public enum ConflictState {
19      // Conflict states in order from low to high.
20      NO_CONFLICT("no-conflict", ""),
21      CONFLICT_CONTENT_EQUAL("content-equal", "(but equal)"),
22      CONFLICT_CONTENT_DIFFERENT("content-different", "and different");
23  
24      private final String value;
25      private final String hint;
26  
27      ConflictState(String value, String hint) {
28          this.value = value;
29          this.hint = hint;
30      }
31  
32      public String getHint() {
33          return hint;
34      }
35  
36      public static ConflictState max(final ConflictState... states) {
37          checkState(states.length > 0, "states is empty");
38  
39          ConflictState result = states[0];
40          for (int i = 1; i < states.length; i++) {
41              if (states[i].ordinal() > result.ordinal()) {
42                  result = states[i];
43              }
44          }
45  
46          return result;
47      }
48  
49      @Override
50      public String toString() {
51          return value;
52      }
53  }