Interface FluentProperty

All Superinterfaces:
Serializable, SerializableLambda
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface FluentProperty extends SerializableLambda
Deprecated.
this interface is only supported with java8 and will be removed in next dm release
Lambda allowing to define fluent service properties. Property names are deduces from the lambda parameter name.

Example of a component which provides fluent properties {"foo"="bar"; "foo2"=Integer(123)}:


 public class Activator extends DependencyManagerActivator {
   public void init(BundleContext ctx, DependencyManager dm) throws Exception {
       component(comp -> comp.impl(MyComponentImpl.class).provides(MyService.class, foo->"bar", foo2 -> 123));
   }
 } 
 
When a property name contains dots ("."), then since it's not possible to declare a lambda parameter with some dots, you can encode the dots using some underscores. A single underscore is then converted to a dot, unless is it followed by another underscore in which case the two consecutive underscores ("__") are converted to a single underscore. For example, assume your component provides a service using the two service.ranking and foo_bar service properties. In this case you would declare the service properties like this:


 public class Activator extends DependencyManagerActivator {
   public void init(BundleContext ctx, DependencyManager dm) throws Exception {
       component(comp -> comp.impl(MyComponentImpl.class).provides(MyService.class, service_ranking->10, foo__bar -> "gabuzo"));
   }
 } 
 
Caution: Fluent properties requires the usage of the "-parameter" javac option. Under eclipse, you can enable this option using:

 Windows -> Preference -> Compiler -> Classfile Generation -> Store information about method parameters.
 

WARNING: this is interface is deprecated, it is only supported when using java8, not on java9+, and we will remove it in next DM release
  • Method Summary

    Modifier and Type
    Method
    Description
    apply(String name)
    Deprecated.
    Represents a fluent property
  • Method Details

    • apply

      Object apply(String name)
      Deprecated.
      Represents a fluent property
      Parameters:
      name - the property name. The parameter used by the lambda will be intropsected and will be used as the actual property name.
      Returns:
      the property value