@@ -0,0 +1,2419 @@
+/**********************************************************************%0ACopyright (c) 2009-2010 Alexander Kerner. All rights reserved.%0ALicensed under the Apache License, Version 2.0 (the %22License%22);%0Ayou may not use this file except in compliance with the License.%0AYou may obtain a copy of the License at%0A%0A    http://www.apache.org/licenses/LICENSE-2.0%0A%0AUnless required by applicable law or agreed to in writing, software%0Adistributed under the License is distributed on an %22AS IS%22 BASIS,%0AWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0ASee the License for the specific language governing permissions and%0Alimitations under the License.%0A ***********************************************************************/%0A%0Apackage net.sf.jranges.range.integer;%0A%0A/**%0A * %0A * Most abstract prototype implementation for %7B@link IntegerRange%7D.%0A * %0A *%0A * @author %3Ca href=%22mailto:alex.kerner.24@googlemail.com%22%3EAlexander Kerner%3C/a%3E%0A * @version 2010-12-08%0A *%0A */%0Apublic abstract class VeryAbstractIntegerRange implements IntegerRange %7B%0A%0A%09private volatile int hashCode;%0A%0A%09// Override //%0A%0A%09@Override%0A%09public String toString() %7B%0A%09%09return getStart() + %22-%22 + getStop();%0A%09%7D%0A%0A%09@Override%0A%09public int hashCode() %7B%0A%09%09int result = hashCode;%0A%09%09if (result == 0) %7B%0A%09%09%09final int prime = 31;%0A%09%09%09result = 1;%0A%09%09%09result = prime * result + getStart();%0A%09%09%09result = prime * result + getStop();%0A%09%09%09result = prime * result + getInterval();%0A%09%09%09hashCode = result;%0A%09%09%7D%0A%09%09return result;%0A%09%7D%0A%09%0A%09@Override%0A%09public boolean equals(Object obj) %7B%0A%09%09if (this == obj)%0A%09%09%09return true;%0A%09%09if (obj == null)%0A%09%09%09return false;%0A%09%09if (!(obj instanceof IntegerRange))%0A%09%09%09return false;%0A%09%09IntegerRange other = (IntegerRange) obj;%0A%09%09if (getStart() != other.getStart())%0A%09%09%09return false;%0A%09%09if (getStop() != other.getStop())%0A%09%09%09return false;%0A%09%09if (getInterval() != other.getInterval())%0A%09%09%09return false;%0A%09%09return true;%0A%09%7D%0A%09%0A%09// Implement //%0A%09%0A%09/**%0A%09 * %0A%09 */%0A%09public int getLength() %7B%0A%09%09return getStop() - getStart() + 1;%0A%09%7D%0A%09%0A%09/**%0A%09 * %0A%09 */%0A%09public int getInterval() %7B%0A%09%09return 1;%0A%09%7D%0A%09%0A%09/**%0A%09 * Compares this %7B@code IntegerRange%7D to given %7B@code IntegerRange%7D by %7B@link #getStart()%7D%0A%09 * .%0A%09 */%0A%09public int compareTo(IntegerRange o) %7B%0A%09%09return Integer.valueOf(getStart()).compareTo(%0A%09%09%09%09Integer.valueOf(o.getStart()));%0A%09%7D%0A%0A%09/**%0A%09 * %0A%09 */%0A%09public boolean includes(int position) %7B%0A%09%09if (getStart() %3C= position && getStop() %3E= position)%0A%09%09%09return true;%0A%09%09return false;%0A%09%7D%0A%0A%7D%0A

Introduce VeryAbstractIntegerRange.