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

org.zodiac.monitor.reload.model.HealthCheckResultOld Maven / Gradle / Ivy

package org.zodiac.monitor.reload.model;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Objects;

import org.zodiac.core.application.AppInstanceStatus;

public class HealthCheckResultOld implements Serializable {

    private static final long serialVersionUID = 8886932821489169380L;
    private static final String SERVER_TIME = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
    private static final String FORMATTER = "{\"appInstanceStatus\":\"%s\",\"data\": %s,\"serverTime\":\"%s\"}";

    private AppInstanceStatus appInstanceStatus;
    private String data;

    public HealthCheckResultOld() {
        this(AppInstanceStatus.UP);
    }

    public HealthCheckResultOld(AppInstanceStatus appInstanceStatus) {
        this.appInstanceStatus = appInstanceStatus;
    }

    public AppInstanceStatus getAppInstanceStatus() {
        return appInstanceStatus;
    }

    public HealthCheckResultOld setAppInstanceStatus(AppInstanceStatus serviceStatus) {
        this.appInstanceStatus = serviceStatus;
        return this;
    }

    public HealthCheckResultOld setData(String jsonData) {
        this.data = jsonData;
        return this;
    }

    public String getDate() {
        return this.data;
    }

    public AppInstanceStatus getHttpStatus() {
        if (AppInstanceStatus.UP.equals(getAppInstanceStatus())) {
            return AppInstanceStatus.UP;
        }
        return AppInstanceStatus.DOWN;
    }

    @Override
    public int hashCode() {
        return Objects.hash(appInstanceStatus, data);
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        HealthCheckResultOld other = (HealthCheckResultOld)obj;
        return appInstanceStatus == other.appInstanceStatus && Objects.equals(data, other.data);
    }

    @Override
    public String toString() {
        return String.format(FORMATTER, appInstanceStatus.getText(), data, SERVER_TIME);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy