Class AbstractFunctionFlux<CALL extends AbstractFunctionCallFlux>

java.lang.Object
com.influxdb.query.dsl.Flux
com.influxdb.query.dsl.VariableAssignment
com.influxdb.query.dsl.functions.AbstractFunctionFlux<CALL>
Type Parameters:
CALL - the type of the AbstractFunctionCallFlux
All Implemented Interfaces:
Expression, HasImports, IsVariableAssignment

public class AbstractFunctionFlux<CALL extends AbstractFunctionCallFlux> extends VariableAssignment
The base class for function definitions. The function definition describes the implementation of a function. A concrete call to this function can be created via the invoke() method.

Example Definition

 public static class MyCustomFunction extends AbstractFunctionFlux<MyCustomFunction.MyCustomFunctionCall> {

     public MyCustomFunction() {
         super("from2",
                 new FromFlux()
                         .withPropertyValue("bucket", "n"),
                 MyCustomFunctionCall::new,
                 new Parameter("n"));
         addImport("foo");
     }

     public static class MyCustomFunctionCall extends AbstractFunctionCallFlux {

         public MyCustomFunctionCall(@Nonnull String name) {
             super(name);
         }

         public MyCustomFunctionCall withN(final String n) {
             this.withPropertyValueEscaped("n", n);
             return this;
         }
     }
 }
 

Example Usage

 MyCustomFunction fun = new MyCustomFunction();

 Expressions flux = new Expressions(
    fun,
    fun.invoke().withN("bar").count(),
    fun.invoke().withN("bar2"),
 );
 
See Also:
  • Constructor Details

    • AbstractFunctionFlux

      protected AbstractFunctionFlux(@Nonnull String name, @Nonnull Expression functionDefinition, @Nonnull Function<String,CALL> invocationFactory, @Nonnull AbstractFunctionFlux.Parameter... parameter)
      Parameters:
      name - the name of the function (the variable th function is assigned to)
      functionDefinition - the function body
      invocationFactory - a factory to create an invocation, should be the constructor reference to the concrete CALL implementation
      parameter - the parameters of this function
  • Method Details

    • toString

      public String toString(@Nonnull Map<String,Object> parameters, boolean prependImports)
      Specified by:
      toString in interface Expression
      Overrides:
      toString in class VariableAssignment
      Parameters:
      parameters - parameters to resolve
      prependImports - true, if the imports should be prepended
      Returns:
      the string representation of the expression
    • invoke

      @Nonnull public CALL invoke()
      Returns:
      A flux invoking this method. The invocation arguments can be adjusted via this flux.
    • invokePiped

      @Nonnull public CALL invokePiped(@Nonnull Flux flux)
    • getImports

      public Set<String> getImports()
      Specified by:
      getImports in interface HasImports
      Overrides:
      getImports in class VariableAssignment
      Returns:
      all used imports of this flux