Debian Codegraph @

src/org/apache/commons/lang3/IntegerRange.java

raw symbols SCIP
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package org.apache.commons.lang3;
19
20 /**
21 * Specializes {@link NumberRange} for {@link Integer}s.
22 *
23 * <p>
24 * This class is not designed to interoperate with other NumberRanges
25 * </p>
26 *
27 * @since 3.13.0
28 */
29 public final class IntegerRange extends NumberRange<Integer> {
30
31 private static final long serialVersionUID = 1L;
32
33 /**
34 * Creates a range with the specified minimum and maximum values (both inclusive).
35 *
36 * <p>
37 * The range uses the natural ordering of the elements to determine where values lie in the range.
38 * </p>
39 *
40 * <p>
41 * The arguments may be passed in the order (min,max) or (max,min). The getMinimum and getMaximum methods will return the correct values.
42 * </p>
43 *
44 * @param fromInclusive the first value that defines the edge of the range, inclusive.
45 * @param toInclusive the second value that defines the edge of the range, inclusive.
46 * @return the range object, not null.
47 */
48 public static IntegerRange of(final int fromInclusive, final int toInclusive) {
49 return of(Integer.valueOf(fromInclusive), Integer.valueOf(toInclusive));
50 }
51
52 /**
53 * Creates a range with the specified minimum and maximum values (both inclusive).
54 *
55 * <p>
56 * The range uses the natural ordering of the elements to determine where values lie in the range.
57 * </p>
58 *
59 * <p>
60 * The arguments may be passed in the order (min,max) or (max,min). The getMinimum and getMaximum methods will return the correct values.
61 * </p>
62 *
63 * @param fromInclusive the first value that defines the edge of the range, inclusive.
64 * @param toInclusive the second value that defines the edge of the range, inclusive.
65 * @return the range object, not null.
66 * @throws IllegalArgumentException if either element is null.
67 */
68 public static IntegerRange of(final Integer fromInclusive, final Integer toInclusive) {
69 return new IntegerRange(fromInclusive, toInclusive);
70 }
71
72 /**
73 * Creates an instance.
74 *
75 * @param number1 the first element, not null
76 * @param number2 the second element, not null
77 * @throws NullPointerException when element1 is null.
78 * @throws NullPointerException when element2 is null.
79 */
80 private IntegerRange(final Integer number1, final Integer number2) {
81 super(number1, number2, null);
82 }
83
84 }