/** * Configuration parameters for an interval are: * * <ul> * <li><code>[@left] (double)</code> Left extremum * <li><code>[@right] (double)</code> Right extremum * <li><code>[@closure] (String)</code> Interval closure. Supported values are "closed-closed", * "closed-open", "open-closed" and "open-open". Default value is "closed-closed". * </ul> */ public void configure(Configuration configuration) { // Get left extremum double left = configuration.getDouble("[@left]"); // Set left extremum setLeft(left); // Get right extremum double right = configuration.getDouble("[@right]"); // Set right extremum setRight(right); // Get closure string String closureString = configuration.getString("[@closure]", "closed-closed"); // Convert closureString Closure closure; if (closureString.equals("closed-closed")) { closure = Closure.ClosedClosed; } else if (closureString.equals("open-open")) { closure = Closure.OpenOpen; } else if (closureString.equals("closed-open")) { closure = Closure.ClosedOpen; } else if (closureString.equals("open-closed")) { closure = Closure.OpenClosed; } else { throw new ConfigurationRuntimeException("Illegal value for interval closure"); } // Set closure setClosure(closure); }
/** * Constructor that set interval properties. * * @param left Left extremum * @param right Right extremum * @param closure Interval closure */ public Interval(double left, double right, Closure closure) { super(); setClosure(closure); setLeft(left); setRight(right); }