View Javadoc

1   /*
2    * Copyright 2012-2013 smartics, Kronseder & Reiner GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package de.smartics.properties.api.core.annotations;
17  
18  import java.lang.annotation.Documented;
19  import java.lang.annotation.ElementType;
20  import java.lang.annotation.Retention;
21  import java.lang.annotation.RetentionPolicy;
22  import java.lang.annotation.Target;
23  
24  /**
25   * Defines a default expression for the property to evaluate a value, if not
26   * specified otherwise.
27   * <p>
28   * The expression may contain a plain default value or the names of properties
29   * to evaluate prior to the translation of the evaluated value to the designated
30   * type. This type is determined by the return value of the annotated method of
31   * the interface. The value is always specified as a {@link String} value.
32   * </p>
33   * <pre>
34   * {@source "Examples"
35   * {@annotation}PropertySet("myprops")
36   * public interface MyProperties {
37   * ...
38   *   {@annotation}PropertyExpression("42")
39   *   int name();
40   *
41   *   {@annotation}PropertyExpression("http://localhost:8080")
42   *   URL baseUrl();
43   *
44   *   {@annotation}PropertyExpression("${myprops.baseUrl}/reports/index.html")
45   *   URL reportIndexUrl();
46   * }
47   * }
48   * </pre>
49   * <p>
50   * Please note that you may use properties of any type to be used as
51   * placeholders in a property value, not just strings. By referencing property
52   * from a placeholder please be reminded to specify the fully qualified name
53   * of the property (which includes the name of the {@link PropertySet property
54   * set}.
55   * </p>
56   */
57  @Documented
58  @Target(ElementType.METHOD)
59  @Retention(RetentionPolicy.RUNTIME)
60  public @interface PropertyExpression
61  {
62    /**
63     * The expression to be evaluated to the property's value type.
64     */
65    String value();
66  }