/*
 *  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 java.util.Optional;

import org.joda.beans.Bean;
import org.joda.beans.BeanBuilder;
import org.joda.beans.JodaBeanUtils;
import org.joda.beans.MetaBean;
import org.joda.beans.MetaProperty;
import org.joda.beans.Property;
import org.joda.beans.gen.BeanDefinition;
import org.joda.beans.gen.PropertyDefinition;
import org.joda.beans.impl.direct.DirectBeanBuilder;
import org.joda.beans.impl.direct.DirectMetaBean;
import org.joda.beans.impl.direct.DirectMetaProperty;
import org.joda.beans.impl.direct.DirectMetaPropertyMap;

/**
 * Mock person JavaBean, used for testing.
 * 
 * @author Stephen Colebourne
 */
@BeanDefinition
public final class MutableDeprecated implements Cloneable, Bean {

    /**
     * The field with deprecated annotation and Javadoc tag.
     * @deprecated Use something else
     */
    @Deprecated
    @PropertyDefinition
    private String deprecatedBoth;

    /**
     * The field with deprecated Javadoc tag only.
     * @deprecated Use something else
     */
    @PropertyDefinition
    private String deprecatedJavadoc;

    @Deprecated
    @PropertyDefinition
    private String deprecatedAnnotation;

    @Deprecated
    @PropertyDefinition(get = "optional")
    private String deprecatedOptional;

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

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

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

    //-----------------------------------------------------------------------
    /**
     * Gets the field with deprecated annotation and Javadoc tag.
     * @return the value of the property
     * @deprecated Use something else
     */
    @Deprecated
    public String getDeprecatedBoth() {
        return deprecatedBoth;
    }

    /**
     * Sets the field with deprecated annotation and Javadoc tag.
     * @param deprecatedBoth  the new value of the property
     * @deprecated Use something else
     */
    @Deprecated
    public void setDeprecatedBoth(String deprecatedBoth) {
        this.deprecatedBoth = deprecatedBoth;
    }

    /**
     * Gets the the {@code deprecatedBoth} property.
     * @return the property, not null
     * @deprecated Use something else
     */
    @Deprecated
    public Property<String> deprecatedBoth() {
        return metaBean().deprecatedBoth().createProperty(this);
    }

    //-----------------------------------------------------------------------
    /**
     * Gets the field with deprecated Javadoc tag only.
     * @return the value of the property
     * @deprecated Use something else
     */
    @Deprecated
    public String getDeprecatedJavadoc() {
        return deprecatedJavadoc;
    }

    /**
     * Sets the field with deprecated Javadoc tag only.
     * @param deprecatedJavadoc  the new value of the property
     * @deprecated Use something else
     */
    @Deprecated
    public void setDeprecatedJavadoc(String deprecatedJavadoc) {
        this.deprecatedJavadoc = deprecatedJavadoc;
    }

    /**
     * Gets the the {@code deprecatedJavadoc} property.
     * @return the property, not null
     * @deprecated Use something else
     */
    @Deprecated
    public Property<String> deprecatedJavadoc() {
        return metaBean().deprecatedJavadoc().createProperty(this);
    }

    //-----------------------------------------------------------------------
    /**
     * Gets the deprecatedAnnotation.
     * @return the value of the property
     * @deprecated Deprecated
     */
    @Deprecated
    public String getDeprecatedAnnotation() {
        return deprecatedAnnotation;
    }

    /**
     * Sets the deprecatedAnnotation.
     * @param deprecatedAnnotation  the new value of the property
     * @deprecated Deprecated
     */
    @Deprecated
    public void setDeprecatedAnnotation(String deprecatedAnnotation) {
        this.deprecatedAnnotation = deprecatedAnnotation;
    }

    /**
     * Gets the the {@code deprecatedAnnotation} property.
     * @return the property, not null
     * @deprecated Deprecated
     */
    @Deprecated
    public Property<String> deprecatedAnnotation() {
        return metaBean().deprecatedAnnotation().createProperty(this);
    }

    //-----------------------------------------------------------------------
    /**
     * Gets the deprecatedOptional.
     * @return the optional value of the property, not null
     * @deprecated Deprecated
     */
    @Deprecated
    public Optional<String> getDeprecatedOptional() {
        return Optional.ofNullable(deprecatedOptional);
    }

    /**
     * Sets the deprecatedOptional.
     * @param deprecatedOptional  the new value of the property
     * @deprecated Deprecated
     */
    @Deprecated
    public void setDeprecatedOptional(String deprecatedOptional) {
        this.deprecatedOptional = deprecatedOptional;
    }

    /**
     * Gets the the {@code deprecatedOptional} property.
     * @return the property, not null
     * @deprecated Deprecated
     */
    @Deprecated
    public Property<String> deprecatedOptional() {
        return metaBean().deprecatedOptional().createProperty(this);
    }

    //-----------------------------------------------------------------------
    @Override
    public MutableDeprecated clone() {
        return JodaBeanUtils.cloneAlways(this);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (obj != null && obj.getClass() == this.getClass()) {
            MutableDeprecated other = (MutableDeprecated) obj;
            return JodaBeanUtils.equal(this.getDeprecatedBoth(), other.getDeprecatedBoth()) &&
                    JodaBeanUtils.equal(this.getDeprecatedJavadoc(), other.getDeprecatedJavadoc()) &&
                    JodaBeanUtils.equal(this.getDeprecatedAnnotation(), other.getDeprecatedAnnotation()) &&
                    JodaBeanUtils.equal(this.deprecatedOptional, other.deprecatedOptional);
        }
        return false;
    }

    @Override
    public int hashCode() {
        int hash = getClass().hashCode();
        hash = hash * 31 + JodaBeanUtils.hashCode(getDeprecatedBoth());
        hash = hash * 31 + JodaBeanUtils.hashCode(getDeprecatedJavadoc());
        hash = hash * 31 + JodaBeanUtils.hashCode(getDeprecatedAnnotation());
        hash = hash * 31 + JodaBeanUtils.hashCode(deprecatedOptional);
        return hash;
    }

    @Override
    public String toString() {
        StringBuilder buf = new StringBuilder(160);
        buf.append("MutableDeprecated{");
        buf.append("deprecatedBoth").append('=').append(JodaBeanUtils.toString(getDeprecatedBoth())).append(',').append(' ');
        buf.append("deprecatedJavadoc").append('=').append(JodaBeanUtils.toString(getDeprecatedJavadoc())).append(',').append(' ');
        buf.append("deprecatedAnnotation").append('=').append(JodaBeanUtils.toString(getDeprecatedAnnotation())).append(',').append(' ');
        buf.append("deprecatedOptional").append('=').append(JodaBeanUtils.toString(deprecatedOptional));
        buf.append('}');
        return buf.toString();
    }

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

        /**
         * The meta-property for the {@code deprecatedBoth} property.
         */
        private final MetaProperty<String> deprecatedBoth = DirectMetaProperty.ofReadWrite(
                this, "deprecatedBoth", MutableDeprecated.class, String.class);
        /**
         * The meta-property for the {@code deprecatedJavadoc} property.
         */
        private final MetaProperty<String> deprecatedJavadoc = DirectMetaProperty.ofReadWrite(
                this, "deprecatedJavadoc", MutableDeprecated.class, String.class);
        /**
         * The meta-property for the {@code deprecatedAnnotation} property.
         */
        private final MetaProperty<String> deprecatedAnnotation = DirectMetaProperty.ofReadWrite(
                this, "deprecatedAnnotation", MutableDeprecated.class, String.class);
        /**
         * The meta-property for the {@code deprecatedOptional} property.
         */
        private final MetaProperty<String> deprecatedOptional = DirectMetaProperty.ofReadWrite(
                this, "deprecatedOptional", MutableDeprecated.class, String.class);
        /**
         * The meta-properties.
         */
        private final Map<String, MetaProperty<?>> metaPropertyMap$ = new DirectMetaPropertyMap(
                this, null,
                "deprecatedBoth",
                "deprecatedJavadoc",
                "deprecatedAnnotation",
                "deprecatedOptional");

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

        @Override
        protected MetaProperty<?> metaPropertyGet(String propertyName) {
            switch (propertyName.hashCode()) {
                case -1108081708:  // deprecatedBoth
                    return this.deprecatedBoth;
                case -1632501085:  // deprecatedJavadoc
                    return this.deprecatedJavadoc;
                case 1044703554:  // deprecatedAnnotation
                    return this.deprecatedAnnotation;
                case 1434300979:  // deprecatedOptional
                    return this.deprecatedOptional;
            }
            return super.metaPropertyGet(propertyName);
        }

        @Override
        public BeanBuilder<? extends MutableDeprecated> builder() {
            return new DirectBeanBuilder<>(new MutableDeprecated());
        }

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

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

        //-----------------------------------------------------------------------
        /**
         * The meta-property for the {@code deprecatedBoth} property.
         * @return the meta-property, not null
         * @deprecated Use something else
         */
        @Deprecated
        public MetaProperty<String> deprecatedBoth() {
            return deprecatedBoth;
        }

        /**
         * The meta-property for the {@code deprecatedJavadoc} property.
         * @return the meta-property, not null
         * @deprecated Use something else
         */
        @Deprecated
        public MetaProperty<String> deprecatedJavadoc() {
            return deprecatedJavadoc;
        }

        /**
         * The meta-property for the {@code deprecatedAnnotation} property.
         * @return the meta-property, not null
         * @deprecated Deprecated
         */
        @Deprecated
        public MetaProperty<String> deprecatedAnnotation() {
            return deprecatedAnnotation;
        }

        /**
         * The meta-property for the {@code deprecatedOptional} property.
         * @return the meta-property, not null
         * @deprecated Deprecated
         */
        @Deprecated
        public MetaProperty<String> deprecatedOptional() {
            return deprecatedOptional;
        }

        //-----------------------------------------------------------------------
        @Override
        protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
            switch (propertyName.hashCode()) {
                case -1108081708:  // deprecatedBoth
                    return ((MutableDeprecated) bean).getDeprecatedBoth();
                case -1632501085:  // deprecatedJavadoc
                    return ((MutableDeprecated) bean).getDeprecatedJavadoc();
                case 1044703554:  // deprecatedAnnotation
                    return ((MutableDeprecated) bean).getDeprecatedAnnotation();
                case 1434300979:  // deprecatedOptional
                    return ((MutableDeprecated) bean).deprecatedOptional;
            }
            return super.propertyGet(bean, propertyName, quiet);
        }

        @Override
        protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
            switch (propertyName.hashCode()) {
                case -1108081708:  // deprecatedBoth
                    ((MutableDeprecated) bean).setDeprecatedBoth((String) newValue);
                    return;
                case -1632501085:  // deprecatedJavadoc
                    ((MutableDeprecated) bean).setDeprecatedJavadoc((String) newValue);
                    return;
                case 1044703554:  // deprecatedAnnotation
                    ((MutableDeprecated) bean).setDeprecatedAnnotation((String) newValue);
                    return;
                case 1434300979:  // deprecatedOptional
                    ((MutableDeprecated) bean).setDeprecatedOptional((String) newValue);
                    return;
            }
            super.propertySet(bean, propertyName, newValue, quiet);
        }

    }

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