com.fathzer.sitessupervisor.Configuration Maven / Gradle / Ivy
package com.fathzer.sitessupervisor;
import java.net.URI;
import java.util.Map;
import java.util.Set;
import com.fathzer.sitessupervisor.alerter.Alerter;
import com.fathzer.sitessupervisor.db.DB;
import com.fathzer.sitessupervisor.tester.Tester;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@NoArgsConstructor
@ToString
public class Configuration {
private DB database;
private Map> alerters;
private Map> testers;
@AllArgsConstructor
@Getter
@EqualsAndHashCode
private static class PluginConfig {
private C plugin;
private T config;
}
@ToString
public static class TesterPluginConfig extends PluginConfig, T> {
public TesterPluginConfig(Tester plugin, T config) {
super(plugin, config);
}
}
@ToString
public static class AlerterPluginConfig extends PluginConfig, T> {
public AlerterPluginConfig(Alerter plugin, T config) {
super(plugin, config);
}
}
@Getter
@ToString
@EqualsAndHashCode
public static class Service {
private ServiceInfo info;
private int frequencyMinutes;
private int timeOutSeconds;
private TesterPluginConfig> tester;
private Set> alerters;
Set> getAlerters() {
return this.alerters;
}
public Service(ServiceInfo info, int frequencyMinutes, int timeOutSeconds, TesterPluginConfig> tester,
Set> alerters) {
super();
if (info.getUri()==null) {
throw new IllegalArgumentException("URI should be provided");
}
if (tester==null) {
throw new IllegalArgumentException("tester is mandatory");
}
this.info = info;
this.frequencyMinutes = frequencyMinutes;
this.timeOutSeconds = timeOutSeconds;
this.tester = tester;
this.alerters = alerters;
}
}
@AllArgsConstructor
@Getter
@EqualsAndHashCode
public static class ServiceInfo {
private URI uri;
private String app;
private String env;
}
}