io.virtdata.basicsmappers.from_long.to_long.FixedValues Maven / Gradle / Ivy
package io.virtdata.basicsmappers.from_long.to_long;
import io.virtdata.annotations.ThreadSafeMapper;
import java.util.function.LongUnaryOperator;
@ThreadSafeMapper
public class FixedValues implements LongUnaryOperator {
private final long[] fixedValues;
public FixedValues(long... values) {
this.fixedValues = values;
}
@Override
public long applyAsLong(long value) {
int index = (int)(value % Integer.MAX_VALUE) % fixedValues.length;
return fixedValues[index];
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy