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

com.capitalone.dashboard.model.ServiceStatus Maven / Gradle / Ivy

There is a newer version: 4.0.2
Show newest version
package com.capitalone.dashboard.model;

/**
 * Denotes the status of a product or service
 */
public enum ServiceStatus {
    Ok(200, 200),
    Warning(300, 400),
    Unauth(401, 401),
    Alert(0, 999);

	private int low;
	private int high;
	
	private ServiceStatus(int low, int high) {
		this.low = low;
		this.high = high;
	}
	
	public static ServiceStatus fromString(String value) {
        for(ServiceStatus status : ServiceStatus.values()) {
            if (status.toString().equalsIgnoreCase(value)) {
                return status;
            }
        }
        throw new IllegalArgumentException(value + " is not a valid ServiceStatus.");
    }
	
	public static ServiceStatus getServiceStatus(int statusCode) {
		for(ServiceStatus status : ServiceStatus.values()) {
			if(status.low <= statusCode && status.high >= statusCode) {
				return status;
			}
		}
		
		return Alert;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy