brooklyn.util.math.MathFunctions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of brooklyn-utils-common Show documentation
Show all versions of brooklyn-utils-common Show documentation
Utility classes and methods developed for Brooklyn but not dependendent on Brooklyn or much else
package brooklyn.util.math;
import javax.annotation.Nullable;
import com.google.common.base.Function;
public class MathFunctions {
public static Function divide(final double divisor) {
return new Function() {
public Double apply(@Nullable Number input) {
if (input==null) return null;
return input.doubleValue() / divisor;
}
};
}
public static Function divide(final Function input, final double divisor) {
return new Function() {
public Double apply(@Nullable T input2) {
Number n = input.apply(input2);
if (n==null) return null;
return n.doubleValue() / divisor;
}
};
}
}