ConflictState.java

  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. import static com.google.common.base.Preconditions.checkState;

  16. public enum ConflictState {
  17.     // Conflict states in order from low to high.
  18.     NO_CONFLICT("no-conflict", ""),
  19.     CONFLICT_CONTENT_EQUAL("content-equal", "(but equal)"),
  20.     CONFLICT_CONTENT_DIFFERENT("content-different", "and different");

  21.     private final String value;
  22.     private final String hint;

  23.     ConflictState(String value, String hint) {
  24.         this.value = value;
  25.         this.hint = hint;
  26.     }

  27.     public String getHint() {
  28.         return hint;
  29.     }

  30.     public static ConflictState max(final ConflictState... states) {
  31.         checkState(states.length > 0, "states is empty");

  32.         ConflictState result = states[0];
  33.         for (int i = 1; i < states.length; i++) {
  34.             if (states[i].ordinal() > result.ordinal()) {
  35.                 result = states[i];
  36.             }
  37.         }

  38.         return result;
  39.     }

  40.     @Override
  41.     public String toString() {
  42.         return value;
  43.     }
  44. }