Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
UnknownProperties |
|
|
1.2;1.2 |
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.config.domain; |
|
17 | ||
18 | import java.io.Serializable; |
|
19 | import java.util.ArrayList; |
|
20 | import java.util.Collections; |
|
21 | import java.util.List; |
|
22 | ||
23 | import javax.annotation.concurrent.NotThreadSafe; |
|
24 | ||
25 | ||
26 | /** |
|
27 | * The set of unknown properties. |
|
28 | */ |
|
29 | @NotThreadSafe |
|
30 | public final class UnknownProperties implements Serializable |
|
31 | { |
|
32 | // ********************************* Fields ********************************* |
|
33 | ||
34 | // --- constants ------------------------------------------------------------ |
|
35 | ||
36 | /** |
|
37 | * The class version identifier. |
|
38 | */ |
|
39 | private static final long serialVersionUID = 1L; |
|
40 | ||
41 | // --- members -------------------------------------------------------------- |
|
42 | ||
43 | /** |
|
44 | * The list of unknown properties. |
|
45 | * |
|
46 | * @serial |
|
47 | */ |
|
48 | 0 | private final List<Property> properties = |
49 | new ArrayList<Property>(); |
|
50 | ||
51 | // ****************************** Initializer ******************************* |
|
52 | ||
53 | // ****************************** Constructors ****************************** |
|
54 | ||
55 | /** |
|
56 | * Default constructor. |
|
57 | */ |
|
58 | public UnknownProperties() |
|
59 | 0 | { |
60 | 0 | } |
61 | ||
62 | // ****************************** Inner Classes ***************************** |
|
63 | ||
64 | // ********************************* Methods ******************************** |
|
65 | ||
66 | // --- init ----------------------------------------------------------------- |
|
67 | ||
68 | // --- get&set -------------------------------------------------------------- |
|
69 | ||
70 | // --- business ------------------------------------------------------------- |
|
71 | ||
72 | /** |
|
73 | * Adds the unknown properties to the list. |
|
74 | * |
|
75 | * @param property the property to add. |
|
76 | */ |
|
77 | public void add(final Property property) |
|
78 | { |
|
79 | 0 | properties.add(property); |
80 | 0 | } |
81 | ||
82 | /** |
|
83 | * Returns a reference to the list on unknown properties. |
|
84 | * |
|
85 | * @return a reference to the list on unknown properties. |
|
86 | */ |
|
87 | public List<Property> getProperties() |
|
88 | { |
|
89 | 0 | return Collections.unmodifiableList(properties); |
90 | } |
|
91 | ||
92 | /** |
|
93 | * Checks if the container contains at least one property. |
|
94 | * |
|
95 | * @return <code>true</code> if there is no property, <code>false</code> |
|
96 | * otherwise. |
|
97 | */ |
|
98 | public boolean isEmpty() |
|
99 | { |
|
100 | 0 | return properties.isEmpty(); |
101 | } |
|
102 | ||
103 | // --- object basics -------------------------------------------------------- |
|
104 | ||
105 | /** |
|
106 | * Returns the string representation of the object. |
|
107 | * |
|
108 | * @return the string representation of the object. |
|
109 | */ |
|
110 | @Override |
|
111 | public String toString() |
|
112 | { |
|
113 | 0 | final StringBuilder buffer = new StringBuilder(); |
114 | ||
115 | 0 | for (final Property property : properties) |
116 | { |
|
117 | 0 | buffer.append(property).append(' '); |
118 | } |
|
119 | ||
120 | 0 | return buffer.toString(); |
121 | } |
|
122 | } |