Class PercentType

java.lang.Object
dev.jcputney.elearning.parser.input.common.PercentType
All Implemented Interfaces:
Serializable

public class PercentType extends Object implements Serializable
Represents a percentage value constrained between 0 and 1, inclusive. This type enforces the range but does not enforce specific decimal precision.
See Also:
  • Constructor Details

    • PercentType

      public PercentType()
      Default constructor for the PercentType class.
    • PercentType

      public PercentType(BigDecimal value)
      Constructs a PercentType instance with the specified value.
      Parameters:
      value - the decimal value for the percentage must be between 0 and 1.
      Throws:
      IllegalArgumentException - if the value is out of range.
  • Method Details

    • parse

      public static PercentType parse(String value)
      Parses a string as a PercentType.
      Parameters:
      value - the string representation of the percentage must be a decimal between 0 and 1.
      Returns:
      a new PercentType instance.
      Throws:
      IllegalArgumentException - if the value is out of range or not a valid decimal format.
    • toString

      public String toString()
      Returns the string representation of the percentage value.
      Overrides:
      toString in class Object
      Returns:
      the string representation of the percentage value.