Class Arguments

java.lang.Object
org.jdbi.v3.core.argument.Arguments
All Implemented Interfaces:
JdbiConfig<Arguments>

public class Arguments extends Object implements JdbiConfig<Arguments>
A registry for ArgumentFactory instances. When a statement with bound parameters is executed, Jdbi consults the Arguments registry to obtain an Argument instance for each bound parameter (see #findFor(...)). The factories are consulted in reverse order of registration (i.e. last-registered wins).
  • Constructor Details

  • Method Details

    • setRegistry

      public void setRegistry(ConfigRegistry registry)
      Description copied from interface: JdbiConfig
      The registry will inject itself into the configuration object. This can be useful if you need to look up dependencies. You will get a new registry after being copied.
      Specified by:
      setRegistry in interface JdbiConfig<Arguments>
      Parameters:
      registry - the registry that owns this configuration object
    • register

      public Arguments register(ArgumentFactory factory)
      Registers the given argument factory. If more than one of the registered factories supports a given parameter type, the last-registered factory wins.
      Parameters:
      factory - the factory to add
      Returns:
      this
    • register

      public Arguments register(QualifiedArgumentFactory factory)
      Registers the given qualified argument factory. If more than one of the registered factories supports a given parameter type, the last-registered factory wins.
      Parameters:
      factory - the qualified factory to add
      Returns:
      this
    • findFor

      public Optional<Argument> findFor(Type type, Object value)
      Obtain an argument for given value in the given context
      Parameters:
      type - the type of the argument.
      value - the argument value.
      Returns:
      an Argument for the given value.
    • findFor

      public Optional<Argument> findFor(QualifiedType<?> type, Object value)
      Obtain an argument for given value in the given context.
      Parameters:
      type - the qualified type of the argument.
      value - the argument value.
      Returns:
      an Argument for the given value.
    • prepareFor

      public Optional<Function<Object,Argument>> prepareFor(Type type)
      Obtain a prepared argument function for given type in the given context.
      Parameters:
      type - the type of the argument.
      Returns:
      an Argument factory function for the given value.
    • prepareFor

      @Beta public Optional<Function<Object,Argument>> prepareFor(QualifiedType<?> type)
      Obtain a prepared argument function for given type in the given context.
      Parameters:
      type - the qualified type of the argument.
      Returns:
      an Argument factory function for the given value.
    • getFactories

      public List<QualifiedArgumentFactory> getFactories()
    • setUntypedNullArgument

      public void setUntypedNullArgument(Argument untypedNullArgument)
      Configure the Argument to use when binding a null we don't have a type for.
      Parameters:
      untypedNullArgument - the argument to bind
    • getUntypedNullArgument

      public Argument getUntypedNullArgument()
      Returns the untyped null argument.
      Returns:
      the untyped null argument.
    • isBindingNullToPrimitivesPermitted

      public boolean isBindingNullToPrimitivesPermitted()
      Returns true if binding null to a variable declared as a primitive type is allowed.
      Returns:
      true if binding null to a variable declared as a primitive type is allowed.
    • setBindingNullToPrimitivesPermitted

      public void setBindingNullToPrimitivesPermitted(boolean bindingNullToPrimitivesPermitted)
      Whether binding null to a variable declared as a primitive type should be allowed.
      Parameters:
      bindingNullToPrimitivesPermitted - if true, null can be bound to a variable declared as a primitive type.
    • isPreparedArgumentsEnabled

      public boolean isPreparedArgumentsEnabled()
      Returns true if prepared arguments binding is enabled. Settings this improves performance.
      Returns:
      true if prepared arguments binding is enabled.
    • setPreparedArgumentsEnabled

      public void setPreparedArgumentsEnabled(boolean preparedArgumentsEnabled)
      Configure whether ArgumentFactory.Preparable factories will be processed before regular ArgumentFactory instances are. This improves speed at a small cost to backwards compatibility. Please disable it if you require the old semantics.
      Parameters:
      preparedArgumentsEnabled - whether to enable preparable argument factories
    • createCopy

      public Arguments createCopy()
      Description copied from interface: JdbiConfig
      Returns a copy of this configuration object. Changes to the copy should not modify the original, and vice-versa.
      Specified by:
      createCopy in interface JdbiConfig<Arguments>
      Returns:
      a copy of this configuration object.