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  
15  package org.basepom.mojo.duplicatefinder;
16  
17  import static com.google.common.base.Preconditions.checkState;
18  
19  public enum ConflictState {
20      // Conflict states in order from low to high.
21      NO_CONFLICT("no-conflict", ""),
22      CONFLICT_CONTENT_EQUAL("content-equal", "(but equal)"),
23      CONFLICT_CONTENT_DIFFERENT("content-different", "and different");
24  
25      private final String value;
26      private final String hint;
27  
28      ConflictState(String value, String hint) {
29          this.value = value;
30          this.hint = hint;
31      }
32  
33      public String getHint() {
34          return hint;
35      }
36  
37      public static ConflictState max(final ConflictState... states) {
38          checkState(states.length > 0, "states is empty");
39  
40          ConflictState result = states[0];
41          for (int i = 1; i < states.length; i++) {
42              if (states[i].ordinal() > result.ordinal()) {
43                  result = states[i];
44              }
45          }
46  
47          return result;
48      }
49  
50      @Override
51      public String toString() {
52          return value;
53      }
54  }