Class BaseGeometryFunction

java.lang.Object
org.locationtech.jtstest.geomfunction.BaseGeometryFunction
All Implemented Interfaces:
Comparable, GeometryFunction
Direct Known Subclasses:
StaticMethodGeometryFunction

public abstract class BaseGeometryFunction extends Object implements GeometryFunction, Comparable
A base for implementations of GeometryFunction which provides most of the required structure. Extenders must supply the behaviour for the actual function invocation.
  • Field Details

    • category

      protected String category
    • name

      protected String name
    • description

      protected String description
    • parameterNames

      protected String[] parameterNames
    • parameterTypes

      protected Class[] parameterTypes
    • returnType

      protected Class returnType
  • Constructor Details

    • BaseGeometryFunction

      public BaseGeometryFunction(String category, String name, String[] parameterNames, Class[] parameterTypes, Class returnType)
    • BaseGeometryFunction

      public BaseGeometryFunction(String category, String name, String description, String[] parameterNames, Class[] parameterTypes, Class returnType)
  • Method Details

    • isBinaryGeomFunction

      public static boolean isBinaryGeomFunction(GeometryFunction func)
    • firstScalarParamIndex

      public static int firstScalarParamIndex(GeometryFunction func)
    • getCategory

      public String getCategory()
      Description copied from interface: GeometryFunction
      Gets the category name of this function
      Specified by:
      getCategory in interface GeometryFunction
      Returns:
      the category name of the function
    • getName

      public String getName()
      Description copied from interface: GeometryFunction
      Gets the name of this function
      Specified by:
      getName in interface GeometryFunction
      Returns:
      the name of the function
    • getDescription

      public String getDescription()
      Description copied from interface: GeometryFunction
      Gets the description of this function
      Specified by:
      getDescription in interface GeometryFunction
      Returns:
      the name of the function
    • getParameterNames

      public String[] getParameterNames()
      Description copied from interface: GeometryFunction
      Gets the parameter names for this function
      Specified by:
      getParameterNames in interface GeometryFunction
      Returns:
      the names of the function parameters
    • getParameterTypes

      public Class[] getParameterTypes()
      Gets the types of the other function arguments, if any.
      Specified by:
      getParameterTypes in interface GeometryFunction
      Returns:
      the types
    • getReturnType

      public Class getReturnType()
      Description copied from interface: GeometryFunction
      Gets the return type of this function
      Specified by:
      getReturnType in interface GeometryFunction
      Returns:
      the type of the value returned by this function
    • isBinary

      public boolean isBinary()
      Specified by:
      isBinary in interface GeometryFunction
    • getSignature

      public String getSignature()
      Description copied from interface: GeometryFunction
      Gets a string representing the signature of this function.
      Specified by:
      getSignature in interface GeometryFunction
      Returns:
      the string for the function signature
    • getDoubleOrNull

      protected static Double getDoubleOrNull(Object[] args, int index)
    • getIntegerOrNull

      protected static Integer getIntegerOrNull(Object[] args, int index)
    • invoke

      public abstract Object invoke(Geometry geom, Object[] args)
      Description copied from interface: GeometryFunction
      Invokes this function. Note that any exceptions returned must be RuntimeExceptions.
      Specified by:
      invoke in interface GeometryFunction
      Parameters:
      geom - the target geometry
      args - the other arguments to the function
      Returns:
      the value computed by the function
    • equals

      public boolean equals(Object obj)
      Two functions are the same if they have the same signature (name, parameter types and return type).
      Specified by:
      equals in interface GeometryFunction
      Overrides:
      equals in class Object
      Parameters:
      obj -
      Returns:
      true if this object is the same as the obj argument
    • compareTo

      public int compareTo(Object o)
      Specified by:
      compareTo in interface Comparable
    • compareTo

      private static int compareTo(Class c1, Class c2)