com.google.security.fences.util.CountingIterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fences-maven-enforcer-rule Show documentation
Show all versions of fences-maven-enforcer-rule Show documentation
Augments Java's access control by checking that a Maven Project and all its
dependencies conform to a policy that specifies which classes/packages can
link to which others.
package com.google.security.fences.util;
import java.util.Iterator;
import com.google.common.base.Preconditions;
/**
* A single enumeration over a {@link CountingIterator}.
*/
public final class CountingIterator implements Iterator {
private int i;
private final int rightExclusive;
CountingIterator(int leftInclusive, int rightExclusive) {
Preconditions.checkArgument(leftInclusive <= rightExclusive);
this.i = leftInclusive;
this.rightExclusive = rightExclusive;
}
@Override
public synchronized String toString() {
return "[" + i + ".." + rightExclusive + ")";
}
public synchronized boolean hasNext() {
return i < rightExclusive;
}
public synchronized Integer next() {
if (i >= rightExclusive) {
throw new IndexOutOfBoundsException(i + " >= " + rightExclusive);
}
return i++;
}
public void remove() {
throw new UnsupportedOperationException();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy