Interface CalcResult

All Known Implementing Classes:
AbstractCalcResult, AverageVisitor.AverageResult, BoundsVisitor.BoundsResult, CountVisitor.CountResult, GroupByVisitor.GroupByResult, MaxVisitor.MaxResult, MedianVisitor.MedianResult, MinVisitor.MinResult, StandardDeviationVisitor.Result, SumVisitor.SumResult, UniqueVisitor.UniqueResult

public interface CalcResult
Encapsulates the results from a FeatureCalc, and includes methods for obtaining and merging results.
Since:
2.2.M2
Author:
Cory Horner, Refractions
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final CalcResult
    The result obtained when a FeatureCalc found no features to visit.
  • Method Summary

    Modifier and Type
    Method
    Description
    Actual answer
    boolean
    isCompatible(CalcResult targetResults)
    Returns true if the target results is a compatible type with the current results, with compatible meaning that the two results may be merged.
    merge(CalcResult resultsToAdd)
    Returns the merged results of two CalcResult.
    Access getValue as an array
    double
    Access getValue as a double
    Access getValue as an envelope
    float
    Access getValue as a float
    Access getValue as a geometry
    int
    Access getValue as an int
    Access getValue as a list
    long
    Access getValue as a long
    Access getValue as a map
    Access getValue as a point
    Access getValue as a set
    Access getValue as a string
  • Field Details

    • NULL_RESULT

      static final CalcResult NULL_RESULT
      The result obtained when a FeatureCalc found no features to visit. It lets itself merge with any other result by just returning the other result as the output of the merge
  • Method Details

    • isCompatible

      boolean isCompatible(CalcResult targetResults)
      Returns true if the target results is a compatible type with the current results, with compatible meaning that the two results may be merged.
      Parameters:
      targetResults - the second CalcResult Object
      Returns:
      true if the targetResults can be merged with the current results
    • merge

      CalcResult merge(CalcResult resultsToAdd)
      Returns the merged results of two CalcResult. The way in which the results are merged is dependent on the type of the results added. A new instance is created containing the merged results.

      For example: merging two min functions would return the smaller of the two values; merging a count and a sum would return an average.

      Returns:
      the merged results
    • getValue

      Object getValue()
      Actual answer
      Returns:
      the calculation result as a generic object
    • toInt

      int toInt()
      Access getValue as an int
      Returns:
      the calculation result as a int (or 0 if not applicable)
    • toDouble

      double toDouble()
      Access getValue as a double
      Returns:
      the calculation result as a double (or 0 if not applicable)
    • toString

      String toString()
      Access getValue as a string
      Overrides:
      toString in class Object
      Returns:
      the calculation result as a string (or "" if not applicable)
    • toLong

      long toLong()
      Access getValue as a long
      Returns:
      the calculation result as a long (or 0 if not applicable)
    • toFloat

      float toFloat()
      Access getValue as a float
      Returns:
      the calculation result as a float (or 0 if not applicable)
    • toGeometry

      Geometry toGeometry()
      Access getValue as a geometry
      Returns:
      the calculation result as a geometry (or null if not applicable)
    • toEnvelope

      Envelope toEnvelope()
      Access getValue as an envelope
      Returns:
      the calculation result as an envelope (or null if not applicable)
    • toPoint

      Point toPoint()
      Access getValue as a point
      Returns:
      the calculation result as a point (or null if not applicable)
    • toSet

      Set toSet()
      Access getValue as a set
      Returns:
      the calculation result as a set (or null if not applicable)
    • toList

      List toList()
      Access getValue as a list
      Returns:
      the calculation result as a list (or null if not applicable)
    • toArray

      Object[] toArray()
      Access getValue as an array
      Returns:
      the calculation result as an array (or null if not applicable)
    • toMap

      Map toMap()
      Access getValue as a map
      Returns:
      the calculation result as a map (or null if not applicable)