/*
 *  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.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.
 */
@BeanDefinition(cloneStyle = "omit")
public class NoClone
        implements Bean {

    @PropertyDefinition
    private String dummyProperty;

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

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

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

    //-----------------------------------------------------------------------
    /**
     * Gets the dummyProperty.
     * @return the value of the property
     */
    public String getDummyProperty() {
        return dummyProperty;
    }

    /**
     * Sets the dummyProperty.
     * @param dummyProperty  the new value of the property
     */
    public void setDummyProperty(String dummyProperty) {
        this.dummyProperty = dummyProperty;
    }

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

    //-----------------------------------------------------------------------
    @Override
    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (obj != null && obj.getClass() == this.getClass()) {
            NoClone other = (NoClone) obj;
            return JodaBeanUtils.equal(this.getDummyProperty(), other.getDummyProperty());
        }
        return false;
    }

    @Override
    public int hashCode() {
        int hash = getClass().hashCode();
        hash = hash * 31 + JodaBeanUtils.hashCode(getDummyProperty());
        return hash;
    }

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

    protected void toString(StringBuilder buf) {
        buf.append("dummyProperty").append('=').append(JodaBeanUtils.toString(getDummyProperty())).append(',').append(' ');
    }

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

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

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

        @Override
        protected MetaProperty<?> metaPropertyGet(String propertyName) {
            switch (propertyName.hashCode()) {
                case -184213859:  // dummyProperty
                    return this.dummyProperty;
            }
            return super.metaPropertyGet(propertyName);
        }

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

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

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

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

        //-----------------------------------------------------------------------
        @Override
        protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
            switch (propertyName.hashCode()) {
                case -184213859:  // dummyProperty
                    return ((NoClone) bean).getDummyProperty();
            }
            return super.propertyGet(bean, propertyName, quiet);
        }

        @Override
        protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
            switch (propertyName.hashCode()) {
                case -184213859:  // dummyProperty
                    ((NoClone) bean).setDummyProperty((String) newValue);
                    return;
            }
            super.propertySet(bean, propertyName, newValue, quiet);
        }

    }

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