Enum AgeRange

  • All Implemented Interfaces:
    Serializable, Comparable<AgeRange>

    public enum AgeRange
    extends Enum<AgeRange>
    Enum representing a user's age range. Valid ranges are 17 or younger, 18 to 20, and 21 or older.
    Author:
    Michal Szwed
    • Enum Constant Detail

      • UNKNOWN

        public static final AgeRange UNKNOWN
      • AGE_17_MINUS

        public static final AgeRange AGE_17_MINUS
      • AGE_18_20

        public static final AgeRange AGE_18_20
      • AGE_21_PLUS

        public static final AgeRange AGE_21_PLUS
    • Method Detail

      • values

        public static AgeRange[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (AgeRange c : AgeRange.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static AgeRange valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • fromMinMax

        public static AgeRange fromMinMax​(Integer min,
                                          Integer max)
        Constructs an AgeRange from the min/max age values.
        Parameters:
        min - The minimum age
        max - The maximum age
        Returns:
        an AgeRange
      • getMin

        public Integer getMin()
        Returns:
        The minimum integer value for the range (possibly null).
      • getMax

        public Integer getMax()
        Returns:
        The maximum integer value for the range (possibly null).