Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*-
  * See the file LICENSE for redistribution information.
  *
  * Copyright (c) 2002, 2013 Oracle and/or its affiliates.  All rights reserved.
  *
  */
 
 package com.sleepycat.je.config;

A JE configuration parameter with an integer value.
public class LongConfigParam extends ConfigParam {
    private static final String DEBUG_NAME = LongConfigParam.class.getName();
    private Long min;
    private Long max;
    public LongConfigParam(String configName,
                           Long minVal,
                           Long maxVal,
                           Long defaultValue,
                           boolean mutable,
                           boolean forReplication) {
        /* defaultValue must not be null. */
        super(configNamedefaultValue.toString(), mutableforReplication);
         = minVal;
         = maxVal;
    }

    
Self validate. Check mins and maxs
    private void validate(Long value)
        throws IllegalArgumentException {
        if (value != null) {
            if ( != null) {
                if (value.compareTo() < 0) {
                    throw new IllegalArgumentException
                        ( + ":" +
                         " param " +  +
                         " doesn't validate, " +
                         value +
                         " is less than min of "
                         + );
                }
            }
            if ( != null) {
                if (value.compareTo() > 0) {
                    throw new IllegalArgumentException
                        ( + ":" +
                         " param " +  +
                         " doesn't validate, " +
                         value +
                         " is greater than max "+
                         " of " +  );
                }
            }
        }
    }
    @Override
    public void validateValue(String value)
        throws IllegalArgumentException {
        try {
            validate(new Long(value));
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException
                ( + ": " +  value + " not valid value for " + );
        }
    }
New to GrepCode? Check out our FAQ X