Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package ch.nerdin.generators.testdata.framework;
 

Author(s):
Erik Jan de Wit
 
public class NumberGenerator implements Generator<Double> {
    private RandomUtil randomUtil;
    @Autowired
    public NumberGenerator(RandomUtil randomUtil) {
        this. = randomUtil;
    }
    public Double generate(FieldProperty property) {
        double from = property.getMinLength();
        double to = property.getMaxLength();
        if (from == 0 && to == 0) {
            return (double.nextLong();
        }
        return .randomBetween(fromto);
    }
    public boolean canGenerate(FieldProperty property) {
        return property.getType() != null && (property.getType().isPrimitive()
                || Number.class.isAssignableFrom(property.getType()));
    }
New to GrepCode? Check out our FAQ X