> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dairy.foundation/llms.txt
> Use this file to discover all available pages before exploring further.

# EnhancedNumericSuppliers

We'll look at `EnhancedDoubleSupplier`, `EnhancedUnitSupplier` also exists and
is essentially the same, but works with `Unit`s from Util.

Constructing:

<CodeGroup>
  ```java Java theme={null}
  EnhancedDoubleSupplier enhancedDoubleSupplier = new EnhancedDoubleSupplier(() -> 0.0);
  ```

  ```kt Kotlin theme={null}
  val enhancedDoubleSupplier = EnhancedDoubleSupplier { 0.0 }
  ```
</CodeGroup>

State:

<CodeGroup>
  ```java Java theme={null}
  enhancedDoubleSupplier.state();
  enhancedDoubleSupplier.velocity();
  enhancedDoubleSupplier.rawVelocity();
  enhancedDoubleSupplier.acceleration();
  enhancedDoubleSupplier.rawAcceleration();
  // velocity and acceleration are captured over a window
  // raw variations are not
  // you can modify the measurement window
  enhancedDoubleSupplier.getMeasurementWindow();
  // defaults to this many seconds
  enhancedDoubleSupplier.setMeasurementWindow(0.02);

  // we can set the state, to give i
  enhancedDoubleSupplier.state(100);
  ```

  ```kt Kotlin theme={null}
  enhancedDoubleSupplier.state
  enhancedDoubleSupplier.velocity
  enhancedDoubleSupplier.rawVelocity
  enhancedDoubleSupplier.acceleration
  enhancedDoubleSupplier.rawAcceleration
  // velocity and acceleration are captured over a window
  // raw variations are not
  // you can modify the measurement window
  enhancedDoubleSupplier.measurementWindow
  // defaults to this many seconds
  enhancedDoubleSupplier.measurementWindow = 0.02

  // we can set the state, to give it an offset
  enhancedDoubleSupplier.state = 100.0
  ```
</CodeGroup>

Manual update management:

<CodeGroup>
  ```java Java theme={null}
  // you can enable / disable the feature based auto calculations
  enhancedDoubleSupplier.getAutoCalculates();
  enhancedDoubleSupplier.setAutoCalculates(false);

  // you can invalidate the current update to get a new update next time you get state
  enhancedDoubleSupplier.invalidate();
  ```

  ```kt Kotlin theme={null}
  // you can enable / disable the feature based auto calculations
  enhancedDoubleSupplier.autoCalculates
  enhancedDoubleSupplier.autoCalculates = false
  // you can invalidate the current update to get a new update next time you get state
  enhancedDoubleSupplier.invalidate()
  ```
</CodeGroup>

Conditional binding:

<CodeGroup>
  ```java Java theme={null}
  // we can build EnhancedBooleanSuppliers off the state of this supplier
  EnhancedBooleanSupplier binding = enhancedDoubleSupplier.conditionalBindState()
  		.greaterThan(10.0)
  		.lessThan(20.0)
  		.bind();

  // or any of the other components
  enhancedDoubleSupplier.conditionalBindVelocityRaw()
  		.greaterThan(10.0)
  		.lessThan(20.0)
  		.bind();
  ```

  ```kt Kotlin theme={null}
  // we can build EnhancedBooleanSuppliers off the state of this supplier
  val binding: EnhancedBooleanSupplier = enhancedDoubleSupplier.conditionalBindState()
  	.greaterThan(10.0)
  	.lessThan(20.0)
  	.bind()

  // or any of the other components
  enhancedDoubleSupplier.conditionalBindVelocityRaw()
  	.greaterThan(10.0)
  	.lessThan(20.0)
  	.bind()
  ```
</CodeGroup>

Conditional bindings also support `greaterThanEqualTo` and `lessThanEqualTo`.
They're capable of pretty complex conditions built around the state of the
controller, its worth taking a look at the documentation attached to the system,
and other examples which document the use of conditional binding. The system is
pretty intuitive and will work if you list your values from smallest to largest,
or if you form closed pairs and list those to it.
