Module com.github.rvesse.airline
Class RangeRestrictionFactory
- java.lang.Object
-
- com.github.rvesse.airline.restrictions.factories.RangeRestrictionFactory
-
- All Implemented Interfaces:
ArgumentsRestrictionFactory,OptionRestrictionFactory
public class RangeRestrictionFactory extends java.lang.Object implements OptionRestrictionFactory, ArgumentsRestrictionFactory
Factory which generates range restrictions from a variety of different range annotations
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Comparator<java.lang.Object>BYTE_COMPARATORprivate static java.util.Comparator<java.lang.Object>DOUBLE_COMPARATORprivate static java.util.Comparator<java.lang.Object>FLOAT_COMPARATORprivate static java.util.Comparator<java.lang.Object>INTEGER_COMPARATORprivate static java.util.Comparator<java.lang.Object>LONG_COMPARATORprivate static java.util.Comparator<java.lang.Object>SHORT_COMPARATOR
-
Constructor Summary
Constructors Constructor Description RangeRestrictionFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ArgumentsRestrictioncreateArgumentsRestriction(java.lang.annotation.Annotation annotation)Tries to create an arguments restriction from the given annotationprotected RangeRestrictioncreateByteRange(java.lang.annotation.Annotation annotation)protected AbstractCommonRestrictioncreateCommon(java.lang.annotation.Annotation annotation)Handles converting all the basic range annotations into appropriate range restrictionsprotected RangeRestrictioncreateDoubleRange(java.lang.annotation.Annotation annotation)protected RangeRestrictioncreateFloatRange(java.lang.annotation.Annotation annotation)protected RangeRestrictioncreateIntegerRange(java.lang.annotation.Annotation annotation)protected AbstractCommonRestrictioncreateLengthRange(java.lang.annotation.Annotation annotation)protected RangeRestrictioncreateLexicalRange(java.lang.annotation.Annotation annotation)protected RangeRestrictioncreateLongRange(java.lang.annotation.Annotation annotation)OptionRestrictioncreateOptionRestriction(java.lang.annotation.Annotation annotation)Try and create an option restriction from the given annotationprotected RangeRestrictioncreateShortRange(java.lang.annotation.Annotation annotation)protected AbstractCommonRestrictioncreateUnknownRange(java.lang.annotation.Annotation annotation)Handles turning unknown annotations into range restrictions, derived factories can extend this to add support for additional range restrictionsprotected java.util.List<java.lang.Class<? extends java.lang.annotation.Annotation>>supportedAnnotations()java.util.List<java.lang.Class<? extends java.lang.annotation.Annotation>>supportedArgumentsAnnotations()Gets a list of annotations that this factory can convert into arguments restrictionsjava.util.List<java.lang.Class<? extends java.lang.annotation.Annotation>>supportedOptionAnnotations()Gets a list of annotations that this factory can convert into option restrictions
-
-
-
Field Detail
-
LONG_COMPARATOR
private static final java.util.Comparator<java.lang.Object> LONG_COMPARATOR
-
INTEGER_COMPARATOR
private static final java.util.Comparator<java.lang.Object> INTEGER_COMPARATOR
-
SHORT_COMPARATOR
private static final java.util.Comparator<java.lang.Object> SHORT_COMPARATOR
-
BYTE_COMPARATOR
private static final java.util.Comparator<java.lang.Object> BYTE_COMPARATOR
-
DOUBLE_COMPARATOR
private static final java.util.Comparator<java.lang.Object> DOUBLE_COMPARATOR
-
FLOAT_COMPARATOR
private static final java.util.Comparator<java.lang.Object> FLOAT_COMPARATOR
-
-
Method Detail
-
createOptionRestriction
public final OptionRestriction createOptionRestriction(java.lang.annotation.Annotation annotation)
Description copied from interface:OptionRestrictionFactoryTry and create an option restriction from the given annotation- Specified by:
createOptionRestrictionin interfaceOptionRestrictionFactory- Parameters:
annotation- Annotation- Returns:
- Option restriction or
nullif this factory cannot create a restriction from the given annotation
-
createArgumentsRestriction
public final ArgumentsRestriction createArgumentsRestriction(java.lang.annotation.Annotation annotation)
Description copied from interface:ArgumentsRestrictionFactoryTries to create an arguments restriction from the given annotation- Specified by:
createArgumentsRestrictionin interfaceArgumentsRestrictionFactory- Parameters:
annotation- Annotation- Returns:
- Arguments restriction or
nullif this factory cannot create a restriction from the given annotation
-
createCommon
protected final AbstractCommonRestriction createCommon(java.lang.annotation.Annotation annotation)
Handles converting all the basic range annotations into appropriate range restrictions- Parameters:
annotation- Annotation to create range from- Returns:
- Range restriction
-
createUnknownRange
protected AbstractCommonRestriction createUnknownRange(java.lang.annotation.Annotation annotation)
Handles turning unknown annotations into range restrictions, derived factories can extend this to add support for additional range restrictions- Parameters:
annotation- Annotation to create range from- Returns:
- Range restriction or null if not a supported annotation
-
createLengthRange
protected AbstractCommonRestriction createLengthRange(java.lang.annotation.Annotation annotation)
-
createLexicalRange
protected RangeRestriction createLexicalRange(java.lang.annotation.Annotation annotation)
-
createFloatRange
protected RangeRestriction createFloatRange(java.lang.annotation.Annotation annotation)
-
createDoubleRange
protected RangeRestriction createDoubleRange(java.lang.annotation.Annotation annotation)
-
createByteRange
protected RangeRestriction createByteRange(java.lang.annotation.Annotation annotation)
-
createShortRange
protected RangeRestriction createShortRange(java.lang.annotation.Annotation annotation)
-
createIntegerRange
protected RangeRestriction createIntegerRange(java.lang.annotation.Annotation annotation)
-
createLongRange
protected RangeRestriction createLongRange(java.lang.annotation.Annotation annotation)
-
supportedAnnotations
protected java.util.List<java.lang.Class<? extends java.lang.annotation.Annotation>> supportedAnnotations()
-
supportedArgumentsAnnotations
public java.util.List<java.lang.Class<? extends java.lang.annotation.Annotation>> supportedArgumentsAnnotations()
Description copied from interface:ArgumentsRestrictionFactoryGets a list of annotations that this factory can convert into arguments restrictions- Specified by:
supportedArgumentsAnnotationsin interfaceArgumentsRestrictionFactory- Returns:
- List of supported annotations
-
supportedOptionAnnotations
public java.util.List<java.lang.Class<? extends java.lang.annotation.Annotation>> supportedOptionAnnotations()
Description copied from interface:OptionRestrictionFactoryGets a list of annotations that this factory can convert into option restrictions- Specified by:
supportedOptionAnnotationsin interfaceOptionRestrictionFactory- Returns:
- List of supported annotations
-
-