Class MethodCheck

java.lang.Object
net.okapia.osid.torrefacto.util.MethodCheck

public class MethodCheck extends Object
Utility to help reduce method clutter in checking state and arguments.
  • Constructor Details

    • MethodCheck

      public MethodCheck()
      Constructs a new MethodCheck.
  • Method Details

    • nullarg

      public static final void nullarg(Object o, String name)
      Throws an error if the given object is null.
      Parameters:
      o - an object
      name - the name of the parameter to include in the exception
      Throws:
      NullArgumentException - o is null
    • cardinalarg

      public static final void cardinalarg(long number, String name)
      Checks that the supplied number is a cardinal value.
      Parameters:
      number - the value to check
      name - the name of the parameter to include in the exception
      Throws:
      InvalidArgumentException - if number is less than zero
      NullArgumentException - name is null
    • cardinalarg

      public static final void cardinalarg(BigDecimal number, String name)
      Checks that the supplied number is a cardinal value.
      Parameters:
      number - the value to check
      name - the name of the parameter to include in the exception
      Throws:
      InvalidArgumentException - if number is less than zero
      NullArgumentException - number or name is null
    • cardinalrangearg

      public static final void cardinalrangearg(long low, long high, String lowName, String highName)
      Checks the supplied cardinal range.
      Parameters:
      low - the low end of range
      high - the high end of range
      lowName - the name of the parameter to include in the exception
      highName - the name of the parameter to include in the exception
      Throws:
      InvalidArgumentException - if low or high is less than zero, or low is greater than high
      NullArgumentException - lowName or highName is null
    • decimalrangearg

      public static final void decimalrangearg(BigDecimal low, BigDecimal high, String lowName, String highName)
      Checks the supplied decimal range.
      Parameters:
      low - the low end of range
      high - the high end of range
      lowName - the name of the parameter to include in the exception
      highName - the name of the parameter to include in the exception
      Throws:
      InvalidArgumentException - if low or high is less than zero, or low is greater than high
      NullArgumentException - low, lowName, high, or highName is null
    • integerrangearg

      public static final void integerrangearg(long low, long high, String lowName, String highName)
      Checks the supplied integer range.
      Parameters:
      low - the low end of range
      high - the high end of range
      lowName - the name of the parameter to include in the exception
      highName - the name of the parameter to include in the exception
      Throws:
      InvalidArgumentException - if low is greater than high
      NullArgumentException - lowName or highName is null
    • percentarg

      public static final void percentarg(long number, String name)
      Checks that the supplied number is between 0-100.
      Parameters:
      number - the value to check
      name - the name of the parameter to include in the exception
      Throws:
      InvalidArgumentException - if number is out of range
      NullArgumentException - name is null
    • percentarg

      public static final void percentarg(BigDecimal number, String name)
      Checks that the supplied number is between 0-100.
      Parameters:
      number - the value to check
      name - the name of the parameter to include in the exception
      Throws:
      InvalidArgumentException - if number is null or less than zero
      NullArgumentException - number or name is null
    • unsetvar

      public static final void unsetvar(Object var, String name)
      Checks that a value is not null.
      Parameters:
      var - the value to check
      name - the name of the parameter to include in the exception
      Throws:
      BadLogicException - if var has not been set
      NullArgumentException - var or name is null