Class F0

java.lang.Object
org.djutils.eval.F0
All Implemented Interfaces:
org.djutils.base.Identifiable, Function

class F0 extends Object implements Function
F0.java. Minimal implementation of zero-argument Function with description.

Copyright (c) 2023-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html.

Author:
Peter Knoppers
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    (package private) static interface 
    Interface for zero argument functions.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) final F0.ZeroArgumentFunction
    The zero argument function.
    (package private) final String
    Id of the function.
    (package private) final org.djutils.metadata.MetaData
    Type of the parameters of this function (also contains name and description).
    (package private) final Class<?>
    Type of the result of this function.
  • Constructor Summary

    Constructors
    Constructor
    Description
    F0(String id, Class<?> resultClass, org.djutils.metadata.MetaData metaData, F0.ZeroArgumentFunction f0)
    Construct a new zero argument function.
    F0(String id, Object constantResult, org.djutils.metadata.MetaData metaData)
    Construct a new zero-argument function with constant result.
  • Method Summary

    Modifier and Type
    Method
    Description
    function(Object[] arguments)
    The function itself.
     
    org.djutils.metadata.MetaData
    Specifies the types of the arguments expected by the function.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.djutils.eval.Function

    getDescription, getName
  • Field Details

    • id

      final String id
      Id of the function.
    • metaData

      final org.djutils.metadata.MetaData metaData
      Type of the parameters of this function (also contains name and description).
    • resultClass

      final Class<?> resultClass
      Type of the result of this function.
    • f0

      The zero argument function.
  • Constructor Details

    • F0

      F0(String id, Class<?> resultClass, org.djutils.metadata.MetaData metaData, F0.ZeroArgumentFunction f0)
      Construct a new zero argument function.
      Parameters:
      id - String; name of the function as it must be written in expressions
      resultClass - Class<?>; the type of the result of the function
      metaData - MetaData; meta data of the function
      f0 - ZeroArgumentFunction; zero argument function
    • F0

      F0(String id, Object constantResult, org.djutils.metadata.MetaData metaData)
      Construct a new zero-argument function with constant result.
      Parameters:
      id - String; name of the function as it must be written in expressions
      constantResult - Object; the result of the zero argument function
      metaData - MetaData; meta data of the function
  • Method Details

    • getId

      public String getId()
      Specified by:
      getId in interface org.djutils.base.Identifiable
    • getMetaData

      public org.djutils.metadata.MetaData getMetaData()
      Description copied from interface: Function
      Specifies the types of the arguments expected by the function.
      Specified by:
      getMetaData in interface Function
      Returns:
      MetaData; specification of the arguments expected by the function
    • function

      public Object function(Object[] arguments) throws RuntimeException
      Description copied from interface: Function
      The function itself.
      Specified by:
      function in interface Function
      Parameters:
      arguments - Object[]; the arguments of the function
      Returns:
      Object; the result of the function (must currently be either some type of DoubleScalar or Boolean).
      Throws:
      RuntimeException - thrown when the function is unable to produce a result