Currently, specific measurements have their ranges checked for validity, but generic measurements do not.
For example, Time values cannot be negative. Invoking Time.apply(-5) will result in an exception. However, if the same time quantity is stored as a Generic.Measure instance, then it can be negative without an exception being thrown upon creation. This is wrong: an exception should be thrown when the invalid Generic.Measure value is created.
One possible solution would be to have the Family class perform the range checking, so that there is no need for NonNegative physical quantities in the hierarchy.
Currently, specific measurements have their ranges checked for validity, but generic measurements do not.
For example, Time values cannot be negative. Invoking
Time.apply(-5)
will result in an exception. However, if the same time quantity is stored as aGeneric.Measure
instance, then it can be negative without an exception being thrown upon creation. This is wrong: an exception should be thrown when the invalidGeneric.Measure
value is created.One possible solution would be to have the
Family
class perform the range checking, so that there is no need forNonNegative
physical quantities in the hierarchy.