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.tutorial.property.constraints;
17  
18  import java.net.URL;
19  
20  import javax.validation.constraints.Min;
21  import javax.validation.constraints.NotNull;
22  
23  import org.hibernate.validator.constraints.NotBlank;
24  
25  import de.smartics.properties.api.core.annotations.AccessType;
26  import de.smartics.properties.api.core.annotations.PropertyExpression;
27  import de.smartics.properties.api.core.annotations.PropertyIntValueRange;
28  import de.smartics.properties.api.core.annotations.PropertyLifecycle;
29  import de.smartics.properties.api.core.annotations.PropertySet;
30  import de.smartics.properties.api.core.domain.PropertyKey;
31  
32  /**
33   * A sample property set for the {@link PropertyConstraintsTutorial}.
34   */
35  @PropertySet(value = "tutorial.property.constraints")
36  public interface ConstraintsProperties
37  {
38    /**
39     * The property must not be blank.
40     */
41    @NotBlank
42    @PropertyLifecycle(access = AccessType.READ_WRITE)
43    String host();
44  
45    PropertyKey hostPropertyKey();
46  
47    /**
48     * The property must not be <code>null</code>.
49     */
50    @NotNull
51    @PropertyLifecycle(access = AccessType.READ_WRITE)
52    URL server();
53  
54    PropertyKey serverPropertyKey();
55  
56    // CHECKSTYLE:OFF
57    /**
58     * A value to be picked from a range of values.
59     */
60    @PropertyIntValueRange(value = { 0, 1, 2, 3, 5, 8, 13, 21, 50, 100 },
61        defaultValue = 8)
62    @NotNull
63    @PropertyLifecycle(access = AccessType.READ_WRITE)
64    Integer storyPoint();
65  
66    // CHECKSTYLE:ON
67  
68    PropertyKey storyPointPropertyKey();
69  
70    /**
71     * A value picked from an enumeration.
72     */
73    @PropertyExpression("required")
74    @PropertyLifecycle(access = AccessType.READ_WRITE)
75    Priority priority();
76  
77    PropertyKey priorityPropertyKey();
78  
79    /**
80     * A value with a minimum level.
81     */
82    @PropertyExpression("0")
83    @Min(0)
84    @PropertyLifecycle(access = AccessType.READ_WRITE)
85    int happiness();
86  
87    PropertyKey happinessPropertyKey();
88  
89    /**
90     * A value with a minimum and maximum level.
91     */
92    @PropertyExpression("0")
93    @RealHappiness
94    @PropertyLifecycle(access = AccessType.READ_WRITE)
95    int realHappiness();
96  
97    PropertyKey realHappinessPropertyKey();
98  }