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

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

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

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

import org.jobrunr.jobs.states.JobState;
import org.jobrunr.jobs.states.ScheduledState;
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 ScheduledStateBean implements Bean, JobStateBean {

    @PropertyDefinition
    private Instant scheduledAt;

    @PropertyDefinition
    private String recurringJobId;

    @PropertyDefinition
    private String reason;

    @PropertyDefinition
    private String state;

    @PropertyDefinition
    private Instant createdAt;

    @PropertyDefinition
    private Instant updatedAt;

    public ScheduledStateBean() {
    }

    public ScheduledStateBean(ScheduledState scheduledState) {
        this.scheduledAt = scheduledState.getScheduledAt();
        this.recurringJobId = scheduledState.getRecurringJobId();
        this.reason = scheduledState.getReason();

        this.state = scheduledState.getName().name();
        this.createdAt = scheduledState.getCreatedAt();
        this.updatedAt = scheduledState.getCreatedAt();
    }

    @Override
    public JobState toState() {
        return new ScheduledState(getScheduledAt(), getReason());
    }
    //------------------------- AUTOGENERATED START -------------------------
    /**
     * The meta-bean for {@code ScheduledStateBean}.
     * @return the meta-bean, not null
     */
    public static ScheduledStateBean.Meta meta() {
        return ScheduledStateBean.Meta.INSTANCE;
    }

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

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

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

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

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

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

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

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

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

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

    /**
     * Gets the the {@code reason} property.
     * @return the property, not null
     */
    public final Property reason() {
        return metaBean().reason().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 ScheduledStateBean clone() {
        return JodaBeanUtils.cloneAlways(this);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (obj != null && obj.getClass() == this.getClass()) {
            ScheduledStateBean other = (ScheduledStateBean) obj;
            return JodaBeanUtils.equal(getScheduledAt(), other.getScheduledAt()) &&
                    JodaBeanUtils.equal(getRecurringJobId(), other.getRecurringJobId()) &&
                    JodaBeanUtils.equal(getReason(), other.getReason()) &&
                    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(getScheduledAt());
        hash = hash * 31 + JodaBeanUtils.hashCode(getRecurringJobId());
        hash = hash * 31 + JodaBeanUtils.hashCode(getReason());
        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(224);
        buf.append("ScheduledStateBean{");
        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("scheduledAt").append('=').append(JodaBeanUtils.toString(getScheduledAt())).append(',').append(' ');
        buf.append("recurringJobId").append('=').append(JodaBeanUtils.toString(getRecurringJobId())).append(',').append(' ');
        buf.append("reason").append('=').append(JodaBeanUtils.toString(getReason())).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 ScheduledStateBean}.
     */
    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 scheduledAt} property.
         */
        private final MetaProperty scheduledAt = DirectMetaProperty.ofReadWrite(
                this, "scheduledAt", ScheduledStateBean.class, Instant.class);
        /**
         * The meta-property for the {@code recurringJobId} property.
         */
        private final MetaProperty recurringJobId = DirectMetaProperty.ofReadWrite(
                this, "recurringJobId", ScheduledStateBean.class, String.class);
        /**
         * The meta-property for the {@code reason} property.
         */
        private final MetaProperty reason = DirectMetaProperty.ofReadWrite(
                this, "reason", ScheduledStateBean.class, String.class);
        /**
         * The meta-property for the {@code state} property.
         */
        private final MetaProperty state = DirectMetaProperty.ofReadWrite(
                this, "state", ScheduledStateBean.class, String.class);
        /**
         * The meta-property for the {@code createdAt} property.
         */
        private final MetaProperty createdAt = DirectMetaProperty.ofReadWrite(
                this, "createdAt", ScheduledStateBean.class, Instant.class);
        /**
         * The meta-property for the {@code updatedAt} property.
         */
        private final MetaProperty updatedAt = DirectMetaProperty.ofReadWrite(
                this, "updatedAt", ScheduledStateBean.class, Instant.class);
        /**
         * The meta-properties.
         */
        private final Map> metaPropertyMap$ = new DirectMetaPropertyMap(
                this, null,
                "scheduledAt",
                "recurringJobId",
                "reason",
                "state",
                "createdAt",
                "updatedAt");

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

        @Override
        protected MetaProperty metaPropertyGet(String propertyName) {
            switch (propertyName.hashCode()) {
                case 176050624:  // scheduledAt
                    return scheduledAt;
                case -1909551909:  // recurringJobId
                    return recurringJobId;
                case -934964668:  // reason
                    return reason;
                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 ScheduledStateBean());
        }

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

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

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

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

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

        /**
         * 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 176050624:  // scheduledAt
                    return ((ScheduledStateBean) bean).getScheduledAt();
                case -1909551909:  // recurringJobId
                    return ((ScheduledStateBean) bean).getRecurringJobId();
                case -934964668:  // reason
                    return ((ScheduledStateBean) bean).getReason();
                case 109757585:  // state
                    return ((ScheduledStateBean) bean).getState();
                case 598371643:  // createdAt
                    return ((ScheduledStateBean) bean).getCreatedAt();
                case -1949194674:  // updatedAt
                    return ((ScheduledStateBean) bean).getUpdatedAt();
            }
            return super.propertyGet(bean, propertyName, quiet);
        }

        @Override
        protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
            switch (propertyName.hashCode()) {
                case 176050624:  // scheduledAt
                    ((ScheduledStateBean) bean).setScheduledAt((Instant) newValue);
                    return;
                case -1909551909:  // recurringJobId
                    ((ScheduledStateBean) bean).setRecurringJobId((String) newValue);
                    return;
                case -934964668:  // reason
                    ((ScheduledStateBean) bean).setReason((String) newValue);
                    return;
                case 109757585:  // state
                    ((ScheduledStateBean) bean).setState((String) newValue);
                    return;
                case 598371643:  // createdAt
                    ((ScheduledStateBean) bean).setCreatedAt((Instant) newValue);
                    return;
                case -1949194674:  // updatedAt
                    ((ScheduledStateBean) bean).setUpdatedAt((Instant) newValue);
                    return;
            }
            super.propertySet(bean, propertyName, newValue, quiet);
        }

    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy