Package xyz.rk0cc.josev.constraint
Class SemVerConstraint<E extends ConstraintPattern<? extends Enum<?>>>
java.lang.Object
xyz.rk0cc.josev.SemVerRange
xyz.rk0cc.josev.constraint.SemVerConstraint<E>
- Type Parameters:
E
- Definition ofconstraint 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 Summary
ModifierConstructorDescriptionprotected
SemVerConstraint
(E constraintPattern, String rawConstraint, SemVerRangeNode start, SemVerRangeNode end) Create version constraint ofSemVer
. -
Method Summary
Modifier and TypeMethodDescriptionfinal E
Detect which pattern is used for this constraint.boolean
int
hashCode()
static <C extends SemVerConstraint<? extends ConstraintPattern<? extends Enum<?>>>>
CParser aString
ofversionConstraint
and specify whichClass
that extended fromSemVerConstraint
will be exported.final String
toString()
Methods inherited from class xyz.rk0cc.josev.SemVerRange
end, isInRange, isInRange, start
-
Constructor Details
-
SemVerConstraint
protected SemVerConstraint(@Nonnull E constraintPattern, @Nullable String rawConstraint, @Nullable SemVerRangeNode start, @Nullable SemVerRangeNode end) Create version constraint ofSemVer
.
All implemented subclass should keep this constructor as private scope.- Parameters:
constraintPattern
- AnConstraintPattern
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
Detect which pattern is used for this constraint.- Returns:
- An
Enum
which implementedConstraintPattern
that indicating the constraint syntax pattern used in this constraint.
-
rawConstraint
- Returns:
- User input value of the version constraint.
-
equals
-
hashCode
public int hashCode() -
toString
-
parse
public static <C extends SemVerConstraint<? extends ConstraintPattern<? extends Enum<?>>>> C parse(@Nonnull Class<C> constraintClass, @Nullable String versionConstraint) Parser aString
ofversionConstraint
and specify whichClass
that extended fromSemVerConstraint
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
ofconstraintClass
, it also applied with abstract parser. -
Annotated
SemVerConstraintParser
with proper configurations:
UnsupportedOperationException
.- Type Parameters:
C
- Defined which subclass ofSemVerConstraint
will be returned.- Parameters:
constraintClass
- A well implementedClass
which inherited fromSemVerConstraint
.versionConstraint
- AString
of version constraint.- Returns:
- An object of
SemVerConstraint
with corresponded data ofSemVerConstraint
. - Throws:
UnsupportedOperationException
- If the implementation does not meet all requirement on the list.- See Also:
-
The class must be public.
-