/*
 *  Copyright 2001-2010 Stephen Colebourne
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.joda.beans.impl;

import org.joda.beans.Bean;
import org.joda.beans.Property;
import org.joda.beans.PropertyMap;

/**
 * Basic implementation of {@code Bean} intended for applications to subclass.
 * <p>
 * The subclass must to provide an implementation for {@link Bean#metaBean()}.
 * This returns the complete definition of the bean at the meta level.
 * <p>
 * A standard meta-bean implementation is {@link StandardMetaBean}. This is normally
 * declared as a static constant, so {@code metaBean()} simply returns the constant.
 * This approach also requires a public static {@link MetaProperty} instance for each property.
 * 
 * @author Stephen Colebourne
 */
public abstract class BasicBean<B extends BasicBean<B>> implements Bean<B> {

    @SuppressWarnings("unchecked")
    public B beanData() {
        return (B) this;  // generics isn't quite strong enough to define the constraint we need
    }

    public boolean propertyExists(String propertyName) {
        return metaBean().metaPropertyExists(propertyName);
    }

    public Property<B, Object> property(String propertyName) {
        return metaBean().metaProperty(propertyName).createProperty(this);
    }

    public PropertyMap<B> propertyMap() {
        return metaBean().createPropertyMap(this);
    }

    //-----------------------------------------------------------------------
    /**
     * Compares this bean to another.
     * <p>
     * This compares all the properties of the bean.
     * 
     * @param obj  the object to compare to, null returns false
     * @return true if the beans are equal
     */
    @Override
    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (obj instanceof BasicBean<?>) {
            BasicBean<?> other = (BasicBean<?>) obj;
            return propertyMap().flatten().equals(other.propertyMap().flatten());
        }
        return false;
    }

    /**
     * Returns a suitable hash code.
     * <p>
     * The hash code is derived from all the properties of the bean.
     * 
     * @return a suitable hash code
     */
    @Override
    public int hashCode() {
        return propertyMap().flatten().hashCode();
    }

    /**
     * Returns a string that summarises the property.
     * <p>
     * The string contains the class name and properties.
     * 
     * @return a summary string, never null
     */
    @Override
    public String toString() {
        return getClass().getSimpleName() + propertyMap().flatten().toString();
    }

}

@@ -1396,24 +1396,39 @@
 ean%3CB%3E %7B%0D%0A%0D%0A
+    @Override%0D%0A
     @Suppres
@@ -1451,16 +1451,16 @@
 cked%22)%0D%0A
-
     publ
@@ -1577,32 +1577,47 @@
  need%0D%0A    %7D%0D%0A%0D%0A
+    @Override%0D%0A
     public boole
@@ -1720,32 +1720,47 @@
 ame);%0D%0A    %7D%0D%0A%0D%0A
+    @Override%0D%0A
     public Prope
@@ -1888,24 +1888,39 @@
 ;%0D%0A    %7D%0D%0A%0D%0A
+    @Override%0D%0A
     public P

Add override tags