Services.Variable

This example demonstrates how to use the Variable.of(Environment) method to efficiently lookup values.

  static void of () {

    final Variable< String > string =
      Services
        .variable (
          Services
            .name (
              "opensignals.services.context.id"
            ),
          (String) null
        );

    final Variable< Integer > chromosomes =
      Services
        .variable (
          Services
            .name (
              "chromosomes"
            ),
          42
        );

    final Environment environment =
      Services
        .context ()
        .getEnvironment ();

    assert
      null !=
        string.of (
          environment
        );

    assert
      42 ==
        chromosomes.of (
          environment
        );

  }