Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.oneandone.network.snmpman.configuration.modifier;
 
 import  lombok.Getter;
 import  org.snmp4j.smi.Counter64;

This modifier instance modifies org.snmp4j.smi.Counter64 variables.
 
public class Counter64Modifier implements VariableModifier<Counter64> {

    
The minimum allowed number for the resulting modified variable.
    @Getter private UnsignedLong minimum;

    
The maximum allowed number for the resulting modified variable.
    @Getter private UnsignedLong maximum;

    
The minimal step by which a variable will be incremented.
    @Getter private UnsignedLong minimumStep;

    
The maximal step by which a variable will be incremented.
    @Getter private UnsignedLong maximumStep;
    @Override
    public void init(final ModifierProperties properties) {
        this. = Optional.fromNullable(properties.getUnsignedLong("minimum")).or(.);
        this. = Optional.fromNullable(properties.getUnsignedLong("maximum")).or(.);
        this. = Optional.fromNullable(properties.getUnsignedLong("minimumStep")).or(.);
        this. = Optional.fromNullable(properties.getUnsignedLong("maximumStep")).or(.);
    }
    @Override
    public Counter64 modify(final Counter64 variable) {
        UnsignedLong currentValue = UnsignedLong.valueOf(variable.toString());
        if (currentValue.compareTo() < 0 || currentValue.compareTo() > 0) {
            currentValue = ;
        }
        final UnsignedLong step = UnsignedLong.valueOf((long) (Math.random() * .minus().longValue())).plus();
        final UnsignedLong newValue = currentValue.plus(step);
        return new Counter64(newValue.longValue());
    }
New to GrepCode? Check out our FAQ X