blob: f76303f52104b81a95b6974e244994fb8877abdc [file] [log] [blame]
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.net.impl;
import java.nio.ByteBuffer;
/** Utility class to check preconditions. */
public final class Preconditions {
private Preconditions() {}
public static void checkDirect(ByteBuffer buffer) {
if (!buffer.isDirect()) {
throw new IllegalArgumentException("byteBuffer must be a direct ByteBuffer.");
}
}
public static void checkHasRemaining(ByteBuffer buffer) {
if (!buffer.hasRemaining()) {
throw new IllegalArgumentException("ByteBuffer is already full.");
}
}
}