org.apache.commons.lang.math.IntRange Java Examples

The following examples show how to use org.apache.commons.lang.math.IntRange. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DataGenerator.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args)
    throws IOException {
  final String[] columns = {"column1", "column2", "column3", "column4", "column5"};
  final Map<String, DataType> dataTypes = new HashMap<>();
  final Map<String, FieldType> fieldTypes = new HashMap<>();
  final Map<String, TimeUnit> timeUnits = new HashMap<>();

  final Map<String, Integer> cardinality = new HashMap<>();
  final Map<String, IntRange> range = new HashMap<>();
  final Map<String, Map<String, Object>> template = new HashMap<>();

  for (final String col : columns) {
    dataTypes.put(col, DataType.INT);
    fieldTypes.put(col, FieldType.DIMENSION);
    cardinality.put(col, 1000);
  }
  final DataGeneratorSpec spec =
      new DataGeneratorSpec(Arrays.asList(columns), cardinality, range, template, dataTypes, fieldTypes, timeUnits,
          FileFormat.AVRO, "/tmp/out", true);

  final DataGenerator gen = new DataGenerator();
  gen.init(spec);
  gen.generateAvro(1000000L, 2);
}
 
Example #2
Source File: DataGeneratorSpec.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
public DataGeneratorSpec(List<String> columns, Map<String, Integer> cardinalityMap, Map<String, IntRange> rangeMap,
    Map<String, Map<String, Object>> patternMap, Map<String, DataType> dataTypesMap, Map<String, FieldType> fieldTypesMap, Map<String, TimeUnit> timeUnitMap,
    FileFormat format, String outputDir, boolean override) {
  this.columns = columns;
  this.cardinalityMap = cardinalityMap;
  this.rangeMap = rangeMap;
  this.patternMap = patternMap;

  outputFileFormat = format;
  this.outputDir = outputDir;
  overrideOutDir = override;

  this.dataTypesMap = dataTypesMap;
  this.fieldTypesMap = fieldTypesMap;
  this.timeUnitMap = timeUnitMap;
}
 
Example #3
Source File: GenerateDataCommand.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
private void buildCardinalityRangeMaps(String file, HashMap<String, Integer> cardinality,
    HashMap<String, IntRange> range, Map<String, Map<String, Object>> pattern)
    throws IOException {
  if (file == null) {
    return; // Nothing to do here.
  }

  List<SchemaAnnotation> saList = JsonUtils.fileToList(new File(file), SchemaAnnotation.class);

  for (SchemaAnnotation sa : saList) {
    String column = sa.getColumn();

    if (sa.isRange()) {
      range.put(column, new IntRange(sa.getRangeStart(), sa.getRangeEnd()));
    } else if (sa.getPattern() != null) {
      pattern.put(column, sa.getPattern());
    } else {
      cardinality.put(column, sa.getCardinality());
    }
  }
}
 
Example #4
Source File: ParamUtilsUnitTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testInRangeSuccess(){
    Assert.assertTrue(4 == ParamUtils.inRange(4L, 3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(4 == ParamUtils.inRange(4, 3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(4 == ParamUtils.inRange(new IntRange(3, 6), 4, "error"));
    Assert.assertTrue(4.1 == ParamUtils.inRange(4.1, 3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(4.1 == ParamUtils.inRange(4.1, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(4.1 == ParamUtils.inRange(new DoubleRange(-3, 6), 4.1, "error"));
    Assert.assertTrue(0 == ParamUtils.inRange(0L, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(0 == ParamUtils.inRange(0, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(0 == ParamUtils.inRange(new IntRange(-3, 6), 0, "error"));
    Assert.assertTrue(0.0 == ParamUtils.inRange(0.0, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(0.0 == ParamUtils.inRange(new DoubleRange(-3, 6), 0.0, "error"));
    Assert.assertTrue(0 == ParamUtils.inRange(0L, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(0 == ParamUtils.inRange(0, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(0 == ParamUtils.inRange(new IntRange(-3, 6), 0, "error"));
    Assert.assertTrue(-1 == ParamUtils.inRange(-1L, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(-1 == ParamUtils.inRange(-1, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(-1 == ParamUtils.inRange(new IntRange(-3, 6), -1, "error"));
    Assert.assertTrue(-1.5 == ParamUtils.inRange(-1.5, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(-1.5 == ParamUtils.inRange(new DoubleRange(-3, 6), -1.5, "error"));
}
 
Example #5
Source File: AdminUserManagement.java    From CodeDefenders with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static String generatePW() {
    int length = AdminDAO.getSystemSetting(AdminSystemSettings.SETTING_NAME.MIN_PASSWORD_LENGTH).getIntValue();

    StringBuilder sb = new StringBuilder();
    char[] initialSet = LOWER;

    Random random = new Random();
    for (int i = 0; i < length; i++) {
        sb.append(initialSet[random.nextInt(initialSet.length)]);
    }
    char[] resultChars = sb.toString().toCharArray();

    List<Integer> randomInts = Arrays.stream(new IntRange(0, length - 1).toArray()).boxed().collect(Collectors.toList());
    Collections.shuffle(randomInts);

    int c = 0;
    resultChars[randomInts.get(c)] = Character.toUpperCase(resultChars[randomInts.get(c)]);
    resultChars[randomInts.get(++c)] = PUNCTUATION[random.nextInt(PUNCTUATION.length)];
    resultChars[randomInts.get(++c)] = DIGITS[random.nextInt(DIGITS.length)];

    return new String(resultChars);
}
 
Example #6
Source File: CreatePanelOfNormalsIntegrationTest.java    From gatk-protected with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void assertBasicPoNAssumptions(final File ponFile, final File initialTargetsFileUsedToCreatePoN) {
    try (final HDF5File ponHDF5File = new HDF5File(ponFile)) {
        final HDF5PCACoveragePoN pon = new HDF5PCACoveragePoN(ponHDF5File);

        Assert.assertTrue(pon.getTargets().size() >= pon.getPanelTargets().size());
        Assert.assertTrue(pon.getRawTargets().size() > pon.getTargets().size());

        Assert.assertTrue(pon.getTargetNames().size() == pon.getTargets().size());
        Assert.assertTrue(pon.getPanelTargetNames().size() == pon.getPanelTargetNames().size());
        Assert.assertTrue(pon.getRawTargetNames().size() == pon.getRawTargetNames().size());

        if (initialTargetsFileUsedToCreatePoN != null) {
            final TargetCollection<Target> tc = TargetArgumentCollection.readTargetCollection(initialTargetsFileUsedToCreatePoN);
            Assert.assertEquals(pon.getRawTargets().size(), tc.targetCount());

            // Check that the raw targets are the same
            Assert.assertTrue(IntStream.of(new IntRange(0, pon.getRawTargets().size()-1).toArray()).boxed().map(i -> pon.getRawTargets().get(i).equals(tc.target(i))).allMatch(t -> t));
        }
    }
}
 
Example #7
Source File: ParamUtilsUnitTest.java    From gatk-protected with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testInRangeSuccess(){
    Assert.assertTrue(4 == ParamUtils.inRange(4L, 3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(4 == ParamUtils.inRange(4, 3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(4 == ParamUtils.inRange(new IntRange(3, 6), 4, "error"));
    Assert.assertTrue(4.1 == ParamUtils.inRange(4.1, 3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(4.1 == ParamUtils.inRange(4.1, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(4.1 == ParamUtils.inRange(new DoubleRange(-3, 6), 4.1, "error"));
    Assert.assertTrue(0 == ParamUtils.inRange(0L, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(0 == ParamUtils.inRange(0, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(0 == ParamUtils.inRange(new IntRange(-3, 6), 0, "error"));
    Assert.assertTrue(0.0 == ParamUtils.inRange(0.0, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(0.0 == ParamUtils.inRange(new DoubleRange(-3, 6), 0.0, "error"));
    Assert.assertTrue(0 == ParamUtils.inRange(0L, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(0 == ParamUtils.inRange(0, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(0 == ParamUtils.inRange(new IntRange(-3, 6), 0, "error"));
    Assert.assertTrue(-1 == ParamUtils.inRange(-1L, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(-1 == ParamUtils.inRange(-1, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(-1 == ParamUtils.inRange(new IntRange(-3, 6), -1, "error"));
    Assert.assertTrue(-1.5 == ParamUtils.inRange(-1.5, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(-1.5 == ParamUtils.inRange(new DoubleRange(-3, 6), -1.5, "error"));
}
 
Example #8
Source File: SplitSelectorExtractorTest.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Test
public void rangeTest2() {
    SplitSelectorExtractor extractor = new SplitSelectorExtractor();
    List<IntRange> useSplitRanges = extractor.parseUseSplitsRanges("0-2,4");
    Assert.assertTrue(extractor.useSplit(useSplitRanges, 2));
    Assert.assertFalse(extractor.useSplit(useSplitRanges, 3));
    Assert.assertTrue(extractor.useSplit(useSplitRanges, 4));
}
 
Example #9
Source File: DataGenerator.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
public void init(DataGeneratorSpec spec)
    throws IOException {
  genSpec = spec;
  outDir = new File(genSpec.getOutputDir());
  if (outDir.exists() && !genSpec.isOverrideOutDir()) {
    LOGGER.error("output directory already exists, and override is set to false");
    throw new RuntimeException("output directory exists");
  }

  if (outDir.exists()) {
    FileUtils.deleteDirectory(outDir);
  }

  outDir.mkdir();

  for (final String column : genSpec.getColumns()) {
    DataType dataType = genSpec.getDataTypesMap().get(column);

    if (genSpec.getPatternMap().containsKey(column)) {
      generators.put(column,
              GeneratorFactory.getGeneratorFor(
                      PatternType.valueOf(genSpec.getPatternMap().get(column).get("type").toString()),
                      genSpec.getPatternMap().get(column)));

    } else if (genSpec.getCardinalityMap().containsKey(column)) {
      generators.put(column, GeneratorFactory.getGeneratorFor(dataType, genSpec.getCardinalityMap().get(column)));

    } else if (genSpec.getRangeMap().containsKey(column)) {
      IntRange range = genSpec.getRangeMap().get(column);
      generators.put(column,
              GeneratorFactory.getGeneratorFor(dataType, range.getMinimumInteger(), range.getMaximumInteger()));

    } else {
      LOGGER.error("cardinality for this column does not exist : " + column);
      throw new RuntimeException("cardinality for this column does not exist");
    }

    generators.get(column).init();
  }
}
 
Example #10
Source File: GenerateDataCommand.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
private DataGeneratorSpec buildDataGeneratorSpec(Schema schema, List<String> columns,
    HashMap<String, DataType> dataTypes, HashMap<String, FieldType> fieldTypes, HashMap<String, TimeUnit> timeUnits,
    HashMap<String, Integer> cardinality, HashMap<String, IntRange> range, HashMap<String, Map<String, Object>> pattern) {
  for (final FieldSpec fs : schema.getAllFieldSpecs()) {
    String col = fs.getName();

    columns.add(col);
    dataTypes.put(col, fs.getDataType());
    fieldTypes.put(col, fs.getFieldType());

    switch (fs.getFieldType()) {
      case DIMENSION:
        if (cardinality.get(col) == null) {
          cardinality.put(col, 1000);
        }
        break;

      case METRIC:
        if (!range.containsKey(col)) {
          range.put(col, new IntRange(1, 1000));
        }
        break;

      case TIME:
        if (!range.containsKey(col)) {
          range.put(col, new IntRange(1, 1000));
        }
        TimeFieldSpec tfs = (TimeFieldSpec) fs;
        timeUnits.put(col, tfs.getIncomingGranularitySpec().getTimeType());
        break;

      default:
        throw new RuntimeException("Invalid field type.");
    }
  }

  return new DataGeneratorSpec(columns, cardinality, range, pattern, dataTypes, fieldTypes, timeUnits, FileFormat.AVRO,
      _outDir, _overwrite);
}
 
Example #11
Source File: GenerateDataCommand.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
@Override
public boolean execute()
    throws Exception {
  LOGGER.info("Executing command: " + toString());

  if ((_numRecords < 0) || (_numFiles < 0)) {
    throw new RuntimeException("Cannot generate negative number of records/files.");
  }

  Schema schema = Schema.fromFile(new File(_schemaFile));

  List<String> columns = new LinkedList<>();
  final HashMap<String, DataType> dataTypes = new HashMap<>();
  final HashMap<String, FieldType> fieldTypes = new HashMap<>();
  final HashMap<String, TimeUnit> timeUnits = new HashMap<>();

  final HashMap<String, Integer> cardinality = new HashMap<>();
  final HashMap<String, IntRange> range = new HashMap<>();
  final HashMap<String, Map<String, Object>> pattern = new HashMap<>();

  buildCardinalityRangeMaps(_schemaAnnFile, cardinality, range, pattern);

  final DataGeneratorSpec spec =
      buildDataGeneratorSpec(schema, columns, dataTypes, fieldTypes, timeUnits, cardinality, range, pattern);

  final DataGenerator gen = new DataGenerator();
  gen.init(spec);

  if (FORMAT_AVRO.equals(_format)) {
    gen.generateAvro(_numRecords, _numFiles);
  } else if (FORMAT_CSV.equals(_format)) {
    gen.generateCsv(_numRecords, _numFiles);
  } else {
    throw new IllegalArgumentException(String.format("Invalid output format '%s'", _format));
  }

  return true;
}
 
Example #12
Source File: DataTensorBlock.java    From systemds with Apache License 2.0 5 votes vote down vote up
public DataTensorBlock(ValueType vt, int[] dims) {
	_dims = dims;
	_schema = new ValueType[getDim(1)];
	Arrays.fill(_schema, vt);
	_colsToIx = new IntRange(0, getDim(1)).toArray();
	_ixToCols = new int[VALID_VALUE_TYPES_LENGTH][];
	_ixToCols[vt.ordinal()] = new IntRange(0, getDim(1)).toArray();
	reset();
}
 
Example #13
Source File: ForwardBackwardAlgorithm.java    From gatk-protected with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private ArrayResult(final List<D> data, final List<T> positions,
                    final HMM<D, T, S> model,
                    final double[][] logForwardProbabilities,
                    final double[][] logBackwardProbabilities) {
    this.data = Collections.unmodifiableList(new ArrayList<>(data));
    this.positions = Collections.unmodifiableList(new ArrayList<>(positions));
    positionIndexRange = new IntRange(0, positions.size() - 1);
    this.model = model;
    positionIndex = composeIndexMap(this.positions);
    stateIndex = composeIndexMap(model.hiddenStates());
    this.logBackwardProbabilities = logBackwardProbabilities;
    this.logForwardProbabilities = logForwardProbabilities;
    logDataLikelihood = calculateLogDataLikelihood(logForwardProbabilities, logBackwardProbabilities);
}
 
Example #14
Source File: CraftGroup.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public ItemRaceEntry[] getRewards(Integer skillId, Integer skillPoints) {
	if (!dataHolder.containsKey(skillId)) {
		return new ItemRaceEntry[0];
	}
	List<ItemRaceEntry> result = new ArrayList<ItemRaceEntry>();
	for (Entry<IntRange, List<CraftReward>> entry : dataHolder.get(skillId).entrySet()) {
		if (!entry.getKey().containsInteger(skillPoints)) {
			continue;
		}
		result.addAll(entry.getValue());
	}
	return result.toArray(new ItemRaceEntry[0]);
}
 
Example #15
Source File: ItemGroupsData.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
void MapCraftReward(FastMap<Integer, FastMap<IntRange, List<CraftReward>>> dataHolder, CraftReward reward) {
	FastMap<IntRange, List<CraftReward>> ranges;
	int lowerBound = 0, upperBound = 0;

	if (reward instanceof CraftRecipe) {
		CraftRecipe recipe = (CraftRecipe) reward;
		lowerBound = recipe.getLevel();
		upperBound = lowerBound + RECIPE_UPPER;
		if (upperBound / 100 != lowerBound / 100) {
			upperBound = lowerBound / 100 + 99;
		}
	}
	else {
		CraftItem item = (CraftItem) reward;
		lowerBound = item.getMinLevel();
		upperBound = item.getMaxLevel();
	}

	IntRange range = new IntRange(lowerBound, upperBound);

	if (dataHolder.containsKey(reward.getSkill())) {
		ranges = dataHolder.get(reward.getSkill());
	}
	else {
		ranges = new FastMap<IntRange, List<CraftReward>>();
		dataHolder.put(reward.getSkill(), ranges);
	}

	List<CraftReward> items;
	if (ranges.containsKey(range)) {
		items = ranges.get(range);
	}
	else {
		items = new ArrayList<CraftReward>();
		ranges.put(range, items);
	}
	items.add(reward);
}
 
Example #16
Source File: DataTensorBlock.java    From systemds with Apache License 2.0 5 votes vote down vote up
public DataTensorBlock(ValueType vt, int[] dims) {
	_dims = dims;
	_schema = new ValueType[getDim(1)];
	Arrays.fill(_schema, vt);
	_colsToIx = new IntRange(0, getDim(1)).toArray();
	_ixToCols = new int[VALID_VALUE_TYPES_LENGTH][];
	_ixToCols[vt.ordinal()] = new IntRange(0, getDim(1)).toArray();
	reset();
}
 
Example #17
Source File: SplitSelectorExtractorTest.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Test
public void rangeTest6() {
    SplitSelectorExtractor extractor = new SplitSelectorExtractor();
    List<IntRange> useSplitRanges = extractor.parseUseSplitsRanges("0");
    Assert.assertTrue(extractor.useSplit(useSplitRanges, 0));
    Assert.assertFalse(extractor.useSplit(useSplitRanges, 1));
}
 
Example #18
Source File: SplitSelectorExtractorTest.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Test
public void rangeTest5() {
    SplitSelectorExtractor extractor = new SplitSelectorExtractor();
    List<IntRange> useSplitRanges = extractor.parseUseSplitsRanges(" 2, 4 , 6- ");
    Assert.assertTrue(extractor.useSplit(useSplitRanges, 2));
    Assert.assertFalse(extractor.useSplit(useSplitRanges, 3));
    Assert.assertTrue(extractor.useSplit(useSplitRanges, 4));
    Assert.assertFalse(extractor.useSplit(useSplitRanges, 5));
    Assert.assertTrue(extractor.useSplit(useSplitRanges, 6));
    Assert.assertTrue(extractor.useSplit(useSplitRanges, 100));
    Assert.assertTrue(extractor.useSplit(useSplitRanges, 1000));
}
 
Example #19
Source File: SplitSelectorExtractorTest.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Test
public void rangeTest4() {
    SplitSelectorExtractor extractor = new SplitSelectorExtractor();
    List<IntRange> useSplitRanges = extractor.parseUseSplitsRanges("2,4,6-");
    Assert.assertTrue(extractor.useSplit(useSplitRanges, 2));
    Assert.assertFalse(extractor.useSplit(useSplitRanges, 3));
    Assert.assertTrue(extractor.useSplit(useSplitRanges, 4));
    Assert.assertFalse(extractor.useSplit(useSplitRanges, 5));
    Assert.assertTrue(extractor.useSplit(useSplitRanges, 6));
    Assert.assertTrue(extractor.useSplit(useSplitRanges, 100));
    Assert.assertTrue(extractor.useSplit(useSplitRanges, 1000));
}
 
Example #20
Source File: SplitSelectorExtractorTest.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Test
public void rangeTest3() {
    SplitSelectorExtractor extractor = new SplitSelectorExtractor();
    List<IntRange> useSplitRanges = extractor.parseUseSplitsRanges("2,4");
    Assert.assertTrue(extractor.useSplit(useSplitRanges, 2));
    Assert.assertFalse(extractor.useSplit(useSplitRanges, 3));
    Assert.assertTrue(extractor.useSplit(useSplitRanges, 4));
}
 
Example #21
Source File: SplitSelectorExtractorTest.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Test
public void rangeTest1() {
    SplitSelectorExtractor extractor = new SplitSelectorExtractor();
    List<IntRange> useSplitRanges = extractor.parseUseSplitsRanges("0-2");
    Assert.assertTrue(extractor.useSplit(useSplitRanges, 0));
    Assert.assertTrue(extractor.useSplit(useSplitRanges, 1));
    Assert.assertTrue(extractor.useSplit(useSplitRanges, 2));
    Assert.assertFalse(extractor.useSplit(useSplitRanges, 3));
}
 
Example #22
Source File: ParamUtilsUnitTest.java    From gatk-protected with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test(expectedExceptions = IllegalArgumentException.class)
public void testInRangeFailureAllPositiveIntRange(){
    ParamUtils.inRange(new IntRange(7, 10), 4, "Range calculation did not work properly");
}
 
Example #23
Source File: CraftGroup.java    From aion-germany with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @return the dataHolder
 */
public FastMap<Integer, FastMap<IntRange, List<CraftReward>>> getDataHolder() {
	return dataHolder;
}
 
Example #24
Source File: ParamUtilsUnitTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test(expectedExceptions = IllegalArgumentException.class)
public void testInRangeFailureAllPositiveIntRange(){
    ParamUtils.inRange(new IntRange(7, 10), 4, "Range calculation did not work properly");
}
 
Example #25
Source File: DataGeneratorSpec.java    From incubator-pinot with Apache License 2.0 4 votes vote down vote up
public Map<String, IntRange> getRangeMap() {
  return rangeMap;
}
 
Example #26
Source File: ParamUtils.java    From gatk-protected with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * Validates the value of a parameter.
 * <p>
 * An invalid value will result in an {@link IllegalArgumentException}.
 * </p>
 *
 * @param validRange the valid range for the parameter value.
 * @param value the parameter value itself.
 * @param definition a human friendly description of the parameter to be used in an explanatory exception.
 * @return the input value.
 * @throws IllegalArgumentException if the value provided is in-valid.
 */
public static int inRange(final IntRange validRange, final int value, final String definition) {
    Utils.nonNull(validRange);
    if (!validRange.containsInteger(value)) {
        final String prefix = definition == null ? "invalid value" : "invalid value for " + definition;
        throw new IllegalArgumentException(String.format("%s: %d is not in [%d, %d]",
                prefix, value, validRange.getMinimumInteger(), validRange.getMaximumInteger()));
    }
    return value;
}
 
Example #27
Source File: ParamUtils.java    From gatk with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * Validates the value of a parameter.
 * <p>
 * An invalid value will result in an {@link IllegalArgumentException}.
 * </p>
 *
 * @param validRange the valid range for the parameter value.
 * @param value the parameter value itself.
 * @param definition a human friendly description of the parameter to be used in an explanatory exception.
 * @return the input value.
 * @throws IllegalArgumentException if the value provided is in-valid.
 */
public static int inRange(final IntRange validRange, final int value, final String definition) {
    Utils.nonNull(validRange);
    if (!validRange.containsInteger(value)) {
        final String prefix = definition == null ? "invalid value" : "invalid value for " + definition;
        throw new IllegalArgumentException(String.format("%s: %d is not in [%d, %d]",
                prefix, value, validRange.getMinimumInteger(), validRange.getMaximumInteger()));
    }
    return value;
}
 
Example #28
Source File: CraftGroup.java    From aion-germany with GNU General Public License v3.0 2 votes vote down vote up
/**
 * @param dataHolder
 *            the dataHolder to set
 */
public void setDataHolder(FastMap<Integer, FastMap<IntRange, List<CraftReward>>> dataHolder) {
	this.dataHolder = dataHolder;
}