All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.codemodder.plugins.maven.operator.AbstractVersionCommand Maven / Gradle / Ivy

There is a newer version: 0.98.6
Show newest version
package io.codemodder.plugins.maven.operator;

import java.util.*;
import org.apache.commons.lang3.builder.CompareToBuilder;

/** Base Class for Version Detection Commands */
class AbstractVersionCommand extends AbstractCommand {

  /** Internal Result */
  Set result = new TreeSet<>(VERSION_KIND_COMPARATOR);

  static final Comparator VERSION_KIND_COMPARATOR =
      new Comparator() {
        @Override
        public int compare(VersionDefinition o1, VersionDefinition o2) {
          if (o1 == null) return 1;
          if (o2 == null) return -1;

          return new CompareToBuilder().append(o1.getKind(), o2.getKind()).toComparison();
        }
      };

  static final Map TYPE_TO_KIND = new HashMap<>();
  static final Map PROPERTY_TO_KIND = new HashMap<>();

  static {
    TYPE_TO_KIND.put("source", Kind.SOURCE);
    TYPE_TO_KIND.put("target", Kind.TARGET);
    TYPE_TO_KIND.put("release", Kind.RELEASE);

    for (Map.Entry entry : TYPE_TO_KIND.entrySet()) {
      PROPERTY_TO_KIND.put("maven.compiler." + entry.getKey(), entry.getValue());
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy