blob: 96b0360e506d9cc6904a4aaf57551a300aa67d08 [file] [log] [blame]
Pierre De Rop6e8f9212016-02-20 21:44:59 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
Pierre De Ropfaca2892016-01-31 23:27:05 +000019package org.apache.felix.dm.lambda;
20
21import org.apache.felix.dm.lambda.callbacks.SerializableLambda;
22
23/**
24 * Lambda allowing to define fluent service properties. Property names are deduces from the lambda parameter name.
25 *
Pierre De Rop57ffa3f2016-02-19 12:54:30 +000026 * <p> Example of a component which provides fluent properties {"foo"="bar"; "foo2"=Integer(123)}:
Pierre De Ropfaca2892016-01-31 23:27:05 +000027 *
28 * <pre>{@code
29 * public class Activator extends DependencyManagerActivator {
Pierre De Rop11527502016-02-18 21:07:16 +000030 * public void init(BundleContext ctx, DependencyManager dm) throws Exception {
Pierre De Ropfaca2892016-01-31 23:27:05 +000031 * component(comp -> comp.impl(MyComponentImpl.class).provides(MyService.class, foo->"bar", foo2 -> 123));
32 * }
33 * }
34 * }</pre>
35 *
36 * <b>Caution: Fluent properties requires the usage of the "-parameter" javac option.</b>
37 *
38 * Under eclipse, you can enable this option using:
39 *
40 * <pre>{@code
41 * Windows -> Preference -> Compiler -> Classfile Generation -> Store information about method parameters.
42 * }</pre>
43 */
44@FunctionalInterface
Pierre De Rop0aac1362016-02-02 19:46:08 +000045public interface FluentProperty extends SerializableLambda {
Pierre De Ropfaca2892016-01-31 23:27:05 +000046 /**
47 * Represents a fluent property
48 *
49 * @param name the property name. The parameter used by the lambda will be intropsected and will be used as the actual property name.
50 * @return the property value
51 */
52 public Object apply(String name);
53}