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

com.breuninger.boot.jobs.eventbus.events.StateChangeEvent Maven / Gradle / Ivy

There is a newer version: 2.0.5.RELEASE
Show newest version
package com.breuninger.boot.jobs.eventbus.events;

import org.springframework.context.ApplicationEvent;

import com.breuninger.boot.jobs.service.JobRunnable;

import net.jcip.annotations.Immutable;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;

@Immutable
@Getter
@EqualsAndHashCode(callSuper = false)
@ToString
public class StateChangeEvent extends ApplicationEvent {

  private final String jobId;
  private final String jobType;
  private final State state;
  private final String message;

  private StateChangeEvent(final JobRunnable jobRunnable, final String jobId, final State state, final String message) {
    super(jobRunnable);
    this.jobId = jobId;
    jobType = jobRunnable.getJobDefinition().jobType();
    this.state = state;
    this.message = message;
  }

  public static StateChangeEvent newStateChangeEvent(final JobRunnable jobRunnable, final String jobId, final State state) {
    return new StateChangeEvent(jobRunnable, jobId, state, "");
  }

  public static StateChangeEvent newStateChangeEvent(final JobRunnable jobRunnable, final String jobId, final State state,
                                                     final String message) {
    return new StateChangeEvent(jobRunnable, jobId, state, message);
  }

  public enum State {
    START, STOP, FAILED, SKIPPED, RESTART, KEEP_ALIVE, DEAD
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy