/*
 *  Copyright 2001-present 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.sample;

import java.util.Map;

import org.joda.beans.JodaBeanUtils;
import org.joda.beans.MetaBean;
import org.joda.beans.MetaProperty;
import org.joda.beans.gen.BeanDefinition;
import org.joda.beans.impl.direct.DirectMetaPropertyMap;

/**
 * Mock.
 */
@BeanDefinition(builderScope = "public")
public class MutableDerivedBean extends MutableBaseBean {

    //------------------------- AUTOGENERATED START -------------------------
    /**
     * The meta-bean for {@code MutableDerivedBean}.
     * @return the meta-bean, not null
     */
    public static MutableDerivedBean.Meta meta() {
        return MutableDerivedBean.Meta.INSTANCE;
    }

    static {
        MetaBean.register(MutableDerivedBean.Meta.INSTANCE);
    }

    /**
     * Returns a builder used to create an instance of the bean.
     * @return the builder, not null
     */
    public static MutableDerivedBean.Builder builder() {
        return new MutableDerivedBean.Builder();
    }

    /**
     * Restricted constructor.
     * @param builder  the builder to copy from, not null
     */
    protected MutableDerivedBean(MutableDerivedBean.Builder builder) {
        super(builder);
    }

    @Override
    public MutableDerivedBean.Meta metaBean() {
        return MutableDerivedBean.Meta.INSTANCE;
    }

    //-----------------------------------------------------------------------
    /**
     * Returns a builder that allows this bean to be mutated.
     * @return the mutable builder, not null
     */
    @Override
    public Builder toBuilder() {
        return new Builder(this);
    }

    @Override
    public MutableDerivedBean clone() {
        return JodaBeanUtils.cloneAlways(this);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (obj != null && obj.getClass() == this.getClass()) {
            return super.equals(obj);
        }
        return false;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        return hash ^ super.hashCode();
    }

    @Override
    public String toString() {
        StringBuilder buf = new StringBuilder(32);
        buf.append("MutableDerivedBean{");
        int len = buf.length();
        toString(buf);
        if (buf.length() > len) {
            buf.setLength(buf.length() - 2);
        }
        buf.append('}');
        return buf.toString();
    }

    @Override
    protected void toString(StringBuilder buf) {
        super.toString(buf);
    }

    //-----------------------------------------------------------------------
    /**
     * The meta-bean for {@code MutableDerivedBean}.
     */
    public static class Meta extends MutableBaseBean.Meta {
        /**
         * The singleton instance of the meta-bean.
         */
        static final Meta INSTANCE = new Meta();

        /**
         * The meta-properties.
         */
        private final Map<String, MetaProperty<?>> metaPropertyMap$ = new DirectMetaPropertyMap(
                this, (DirectMetaPropertyMap) super.metaPropertyMap());

        /**
         * Restricted constructor.
         */
        protected Meta() {
        }

        @Override
        public MutableDerivedBean.Builder builder() {
            return new MutableDerivedBean.Builder();
        }

        @Override
        public Class<? extends MutableDerivedBean> beanType() {
            return MutableDerivedBean.class;
        }

        @Override
        public Map<String, MetaProperty<?>> metaPropertyMap() {
            return metaPropertyMap$;
        }

        //-----------------------------------------------------------------------
    }

    //-----------------------------------------------------------------------
    /**
     * The bean-builder for {@code MutableDerivedBean}.
     */
    public static class Builder extends MutableBaseBean.Builder {

        /**
         * Restricted constructor.
         */
        protected Builder() {
        }

        /**
         * Restricted copy constructor.
         * @param beanToCopy  the bean to copy from, not null
         */
        protected Builder(MutableDerivedBean beanToCopy) {
            super(beanToCopy);
        }

        //-----------------------------------------------------------------------
        @Override
        public Object get(String propertyName) {
            return super.get(propertyName);
        }

        @Override
        public Builder set(String propertyName, Object newValue) {
            super.set(propertyName, newValue);
            return this;
        }

        @Override
        public Builder set(MetaProperty<?> property, Object value) {
            super.set(property, value);
            return this;
        }

        @Override
        public MutableDerivedBean build() {
            return new MutableDerivedBean(this);
        }

        //-----------------------------------------------------------------------
        @Override
        public String toString() {
            StringBuilder buf = new StringBuilder(32);
            buf.append("MutableDerivedBean.Builder{");
            int len = buf.length();
            toString(buf);
            if (buf.length() > len) {
                buf.setLength(buf.length() - 2);
            }
            buf.append('}');
            return buf.toString();
        }

        @Override
        protected void toString(StringBuilder buf) {
            super.toString(buf);
        }

    }

    //-------------------------- AUTOGENERATED END --------------------------
}
