nhojpatrick/nhojpatrick-cucumber

View on GitHub
json/jodabeans/src/main/java/com/github/nhojpatrick/cucumber/json/jodabeans/transform/TransformActionTask.java

Summary

Maintainability
A
1 hr
Test Coverage
package com.github.nhojpatrick.cucumber.json.jodabeans.transform;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.lang3.builder.CompareToBuilder;
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;

import java.io.Serializable;
import java.util.Map;

import static java.util.Objects.requireNonNull;

@BeanDefinition
@SuppressFBWarnings(value = {"CN_IDIOM_NO_SUPER_CALL",
        "CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE",
        "EI_EXPOSE_REP",
        "USBR_UNNECESSARY_STORE_BEFORE_RETURN"},
        justification = "Managed by JodaBeans")
@SuppressWarnings("PMD.UselessParentheses")
public class TransformActionTask
        implements Bean,
        Comparable<TransformActionTask>,
        Serializable {

    @PropertyDefinition(set = "")
    protected String type;

    @PropertyDefinition(set = "")
    protected String value;

    TransformActionTask() {
    }

    @Override
    public int compareTo(final TransformActionTask that) {

        return new CompareToBuilder()
                .append(this.type, that.type)
                .append(this.value, that.value)
                .toComparison();
    }

    @SuppressFBWarnings(value = "PI_DO_NOT_REUSE_PUBLIC_IDENTIFIERS_CLASS_NAMES",
            justification = "Accepted for Builder")
    public static class Builder<B extends Builder, E extends TransformActionTask> {

        protected E entity;

        public Builder() {
            this((E) new TransformActionTask());
        }

        public Builder(final E entity) {
            requireNonNull(entity, "Builder(TransformActionTask)");
            this.entity = entity;
        }

        public TransformActionTask build() {
            return this.entity;
        }

        public Builder<B, E> withType(final String type) {
            this.entity.type = type;
            return (B) this;
        }

        public Builder<B, E> withValue(final String value) {
            this.entity.value = value;
            return (B) this;
        }

    }

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

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

    /**
     * The serialization version id.
     */
    private static final long serialVersionUID = 1L;

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

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

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

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

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

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

    @Override
    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (obj != null && obj.getClass() == this.getClass()) {
            TransformActionTask other = (TransformActionTask) obj;
            return JodaBeanUtils.equal(getType(), other.getType()) &&
                    JodaBeanUtils.equal(getValue(), other.getValue());
        }
        return false;
    }

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

    @Override
    public String toString() {
        StringBuilder buf = new StringBuilder(96);
        buf.append("TransformActionTask{");
        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("type").append('=').append(JodaBeanUtils.toString(getType())).append(',').append(' ');
        buf.append("value").append('=').append(JodaBeanUtils.toString(getValue())).append(',').append(' ');
    }

    //-----------------------------------------------------------------------
    /**
     * The meta-bean for {@code TransformActionTask}.
     */
    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 type} property.
         */
        private final MetaProperty<String> type = DirectMetaProperty.ofReadOnly(
                this, "type", TransformActionTask.class, String.class);
        /**
         * The meta-property for the {@code value} property.
         */
        private final MetaProperty<String> value = DirectMetaProperty.ofReadOnly(
                this, "value", TransformActionTask.class, String.class);
        /**
         * The meta-properties.
         */
        private final Map<String, MetaProperty<?>> metaPropertyMap$ = new DirectMetaPropertyMap(
                this, null,
                "type",
                "value");

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

        @Override
        protected MetaProperty<?> metaPropertyGet(String propertyName) {
            switch (propertyName.hashCode()) {
                case 3575610:  // type
                    return type;
                case 111972721:  // value
                    return value;
            }
            return super.metaPropertyGet(propertyName);
        }

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

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

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

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

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

        //-----------------------------------------------------------------------
        @Override
        protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
            switch (propertyName.hashCode()) {
                case 3575610:  // type
                    return ((TransformActionTask) bean).getType();
                case 111972721:  // value
                    return ((TransformActionTask) bean).getValue();
            }
            return super.propertyGet(bean, propertyName, quiet);
        }

        @Override
        protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
            switch (propertyName.hashCode()) {
                case 3575610:  // type
                    if (quiet) {
                        return;
                    }
                    throw new UnsupportedOperationException("Property cannot be written: type");
                case 111972721:  // value
                    if (quiet) {
                        return;
                    }
                    throw new UnsupportedOperationException("Property cannot be written: value");
            }
            super.propertySet(bean, propertyName, newValue, quiet);
        }

    }

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

}