Refine search
ChecksumHashFunction( ImmutableSupplier<? extends Checksum> checksumSupplier, int bits, String toString) { this.checksumSupplier = checkNotNull(checksumSupplier); checkArgument(bits == 32 || bits == 64, "bits (%s) must be either 32 or 64", bits); this.bits = bits; this.toString = checkNotNull(toString); }
SeparatedBaseEncoding(BaseEncoding delegate, String separator, int afterEveryChars) { this.delegate = checkNotNull(delegate); this.separator = checkNotNull(separator); this.afterEveryChars = afterEveryChars; checkArgument( afterEveryChars > 0, "Cannot add a separator after every %s chars", afterEveryChars); }
/** Creates a BloomFilter. */ private BloomFilter( LockFreeBitArray bits, int numHashFunctions, Funnel<? super T> funnel, Strategy strategy) { checkArgument(numHashFunctions > 0, "numHashFunctions (%s) must be > 0", numHashFunctions); checkArgument( numHashFunctions <= 255, "numHashFunctions (%s) must be <= 255", numHashFunctions); this.bits = checkNotNull(bits); this.numHashFunctions = numHashFunctions; this.funnel = checkNotNull(funnel); this.strategy = checkNotNull(strategy); }
private TopKSelector(Comparator<? super T> comparator, int k) { this.comparator = checkNotNull(comparator, "comparator"); this.k = k; checkArgument(k >= 0, "k must be nonnegative, was %s", k); this.buffer = (T[]) new Object[k * 2]; this.bufferSize = 0; this.threshold = null; }
LimitedInputStream(InputStream in, long limit) { super(in); checkNotNull(in); checkArgument(limit >= 0, "limit must be non-negative"); left = limit; }
ExpiringMemoizingSupplier(Supplier<T> delegate, long duration, TimeUnit unit) { this.delegate = checkNotNull(delegate); this.durationNanos = unit.toNanos(duration); checkArgument(duration > 0, "duration (%s %s) must be > 0", duration, unit); }
LimitedYieldingAccumulator(YieldingAccumulator<OutType, T> accumulator) { super(accumulator); count = 0; }
/** * Creates a new input stream that will encode the characters from {@code reader} into bytes using * the given character set encoder. * * @param reader input source * @param encoder character set encoder used for encoding chars to bytes * @param bufferSize size of internal input and output buffers * @throws IllegalArgumentException if bufferSize is non-positive */ ReaderInputStream(Reader reader, CharsetEncoder encoder, int bufferSize) { this.reader = checkNotNull(reader); this.encoder = checkNotNull(encoder); checkArgument(bufferSize > 0, "bufferSize must be positive: %s", bufferSize); encoder.reset(); charBuffer = CharBuffer.allocate(bufferSize); charBuffer.flip(); byteBuffer = ByteBuffer.allocate(bufferSize); }
@Override public ContiguousSet<C> subSet(C fromElement, C toElement) { checkNotNull(fromElement); checkNotNull(toElement); checkArgument(comparator().compare(fromElement, toElement) <= 0); return subSetImpl(fromElement, true, toElement, false); }
/** * Throws {@code IllegalArgumentException} if the ordering of {@code endpoints} is not compatible * with the directionality of this graph. */ protected final void validateEndpoints(EndpointPair<?> endpoints) { checkNotNull(endpoints); checkArgument(isOrderingCompatible(endpoints), ENDPOINTS_MISMATCH); }
/** * Throws an IllegalArgumentException if the ordering of {@code endpoints} is not compatible * with the directionality of this graph. */ protected final void validateEndpoints(EndpointPair<?> endpoints) { checkNotNull(endpoints); checkArgument(isOrderingCompatible(endpoints), ENDPOINTS_MISMATCH); }
/** @since 12.0 */ @GwtIncompatible // NavigableSet @Override public ImmutableSortedSet<E> subSet( E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) { checkNotNull(fromElement); checkNotNull(toElement); checkArgument(comparator.compare(fromElement, toElement) <= 0); return subSetImpl(fromElement, fromInclusive, toElement, toInclusive); }
/** * Returns a proxy instance that implements {@code interfaceType} by dispatching method * invocations to {@code handler}. The class loader of {@code interfaceType} will be used to * define the proxy class. To implement multiple interfaces or specify a class loader, use {@link * Proxy#newProxyInstance}. * * @throws IllegalArgumentException if {@code interfaceType} does not specify the type of a Java * interface */ public static <T> T newProxy(Class<T> interfaceType, InvocationHandler handler) { checkNotNull(handler); checkArgument(interfaceType.isInterface(), "%s is not an interface", interfaceType); Object object = Proxy.newProxyInstance( interfaceType.getClassLoader(), new Class<?>[] {interfaceType}, handler); return interfaceType.cast(object); }
/** * Associates the specified range with the specified value. * * @throws IllegalArgumentException if {@code range} is empty */ @CanIgnoreReturnValue public Builder<K, V> put(Range<K> range, V value) { checkNotNull(range); checkNotNull(value); checkArgument(!range.isEmpty(), "Range must not be empty, but was %s", range); entries.add(Maps.immutableEntry(range, value)); return this; }
/** * Create a proc discovery mechanism based on a `/proc` directory. * * @param procDir The directory under proc. This is usually `/proc/self` or `/proc/#pid` */ public ProcCgroupDiscoverer(Path procDir) { this.procDir = Preconditions.checkNotNull(procDir, "procDir").toFile(); Preconditions.checkArgument(this.procDir.isDirectory(), "Not a directory: [%s]", procDir); }
private TaskStuff(Task task, TaskStatus status, DateTime createdDate, String dataSource) { Preconditions.checkArgument(task.getId().equals(status.getId())); this.task = Preconditions.checkNotNull(task, "task"); this.status = Preconditions.checkNotNull(status, "status"); this.createdDate = Preconditions.checkNotNull(createdDate, "createdDate"); this.dataSource = Preconditions.checkNotNull(dataSource, "dataSource"); }
@JsonCreator public DerivativeDataSourceMetadata( @JsonProperty("baseDataSource") String baseDataSource, @JsonProperty("dimensions") Set<String> dimensions, @JsonProperty("metrics") Set<String> metrics ) { Preconditions.checkArgument(!Strings.isNullOrEmpty(baseDataSource), "baseDataSource cannot be null or empty. Please provide a baseDataSource."); this.baseDataSource = baseDataSource; this.dimensions = Preconditions.checkNotNull(dimensions, "dimensions cannot be null. This is not a valid DerivativeDataSourceMetadata."); this.metrics = Preconditions.checkNotNull(metrics, "metrics cannot be null. This is not a valid DerivativeDataSourceMetadata."); }
/** * Returns a {@code UnsignedInteger} representing the same value as the specified {@link * BigInteger}. This is the inverse operation of {@link #bigIntegerValue()}. * * @throws IllegalArgumentException if {@code value} is negative or {@code value >= 2^32} */ public static UnsignedInteger valueOf(BigInteger value) { checkNotNull(value); checkArgument( value.signum() >= 0 && value.bitLength() <= Integer.SIZE, "value (%s) is outside the range for an unsigned integer value", value); return fromIntBits(value.intValue()); }
@JsonCreator public FireDepartmentConfig( @JsonProperty("maxRowsInMemory") int maxRowsInMemory, @JsonProperty("intermediatePersistPeriod") Period intermediatePersistPeriod ) { this.maxRowsInMemory = maxRowsInMemory; this.intermediatePersistPeriod = intermediatePersistPeriod; Preconditions.checkArgument(maxRowsInMemory > 0, "maxRowsInMemory[%s] should be greater than 0", maxRowsInMemory); Preconditions.checkNotNull(intermediatePersistPeriod, "intermediatePersistPeriod"); }
@JsonCreator public ColumnComparisonDimFilter( @JsonProperty("dimensions") List<DimensionSpec> dimensions ) { this.dimensions = Preconditions.checkNotNull(dimensions, "dimensions"); Preconditions.checkArgument(dimensions.size() >= 2, "dimensions must have a least 2 dimensions"); }