001    /*
002     *  Copyright 2001-2013 Stephen Colebourne
003     *
004     *  Licensed under the Apache License, Version 2.0 (the "License");
005     *  you may not use this file except in compliance with the License.
006     *  You may obtain a copy of the License at
007     *
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     *
010     *  Unless required by applicable law or agreed to in writing, software
011     *  distributed under the License is distributed on an "AS IS" BASIS,
012     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     *  See the License for the specific language governing permissions and
014     *  limitations under the License.
015     */
016    package org.joda.beans;
017    
018    import java.util.NoSuchElementException;
019    import java.util.Set;
020    
021    /**
022     * A bean consisting of a set of properties.
023     * <p>
024     * The implementation may be any class, but is typically a standard JavaBean
025     * with get/set methods. Alternate implementations might store the properties
026     * in another data structure such as a map.
027     * 
028     * @author Stephen Colebourne
029     */
030    public interface Bean {
031    
032        /**
033         * Gets the meta-bean representing the parts of the bean that are
034         * common across all instances, such as the set of meta-properties.
035         * 
036         * @return the meta-bean, not null
037         */
038        MetaBean metaBean();
039    
040        /**
041         * Gets a property by name.
042         * 
043         * @param <R>  the property type, optional, enabling auto-casting
044         * @param propertyName  the property name to retrieve, null throws NoSuchElementException
045         * @return the property, not null
046         * @throws NoSuchElementException if the property name is invalid
047         */
048        <R> Property<R> property(String propertyName);
049    
050        /**
051         * Gets the set of property names.
052         * 
053         * @return the unmodifiable map of property objects, not null
054         */
055        Set<String> propertyNames();
056    
057    }