Class SemVerConstraint<E extends ConstraintPattern<? extends Enum<?>>>

java.lang.Object
xyz.rk0cc.josev.SemVerRange
xyz.rk0cc.josev.constraint.SemVerConstraint<E>
Type Parameters:
E - Definition of constraint pattern that available in the subclass.
All Implemented Interfaces:
Serializable, SemVerDetermineInRange

public abstract class SemVerConstraint<E extends ConstraintPattern<? extends Enum<?>>> extends SemVerRange
Version constraint is a definition of SemVer range which bounding the version to ensure compatibility. This, class in extended from SemVerRange with more complicated detection to determine which SemVer can be accepted depending on different rules.
Since:
1.0.0
See Also:
  • Constructor Details

    • SemVerConstraint

      protected SemVerConstraint(@Nonnull E constraintPattern, @Nullable String rawConstraint, @Nullable SemVerRangeNode start, @Nullable SemVerRangeNode end)
      Create version constraint of SemVer.
      All implemented subclass should keep this constructor as private scope.
      Parameters:
      constraintPattern - An ConstraintPattern that applied from parser.
      rawConstraint - The version constraint that inserted by user.
      start - Start of the version range.
      end - End of the version range.
  • Method Details

    • constraintPattern

      @Nonnull public final E constraintPattern()
      Detect which pattern is used for this constraint.
      Returns:
      An Enum which implemented ConstraintPattern that indicating the constraint syntax pattern used in this constraint.
    • rawConstraint

      @Nullable public final String rawConstraint()
      A String of constraint that came from parser.
      Returns:
      User input value of the version constraint.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • parse

      public static <C extends SemVerConstraint<? extends ConstraintPattern<? extends Enum<?>>>> C parse(@Nonnull Class<C> constraintClass, @Nullable String versionConstraint)
      Parser a String of versionConstraint and specify which Class that extended from SemVerConstraint will be exported.
      Not all Class which inherited from SemVerConstraint can be parsed by this method unless it meets these requirements:
      • The class must be public.
        • If the annotated class is abstracted, it must be sealed and all permitted class should not abstract again.
        • For implementation class, it must be final.
      • Do not implement any public scope constructor
      • Has a static method that returns the same Class of constraintClass, it also applied with abstract parser.
      • Annotated SemVerConstraintParser with proper configurations:
      If one of these requirement is missed, it will throw UnsupportedOperationException.
      Type Parameters:
      C - Defined which subclass of SemVerConstraint will be returned.
      Parameters:
      constraintClass - A well implemented Class which inherited from SemVerConstraint.
      versionConstraint - A String of version constraint.
      Returns:
      An object of SemVerConstraint with corresponded data of SemVerConstraint.
      Throws:
      UnsupportedOperationException - If the implementation does not meet all requirement on the list.
      See Also: