Java Properties Get getIntInRange(Properties props, String name, int defaultValue, int min, int max)

Here you can find the source of getIntInRange(Properties props, String name, int defaultValue, int min, int max)

Description

get Int In Range

License

Open Source License

Declaration

public static int getIntInRange(Properties props, String name, int defaultValue, int min, int max) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.*;

public class Main {
    public static int getIntInRange(Properties props, String name, int defaultValue, int min, int max) {
        int v = defaultValue;
        if (props.containsKey(name)) {
            v = Integer.valueOf(props.getProperty(name));
        }/*from   w w  w. j  a v a 2s.  co m*/
        if (v >= min && v <= max) {
            return v;
        }
        throw new IllegalArgumentException(name + " has value " + v + " which is not in the range");
    }
}

Related

  1. getBoolean(Properties props, String key)
  2. getBoolean(Properties props, String name, boolean defaultValue)
  3. getInt(Properties props, String name)
  4. getInt(Properties props, String name, int defaultValue)
  5. getIntersectionOfPropertyValues(Properties propertyFileOne, Properties propertyFileTwo)
  6. getIntProperty(Properties props, String keyword, int defaultValue)
  7. getIsB37PropertyValue(final Properties dataSourceProperties)
  8. getLocalizedProperties(String[] propertyKeys, Properties properties)
  9. getLong(Properties props, String string, long defaultV)