Services.Fn

An example demonstrating the use of the Fn functional interface and related methods.

package io.opensignals.services.samples;

import io.opensignals.services.Services;
import io.opensignals.services.Services.Fn;
import io.opensignals.services.Services.Service;

final class Fns {

  public static void main (
    final String[] args
  ) throws Throwable {

    final Service service =
      Services
        .context ()
        .service (
          Services.name (
            "service.one"
          )
        );

    assert
      1 ==
        Services
          .execute (
            service,
            () ->
              doWork ()
          );

    assert
      1 ==
        Services
          .execute (
            service,
            (Fn< Integer, ? >)
              Fns::doWork
          );

    assert
      1 ==
        Services
          .execute (
            service,
            Fn.of (
              Fns::doWork
            )
          );

  }

  private static int doWork () {

    return 1;

  }

  static int doWork (
    final int units
  ) {

    return
      units;

  }

}