001/*
002 * JPPF.
003 * Copyright (C) 2005-2018 JPPF Team.
004 * http://www.jppf.org
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019package org.jppf.node.policy;
020
021
022/**
023 * An execution policy rule that encapsulates a test of type <i>{@code a <= property_value_or_expression < b}</i>.
024 * The test applies to numeric values only.
025 * @author Laurent Cohen
026 */
027public class BetweenIE extends TrinaryNumericRule {
028  /**
029   * Explicit serialVersionUID.
030   */
031  private static final long serialVersionUID = 1L;
032
033  /**
034   * Define a comparison of type value between a and b with a included and b excluded.
035   * @param propertyNameOrExpression either a literal string which represents a property name, or an expression resolving to a numeric value.
036   * @param a the lower bound.
037   * @param b the upper bound.
038   */
039  public BetweenIE(final String propertyNameOrExpression, final double a, final double b) {
040    super(propertyNameOrExpression, a, b, 2);
041  }
042
043  /**
044   * Define a comparison of type value between a and b with a included and b excluded.
045   * @param propertyNameOrExpression either a literal string which represents a property name, or an expression resolving to a numeric value.
046   * @param a the lower bound expression.
047   * @param b the upper bound.
048   */
049  public BetweenIE(final String propertyNameOrExpression, final String a, final double b) {
050    super(propertyNameOrExpression, a, b, 2);
051  }
052
053  /**
054   * Define a comparison of type value between a and b with a included and b excluded.
055   * @param propertyNameOrExpression either a literal string which represents a property name, or an expression resolving to a numeric value.
056   * @param a the lower bound.
057   * @param b the upper bound expression.
058   */
059  public BetweenIE(final String propertyNameOrExpression, final double a, final String b) {
060    super(propertyNameOrExpression, a, b, 2);
061  }
062
063  /**
064   * Define a comparison of type value between a and b with a included and b excluded.
065   * @param propertyNameOrExpression either a literal string which represents a property name, or an expression resolving to a numeric value.
066   * @param a the lower bound expression.
067   * @param b the upper bound expression.
068   */
069  public BetweenIE(final String propertyNameOrExpression, final String a, final String b) {
070    super(propertyNameOrExpression, a, b, 2);
071  }
072
073  @Override
074  boolean accepts(final double value, final double a, final double  b) {
075    return (value >= a) && (value < b);
076  }
077}