blob: 55a92da515574833edc7611aaa431556703cfe6c [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.");
}
}
}