Formula 1.0.0

hirondelle.formula.function
Class Check

Object
  extended by hirondelle.formula.function.Check

public final class Check
extends Object

Utility class for validating the parameters passed to a Function. If a problem is found, all methods in this class will throw a RuntimeException.

Some methods in this class take a String name argument. This is simply used to provide a more informative message, in case of an error.

The built-in functions use this class to validate their arguments. You are encouraged to do the same, but you are not obliged to use this class. You may validate the arguments passed to your own custom functions in any way that's best for you.


Method Summary
static void date(Decimal aYear, Decimal aMonth, Decimal aDay)
          Verify that the given year-month-day can form a date.
static void integer(Decimal aArg, String aName)
          Verify that the given value has no fractional value (has no decimals).
static void negative(Decimal aArg, String aName)
          Verify that the given value is less than 0.
static void nonNegative(Decimal aArg, String aName)
          Verify that the given value is greater than or equal to 0.
static void nonPositive(Decimal aArg, String aName)
          Verify that the given value is less than or equal to 0.
static void numArgs(int aExpected, Decimal... aAllArgs)
          Verify that the number of arguments passed to the function matches an expected value.
static void oneArg(Decimal... aAllArgs)
          Verify that the function has been passed exactly 1 argument.
static void positive(Decimal aArg, String aName)
          Verify that the given value is greater than 0.
static void positiveInteger(Decimal aArg, String aName)
          Verify that the given value is both greater than 0, and has no fractional value (has no decimals).
static void range(Decimal aArg, String aName, Decimal aLow, Decimal aHigh)
          Verify that the given value is in a given range (inclusive).
static void twoArgs(Decimal... aAllArgs)
          Verify that the function has been passed exactly 2 arguments.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

numArgs

public static void numArgs(int aExpected,
                           Decimal... aAllArgs)
Verify that the number of arguments passed to the function matches an expected value.


oneArg

public static void oneArg(Decimal... aAllArgs)
Verify that the function has been passed exactly 1 argument.


twoArgs

public static void twoArgs(Decimal... aAllArgs)
Verify that the function has been passed exactly 2 arguments.


integer

public static void integer(Decimal aArg,
                           String aName)
Verify that the given value has no fractional value (has no decimals). For this method, both 2 and 2.00 (for example) are taken to be integers.


positive

public static void positive(Decimal aArg,
                            String aName)
Verify that the given value is greater than 0.


negative

public static void negative(Decimal aArg,
                            String aName)
Verify that the given value is less than 0.


range

public static void range(Decimal aArg,
                         String aName,
                         Decimal aLow,
                         Decimal aHigh)
Verify that the given value is in a given range (inclusive).


nonNegative

public static void nonNegative(Decimal aArg,
                               String aName)
Verify that the given value is greater than or equal to 0.


nonPositive

public static void nonPositive(Decimal aArg,
                               String aName)
Verify that the given value is less than or equal to 0.


positiveInteger

public static void positiveInteger(Decimal aArg,
                                   String aName)
Verify that the given value is both greater than 0, and has no fractional value (has no decimals).


date

public static void date(Decimal aYear,
                        Decimal aMonth,
                        Decimal aDay)
Verify that the given year-month-day can form a date. No checking on the number of days in the month is performed - only basic range checking.

Parameters:
aYear - a positive integer
aMonth - integer in the range 1..12 (inclusive)
aDay - in the range 1..31 (inclusive), with possible fractional day.

Formula 1.0.0

Copyright Hirondelle Systems. Published January 31, 2013