• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 package org.chromium.net.impl;
6 
7 import java.nio.ByteBuffer;
8 
9 /** Utility class to check preconditions. */
10 public final class Preconditions {
Preconditions()11     private Preconditions() {}
12 
checkDirect(ByteBuffer buffer)13     public static void checkDirect(ByteBuffer buffer) {
14         if (!buffer.isDirect()) {
15             throw new IllegalArgumentException("byteBuffer must be a direct ByteBuffer.");
16         }
17     }
18 
checkHasRemaining(ByteBuffer buffer)19     public static void checkHasRemaining(ByteBuffer buffer) {
20         if (!buffer.hasRemaining()) {
21             throw new IllegalArgumentException("ByteBuffer is already full.");
22         }
23     }
24 }
25