![JAR search and dependency download from the Maven repository](/logo.png)
com.soulgalore.velocity.sitespeed.Rule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xml-velocity Show documentation
Show all versions of xml-velocity Show documentation
Merge a XML file with a Velocity template
The newest version!
package com.soulgalore.velocity.sitespeed;
public class Rule {
private final double yellowLimit;
private final double greenLimit;
private final String name;
private final Type type;
public Rule(String name, Type type, double green, double yellow) {
this.yellowLimit = yellow;
this.greenLimit = green;
this.name = name;
this.type = type;
}
public String getColor(double value) {
if (type.equals(Type.GREATER_THAN)) {
if (value > greenLimit)
return Color.GREEN.toString();
else if (value > yellowLimit)
return Color.YELLOW.toString();
else
return Color.RED.toString();
} else {
if (value < greenLimit)
return Color.GREEN.toString();
else if (value < yellowLimit)
return Color.YELLOW.toString();
else
return Color.RED.toString();
}
}
public double getYellowLimit() {
return yellowLimit;
}
public double getGreenLimit() {
return greenLimit;
}
public Type getType() {
return type;
}
public String getName() {
return name;
}
public enum Type {
GREATER_THAN("greater than"), LESS_THAN("less than");
private final String friendlyName;
Type(String friendlyName) {
this.friendlyName = friendlyName;
}
public String getFriendlyName() {
return friendlyName;
}
public Type getOpposite() {
if (this.equals(GREATER_THAN))
return LESS_THAN;
else
return GREATER_THAN;
}
}
public enum Color {
RED, YELLOW, GREEN
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy