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

com.breuninger.boot.jobs.configuration.JobsProperties Maven / Gradle / Ivy

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

import java.util.HashMap;
import java.util.Map;

import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@ConfigurationProperties(prefix = "breuninger.jobs")
@Validated
public class JobsProperties {

  private boolean externalTrigger = true;
  private @Min(1) int threadCount = 10;
  private @Valid Cleanup cleanup = new Cleanup();
  private @Valid Status status = new Status();

  @Getter
  @Setter
  public static class Cleanup {

    private @Min(1) int numberOfJobsToKeep = 100;
    private @Min(1) int numberOfSkippedJobsToKeep = 10;
    private @Min(1) int markDeadAfter = 30;
  }

  @Getter
  @Setter
  public static class Status {

    private boolean enabled = true;
    private @NotNull Map calculator = new HashMap<>();

    public void setCalculator(final Map calculator) {
      final Map normalized = new HashMap<>();
      calculator.forEach((key, value) -> normalized.put(key.toLowerCase().replace(" ", "-"), value));
      this.calculator = normalized;
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy