Gridarta Editor
Range.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2023 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.model.validation.checks;
21 
26 public class Range {
27 
31  private final int min;
32 
36  private final int max;
37 
43  public Range(final int min, final int max) {
44  if (min > max) {
45  throw new IllegalArgumentException("min=" + min + " > " + max + "=" + max);
46  }
47 
48  this.min = min;
49  this.max = max;
50  }
51 
58  public boolean isWithinRange(final int value) {
59  return min <= value && value <= max;
60  }
61 
66  public int getMin() {
67  return min;
68  }
69 
74  public int getMax() {
75  return max;
76  }
77 
78 }
net.sf.gridarta.model.validation.checks.Range.isWithinRange
boolean isWithinRange(final int value)
Returns whether a given attribute value is within the valid attribute values range.
Definition: Range.java:58
net.sf.gridarta.model.validation.checks.Range.min
final int min
The minimum allowed value.
Definition: Range.java:31
net.sf.gridarta.model.validation.checks.Range.max
final int max
The maximum allowed value.
Definition: Range.java:36
net.sf.gridarta.model.validation.checks.Range.Range
Range(final int min, final int max)
Creates a new instance.
Definition: Range.java:43
net.sf.gridarta.model.validation.checks.Range
Represents a range of attribute values.
Definition: Range.java:26
net.sf.gridarta.model.validation.checks.Range.getMin
int getMin()
Returns the minimum allowed value.
Definition: Range.java:66
net.sf.gridarta.model.validation.checks.Range.getMax
int getMax()
Returns the maximum allowed value.
Definition: Range.java:74