io.virtdata.libbasics.shared.from_long.to_int.Scale Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of virtdata-lib-realer Show documentation
Show all versions of virtdata-lib-realer Show documentation
With inspiration from other libraries
package io.virtdata.libbasics.shared.from_long.to_int;
import io.virtdata.annotations.ThreadSafeMapper;
import java.util.function.LongToIntFunction;
/**
* Scale the input to the
*/
@ThreadSafeMapper
public class Scale implements LongToIntFunction {
private final double scaleFactor;
public Scale(double scaleFactor) {
this.scaleFactor = scaleFactor;
}
@Override
public int applyAsInt(long value) {
return (int) (scaleFactor * (double) value);
}
}