blob: 096f9c6b346d2cefc7928712b953c74f946c4160 [file] [log] [blame]
Pierre De Ropfaca2892016-01-31 23:27:05 +00001package org.apache.felix.dm.lambda;
2
3import org.apache.felix.dm.lambda.callbacks.SerializableLambda;
4
5/**
6 * Lambda allowing to define fluent service properties. Property names are deduces from the lambda parameter name.
7 *
Pierre De Rop57ffa3f2016-02-19 12:54:30 +00008 * <p> Example of a component which provides fluent properties {"foo"="bar"; "foo2"=Integer(123)}:
Pierre De Ropfaca2892016-01-31 23:27:05 +00009 *
10 * <pre>{@code
11 * public class Activator extends DependencyManagerActivator {
Pierre De Rop11527502016-02-18 21:07:16 +000012 * public void init(BundleContext ctx, DependencyManager dm) throws Exception {
Pierre De Ropfaca2892016-01-31 23:27:05 +000013 * component(comp -> comp.impl(MyComponentImpl.class).provides(MyService.class, foo->"bar", foo2 -> 123));
14 * }
15 * }
16 * }</pre>
17 *
18 * <b>Caution: Fluent properties requires the usage of the "-parameter" javac option.</b>
19 *
20 * Under eclipse, you can enable this option using:
21 *
22 * <pre>{@code
23 * Windows -> Preference -> Compiler -> Classfile Generation -> Store information about method parameters.
24 * }</pre>
25 */
26@FunctionalInterface
Pierre De Rop0aac1362016-02-02 19:46:08 +000027public interface FluentProperty extends SerializableLambda {
Pierre De Ropfaca2892016-01-31 23:27:05 +000028 /**
29 * Represents a fluent property
30 *
31 * @param name the property name. The parameter used by the lambda will be intropsected and will be used as the actual property name.
32 * @return the property value
33 */
34 public Object apply(String name);
35}