All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.wavefront.predicates.PredicateEvalExpression Maven / Gradle / Ivy

The newest version!
package com.wavefront.predicates;

/**
 * An expression that returns a numeric value.
 *
 * @author [email protected].
 */
public interface PredicateEvalExpression extends BaseExpression {

  /**
   * Get a double value.
   *
   * @param entity entity to get the value from.
   * @return double value
   */
  double getValue(Object entity);

  /**
   * Helper method to convert a double value into a boolean.
   *
   * @param value value to evaluate
   * @return true if value is close to 0 (within 1e-6)
   */
  static boolean isTrue(double value) {
    return Math.abs(value) > 1e-6;
  }

  /**
   * Helper method to convert a boolean value into a double.
   *
   * @param value value to evaluate
   * @return 1.0 for true, 0.0 for false.
   */
  static double asDouble(boolean value) { return value ? 1 : 0; }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy