1 /*
2 * Copyright 2001-2013 Stephen Colebourne
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 org.joda.beans;
17
18 import java.util.NoSuchElementException;
19 import java.util.Set;
20
21 /**
22 * A bean consisting of a set of properties.
23 * <p>
24 * The implementation may be any class, but is typically a standard JavaBean
25 * with get/set methods. Alternate implementations might store the properties
26 * in another data structure such as a map.
27 *
28 * @author Stephen Colebourne
29 */
30 public interface Bean {
31
32 /**
33 * Gets the meta-bean representing the parts of the bean that are
34 * common across all instances, such as the set of meta-properties.
35 *
36 * @return the meta-bean, not null
37 */
38 MetaBean metaBean();
39
40 /**
41 * Gets a property by name.
42 *
43 * @param <R> the property type, optional, enabling auto-casting
44 * @param propertyName the property name to retrieve, null throws NoSuchElementException
45 * @return the property, not null
46 * @throws NoSuchElementException if the property name is invalid
47 */
48 <R> Property<R> property(String propertyName);
49
50 /**
51 * Gets the set of property names.
52 *
53 * @return the unmodifiable map of property objects, not null
54 */
55 Set<String> propertyNames();
56
57 }