All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.lontime.extjobrunr.beans.states.SucceededStateBean Maven / Gradle / Ivy

package com.github.lontime.extjobrunr.beans.states;

import java.time.Duration;
import java.time.Instant;
import java.util.Map;

import org.jobrunr.jobs.states.JobState;
import org.jobrunr.jobs.states.SucceededState;
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;

@BeanDefinition
public class SucceededStateBean implements Bean, JobStateBean {

    @PropertyDefinition
    private Duration latencyDuration;

    @PropertyDefinition
    private Duration processDuration;

    @PropertyDefinition
    private String state;

    @PropertyDefinition
    private Instant createdAt;

    @PropertyDefinition
    private Instant updatedAt;

    public SucceededStateBean() {

    }

    public SucceededStateBean(SucceededState succeededState) {
        this.processDuration = succeededState.getProcessDuration();
        this.latencyDuration = succeededState.getLatencyDuration();
        this.state = succeededState.getName().name();
        this.createdAt = succeededState.getCreatedAt();
        this.updatedAt = succeededState.getUpdatedAt();
    }

    @Override
    public JobState toState() {
        return new SucceededState(getLatencyDuration(), getProcessDuration());
    }

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

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

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

    //-----------------------------------------------------------------------
    /**
     * Gets the latencyDuration.
     * @return the value of the property
     */
    public Duration getLatencyDuration() {
        return latencyDuration;
    }

    /**
     * Sets the latencyDuration.
     * @param latencyDuration  the new value of the property
     */
    public void setLatencyDuration(Duration latencyDuration) {
        this.latencyDuration = latencyDuration;
    }

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

    //-----------------------------------------------------------------------
    /**
     * Gets the processDuration.
     * @return the value of the property
     */
    public Duration getProcessDuration() {
        return processDuration;
    }

    /**
     * Sets the processDuration.
     * @param processDuration  the new value of the property
     */
    public void setProcessDuration(Duration processDuration) {
        this.processDuration = processDuration;
    }

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

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

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

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

    //-----------------------------------------------------------------------
    /**
     * Gets the createdAt.
     * @return the value of the property
     */
    public Instant getCreatedAt() {
        return createdAt;
    }

    /**
     * Sets the createdAt.
     * @param createdAt  the new value of the property
     */
    public void setCreatedAt(Instant createdAt) {
        this.createdAt = createdAt;
    }

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

    //-----------------------------------------------------------------------
    /**
     * Gets the updatedAt.
     * @return the value of the property
     */
    public Instant getUpdatedAt() {
        return updatedAt;
    }

    /**
     * Sets the updatedAt.
     * @param updatedAt  the new value of the property
     */
    public void setUpdatedAt(Instant updatedAt) {
        this.updatedAt = updatedAt;
    }

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

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

    @Override
    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (obj != null && obj.getClass() == this.getClass()) {
            SucceededStateBean other = (SucceededStateBean) obj;
            return JodaBeanUtils.equal(getLatencyDuration(), other.getLatencyDuration()) &&
                    JodaBeanUtils.equal(getProcessDuration(), other.getProcessDuration()) &&
                    JodaBeanUtils.equal(getState(), other.getState()) &&
                    JodaBeanUtils.equal(getCreatedAt(), other.getCreatedAt()) &&
                    JodaBeanUtils.equal(getUpdatedAt(), other.getUpdatedAt());
        }
        return false;
    }

    @Override
    public int hashCode() {
        int hash = getClass().hashCode();
        hash = hash * 31 + JodaBeanUtils.hashCode(getLatencyDuration());
        hash = hash * 31 + JodaBeanUtils.hashCode(getProcessDuration());
        hash = hash * 31 + JodaBeanUtils.hashCode(getState());
        hash = hash * 31 + JodaBeanUtils.hashCode(getCreatedAt());
        hash = hash * 31 + JodaBeanUtils.hashCode(getUpdatedAt());
        return hash;
    }

    @Override
    public String toString() {
        StringBuilder buf = new StringBuilder(192);
        buf.append("SucceededStateBean{");
        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("latencyDuration").append('=').append(JodaBeanUtils.toString(getLatencyDuration())).append(',').append(' ');
        buf.append("processDuration").append('=').append(JodaBeanUtils.toString(getProcessDuration())).append(',').append(' ');
        buf.append("state").append('=').append(JodaBeanUtils.toString(getState())).append(',').append(' ');
        buf.append("createdAt").append('=').append(JodaBeanUtils.toString(getCreatedAt())).append(',').append(' ');
        buf.append("updatedAt").append('=').append(JodaBeanUtils.toString(getUpdatedAt())).append(',').append(' ');
    }

    //-----------------------------------------------------------------------
    /**
     * The meta-bean for {@code SucceededStateBean}.
     */
    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 latencyDuration} property.
         */
        private final MetaProperty latencyDuration = DirectMetaProperty.ofReadWrite(
                this, "latencyDuration", SucceededStateBean.class, Duration.class);
        /**
         * The meta-property for the {@code processDuration} property.
         */
        private final MetaProperty processDuration = DirectMetaProperty.ofReadWrite(
                this, "processDuration", SucceededStateBean.class, Duration.class);
        /**
         * The meta-property for the {@code state} property.
         */
        private final MetaProperty state = DirectMetaProperty.ofReadWrite(
                this, "state", SucceededStateBean.class, String.class);
        /**
         * The meta-property for the {@code createdAt} property.
         */
        private final MetaProperty createdAt = DirectMetaProperty.ofReadWrite(
                this, "createdAt", SucceededStateBean.class, Instant.class);
        /**
         * The meta-property for the {@code updatedAt} property.
         */
        private final MetaProperty updatedAt = DirectMetaProperty.ofReadWrite(
                this, "updatedAt", SucceededStateBean.class, Instant.class);
        /**
         * The meta-properties.
         */
        private final Map> metaPropertyMap$ = new DirectMetaPropertyMap(
                this, null,
                "latencyDuration",
                "processDuration",
                "state",
                "createdAt",
                "updatedAt");

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

        @Override
        protected MetaProperty metaPropertyGet(String propertyName) {
            switch (propertyName.hashCode()) {
                case -1372446542:  // latencyDuration
                    return latencyDuration;
                case -329649885:  // processDuration
                    return processDuration;
                case 109757585:  // state
                    return state;
                case 598371643:  // createdAt
                    return createdAt;
                case -1949194674:  // updatedAt
                    return updatedAt;
            }
            return super.metaPropertyGet(propertyName);
        }

        @Override
        public BeanBuilder builder() {
            return new DirectBeanBuilder<>(new SucceededStateBean());
        }

        @Override
        public Class beanType() {
            return SucceededStateBean.class;
        }

        @Override
        public Map> metaPropertyMap() {
            return metaPropertyMap$;
        }

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

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

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

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

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

        //-----------------------------------------------------------------------
        @Override
        protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
            switch (propertyName.hashCode()) {
                case -1372446542:  // latencyDuration
                    return ((SucceededStateBean) bean).getLatencyDuration();
                case -329649885:  // processDuration
                    return ((SucceededStateBean) bean).getProcessDuration();
                case 109757585:  // state
                    return ((SucceededStateBean) bean).getState();
                case 598371643:  // createdAt
                    return ((SucceededStateBean) bean).getCreatedAt();
                case -1949194674:  // updatedAt
                    return ((SucceededStateBean) bean).getUpdatedAt();
            }
            return super.propertyGet(bean, propertyName, quiet);
        }

        @Override
        protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
            switch (propertyName.hashCode()) {
                case -1372446542:  // latencyDuration
                    ((SucceededStateBean) bean).setLatencyDuration((Duration) newValue);
                    return;
                case -329649885:  // processDuration
                    ((SucceededStateBean) bean).setProcessDuration((Duration) newValue);
                    return;
                case 109757585:  // state
                    ((SucceededStateBean) bean).setState((String) newValue);
                    return;
                case 598371643:  // createdAt
                    ((SucceededStateBean) bean).setCreatedAt((Instant) newValue);
                    return;
                case -1949194674:  // updatedAt
                    ((SucceededStateBean) bean).setUpdatedAt((Instant) newValue);
                    return;
            }
            super.propertySet(bean, propertyName, newValue, quiet);
        }

    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy