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_COMPARATOR
private static java.util.Comparator<java.lang.Object>
DOUBLE_COMPARATOR
private static java.util.Comparator<java.lang.Object>
FLOAT_COMPARATOR
private static java.util.Comparator<java.lang.Object>
INTEGER_COMPARATOR
private static java.util.Comparator<java.lang.Object>
LONG_COMPARATOR
private 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 ArgumentsRestriction
createArgumentsRestriction(java.lang.annotation.Annotation annotation)
Tries to create an arguments restriction from the given annotationprotected RangeRestriction
createByteRange(java.lang.annotation.Annotation annotation)
protected AbstractCommonRestriction
createCommon(java.lang.annotation.Annotation annotation)
Handles converting all the basic range annotations into appropriate range restrictionsprotected RangeRestriction
createDoubleRange(java.lang.annotation.Annotation annotation)
protected RangeRestriction
createFloatRange(java.lang.annotation.Annotation annotation)
protected RangeRestriction
createIntegerRange(java.lang.annotation.Annotation annotation)
protected AbstractCommonRestriction
createLengthRange(java.lang.annotation.Annotation annotation)
protected RangeRestriction
createLexicalRange(java.lang.annotation.Annotation annotation)
protected RangeRestriction
createLongRange(java.lang.annotation.Annotation annotation)
OptionRestriction
createOptionRestriction(java.lang.annotation.Annotation annotation)
Try and create an option restriction from the given annotationprotected RangeRestriction
createShortRange(java.lang.annotation.Annotation annotation)
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 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:OptionRestrictionFactory
Try and create an option restriction from the given annotation- Specified by:
createOptionRestriction
in interfaceOptionRestrictionFactory
- Parameters:
annotation
- Annotation- Returns:
- Option restriction or
null
if this factory cannot create a restriction from the given annotation
-
createArgumentsRestriction
public final ArgumentsRestriction createArgumentsRestriction(java.lang.annotation.Annotation annotation)
Description copied from interface:ArgumentsRestrictionFactory
Tries to create an arguments restriction from the given annotation- Specified by:
createArgumentsRestriction
in interfaceArgumentsRestrictionFactory
- Parameters:
annotation
- Annotation- Returns:
- Arguments restriction or
null
if 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:ArgumentsRestrictionFactory
Gets a list of annotations that this factory can convert into arguments restrictions- Specified by:
supportedArgumentsAnnotations
in interfaceArgumentsRestrictionFactory
- Returns:
- List of supported annotations
-
supportedOptionAnnotations
public java.util.List<java.lang.Class<? extends java.lang.annotation.Annotation>> supportedOptionAnnotations()
Description copied from interface:OptionRestrictionFactory
Gets a list of annotations that this factory can convert into option restrictions- Specified by:
supportedOptionAnnotations
in interfaceOptionRestrictionFactory
- Returns:
- List of supported annotations
-
-