Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 1 | package org.apache.felix.dm.lambda; |
| 2 | |
| 3 | import 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 Rop | 57ffa3f | 2016-02-19 12:54:30 +0000 | [diff] [blame^] | 8 | * <p> Example of a component which provides fluent properties {"foo"="bar"; "foo2"=Integer(123)}: |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 9 | * |
| 10 | * <pre>{@code |
| 11 | * public class Activator extends DependencyManagerActivator { |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 12 | * public void init(BundleContext ctx, DependencyManager dm) throws Exception { |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 13 | * 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 Rop | 0aac136 | 2016-02-02 19:46:08 +0000 | [diff] [blame] | 27 | public interface FluentProperty extends SerializableLambda { |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 28 | /** |
| 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 | } |