public boolean process() { if (currentTime() >= lastTime() + getDelay()) { this.time = currentTime(); return true; } return false; }
public void setSaltRounds(int saltRounds) { XApi.require(saltRounds >= 4 && saltRounds <= 30, "Illegal salt rounds: " + saltRounds + "; expected to be between 4 and 30, inclusive"); this.saltRounds = saltRounds; } }
public NumberFormatter(int fractionalDigits, char splitter) { setFractionalDigits(fractionalDigits); setSplitter(splitter); }
@Nonnull public static StackWalk caller(int offset) { offset += 2; Throwable throwable = new Throwable().fillInStackTrace(); StackTraceElement[] trace = throwable.getStackTrace(); XApi.require(offset < trace.length, "Stack trace size (" + (trace.length - 2) + ") too small for specified offset"); StackTraceElement element = trace[offset]; return new StackWalk(element); }
public AbstractLogger() { this(StackWalk.caller().getClassName()); }
public void restart() { this.time = currentTime(); }
public static void require(boolean condition, @Nonnull String message) throws IllegalArgumentException { if (!condition) { raise(message); } }
@Nonnull public static StackWalk self() { return caller(0); } }
public static void requireState(boolean condition, @Nonnull String message) throws IllegalStateException { if (!condition) { raiseState(message); } }
@Nonnull public static <E> E requireStateNonNull(@Nonnull E object, @Nonnull String objectName) throws IllegalStateException { requireState(object != null, objectName + " cannot be null"); return object; } }
public void setReadTimeout(int timeout) { XApi.require(timeout >= 0, "Timeout cannot be negative"); this.readTimeout = timeout; }
public void setInitialBufferCapacity(int initialBufferCapacity) { XApi.require(initialBufferCapacity > 0, "initialBufferCapacity must be greater than zero"); this.initialBufferCapacity = initialBufferCapacity; } }
@Override public void seek(long position) throws IOException { XApi.require(position >= 0 && position < array.length, "Position out of array bounds"); this.position = (int) position; }
public Bytes(long bytes) { XApi.require(bytes >= 0L, "Byte amount cannot be negative"); this.bytes = bytes; }
public void setConnectTimeout(int timeout) { XApi.require(timeout >= 0, "Timeout cannot be negative"); this.connectTimeout = timeout; }
@Nonnull public static <E> E requireNonNull(@Nonnull E object, @Nonnull String objectName) throws IllegalArgumentException { require(object != null, objectName + " cannot be null"); return object; }
public double nextDouble(double minValue, double maxValue) { XApi.require(minValue <= maxValue, "maxValue must be greater than minValue"); if (minValue == maxValue) { return minValue; } double bound = maxValue - minValue + 1.0D; double result = nextDouble(bound); return minValue + result; }
public long nextLong(long minValue, long maxValue) { XApi.require(minValue <= maxValue, "maxValue must be greater than minValue"); if (minValue == maxValue) { return minValue; } long bound = maxValue - minValue + 1; long result = nextLong(bound); return minValue + result; }
public void write(long data, int bitCount) throws IOException { XApi.require(bitCount <= 64, "bitCount must be equal or less than 64"); for (int i = 0; i < bitCount; i++) { write1(((data >> i) & 0x1) == 0x1); } }
@Override public synchronized void reset() throws IOException { XApi.require(markedChar >= 0, markedChar == INVALIDATED ? "Invalid mark" : "Reader not marked"); ensureOpen(); this.nextChar = markedChar; this.skipLF = markedSkipLF; }