com.google.common.primitives.Bytes.copyOf()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(136)

本文整理了Java中com.google.common.primitives.Bytes.copyOf()方法的一些代码示例,展示了Bytes.copyOf()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bytes.copyOf()方法的具体详情如下:
包路径:com.google.common.primitives.Bytes
类名称:Bytes
方法名:copyOf

Bytes.copyOf介绍

暂无

代码示例

代码示例来源:origin: com.google.guava/guava-jdk5

/**
 * Returns an array containing the same values as {@code array}, but
 * guaranteed to be of a specified minimum length. If {@code array} already
 * has a length of at least {@code minLength}, it is returned directly.
 * Otherwise, a new array of size {@code minLength + padding} is returned,
 * containing the values of {@code array}, and zeroes in the remaining places.
 *
 * @param array the source array
 * @param minLength the minimum length the returned array must guarantee
 * @param padding an extra amount to "grow" the array by if growth is
 *     necessary
 * @throws IllegalArgumentException if {@code minLength} or {@code padding} is
 *     negative
 * @return an array containing the values of {@code array}, with guaranteed
 *     minimum length {@code minLength}
 */
public static byte[] ensureCapacity(
  byte[] array, int minLength, int padding) {
 checkArgument(minLength >= 0, "Invalid minLength: %s", minLength);
 checkArgument(padding >= 0, "Invalid padding: %s", padding);
 return (array.length < minLength)
   ? copyOf(array, minLength + padding)
   : array;
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

/**
 * Returns an array containing the same values as {@code array}, but
 * guaranteed to be of a specified minimum length. If {@code array} already
 * has a length of at least {@code minLength}, it is returned directly.
 * Otherwise, a new array of size {@code minLength + padding} is returned,
 * containing the values of {@code array}, and zeroes in the remaining places.
 *
 * @param array the source array
 * @param minLength the minimum length the returned array must guarantee
 * @param padding an extra amount to "grow" the array by if growth is
 *     necessary
 * @throws IllegalArgumentException if {@code minLength} or {@code padding} is
 *     negative
 * @return an array containing the values of {@code array}, with guaranteed
 *     minimum length {@code minLength}
 */
public static byte[] ensureCapacity(
  byte[] array, int minLength, int padding) {
 checkArgument(minLength >= 0, "Invalid minLength: %s", minLength);
 checkArgument(padding >= 0, "Invalid padding: %s", padding);
 return (array.length < minLength)
   ? copyOf(array, minLength + padding)
   : array;
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/**
 * Returns an array containing the same values as {@code array}, but
 * guaranteed to be of a specified minimum length. If {@code array} already
 * has a length of at least {@code minLength}, it is returned directly.
 * Otherwise, a new array of size {@code minLength + padding} is returned,
 * containing the values of {@code array}, and zeroes in the remaining places.
 *
 * @param array the source array
 * @param minLength the minimum length the returned array must guarantee
 * @param padding an extra amount to "grow" the array by if growth is
 *     necessary
 * @throws IllegalArgumentException if {@code minLength} or {@code padding} is
 *     negative
 * @return an array containing the values of {@code array}, with guaranteed
 *     minimum length {@code minLength}
 */
public static byte[] ensureCapacity(
  byte[] array, int minLength, int padding) {
 checkArgument(minLength >= 0, "Invalid minLength: %s", minLength);
 checkArgument(padding >= 0, "Invalid padding: %s", padding);
 return (array.length < minLength)
   ? copyOf(array, minLength + padding)
   : array;
}

代码示例来源:origin: Nextdoor/bender

/**
 * Returns an array containing the same values as {@code array}, but
 * guaranteed to be of a specified minimum length. If {@code array} already
 * has a length of at least {@code minLength}, it is returned directly.
 * Otherwise, a new array of size {@code minLength + padding} is returned,
 * containing the values of {@code array}, and zeroes in the remaining places.
 *
 * @param array the source array
 * @param minLength the minimum length the returned array must guarantee
 * @param padding an extra amount to "grow" the array by if growth is
 *     necessary
 * @throws IllegalArgumentException if {@code minLength} or {@code padding} is
 *     negative
 * @return an array containing the values of {@code array}, with guaranteed
 *     minimum length {@code minLength}
 */
public static byte[] ensureCapacity(
  byte[] array, int minLength, int padding) {
 checkArgument(minLength >= 0, "Invalid minLength: %s", minLength);
 checkArgument(padding >= 0, "Invalid padding: %s", padding);
 return (array.length < minLength)
   ? copyOf(array, minLength + padding)
   : array;
}

代码示例来源:origin: com.atlassian.bundles/guava

/**
 * Returns an array containing the same values as {@code array}, but
 * guaranteed to be of a specified minimum length. If {@code array} already
 * has a length of at least {@code minLength}, it is returned directly.
 * Otherwise, a new array of size {@code minLength + padding} is returned,
 * containing the values of {@code array}, and zeroes in the remaining places.
 *
 * @param array the source array
 * @param minLength the minimum length the returned array must guarantee
 * @param padding an extra amount to "grow" the array by if growth is
 *     necessary
 * @throws IllegalArgumentException if {@code minLength} or {@code padding} is
 *     negative
 * @return an array containing the values of {@code array}, with guaranteed
 *     minimum length {@code minLength}
 */
public static byte[] ensureCapacity(
  byte[] array, int minLength, int padding) {
 checkArgument(minLength >= 0, "Invalid minLength: %s", minLength);
 checkArgument(padding >= 0, "Invalid padding: %s", padding);
 return (array.length < minLength)
   ? copyOf(array, minLength + padding)
   : array;
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/**
 * Returns an array containing the same values as {@code array}, but
 * guaranteed to be of a specified minimum length. If {@code array} already
 * has a length of at least {@code minLength}, it is returned directly.
 * Otherwise, a new array of size {@code minLength + padding} is returned,
 * containing the values of {@code array}, and zeroes in the remaining places.
 *
 * @param array the source array
 * @param minLength the minimum length the returned array must guarantee
 * @param padding an extra amount to "grow" the array by if growth is
 *     necessary
 * @throws IllegalArgumentException if {@code minLength} or {@code padding} is
 *     negative
 * @return an array containing the values of {@code array}, with guaranteed
 *     minimum length {@code minLength}
 */
public static byte[] ensureCapacity(
  byte[] array, int minLength, int padding) {
 checkArgument(minLength >= 0, "Invalid minLength: %s", minLength);
 checkArgument(padding >= 0, "Invalid padding: %s", padding);
 return (array.length < minLength)
   ? copyOf(array, minLength + padding)
   : array;
}

代码示例来源:origin: com.diffplug.guava/guava-core

/**
 * Returns an array containing the same values as {@code array}, but
 * guaranteed to be of a specified minimum length. If {@code array} already
 * has a length of at least {@code minLength}, it is returned directly.
 * Otherwise, a new array of size {@code minLength + padding} is returned,
 * containing the values of {@code array}, and zeroes in the remaining places.
 *
 * @param array the source array
 * @param minLength the minimum length the returned array must guarantee
 * @param padding an extra amount to "grow" the array by if growth is
 *     necessary
 * @throws IllegalArgumentException if {@code minLength} or {@code padding} is
 *     negative
 * @return an array containing the values of {@code array}, with guaranteed
 *     minimum length {@code minLength}
 */
public static byte[] ensureCapacity(byte[] array, int minLength, int padding) {
  checkArgument(minLength >= 0, "Invalid minLength: %s", minLength);
  checkArgument(padding >= 0, "Invalid padding: %s", padding);
  return (array.length < minLength)
      ? copyOf(array, minLength + padding)
      : array;
}

代码示例来源:origin: org.sonatype.sisu/sisu-guava

/**
 * Returns an array containing the same values as {@code array}, but
 * guaranteed to be of a specified minimum length. If {@code array} already
 * has a length of at least {@code minLength}, it is returned directly.
 * Otherwise, a new array of size {@code minLength + padding} is returned,
 * containing the values of {@code array}, and zeroes in the remaining places.
 *
 * @param array the source array
 * @param minLength the minimum length the returned array must guarantee
 * @param padding an extra amount to "grow" the array by if growth is
 *     necessary
 * @throws IllegalArgumentException if {@code minLength} or {@code padding} is
 *     negative
 * @return an array containing the values of {@code array}, with guaranteed
 *     minimum length {@code minLength}
 */
public static byte[] ensureCapacity(
  byte[] array, int minLength, int padding) {
 checkArgument(minLength >= 0, "Invalid minLength: %s", minLength);
 checkArgument(padding >= 0, "Invalid padding: %s", padding);
 return (array.length < minLength)
   ? copyOf(array, minLength + padding)
   : array;
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.guava

/**
 * Returns an array containing the same values as {@code array}, but
 * guaranteed to be of a specified minimum length. If {@code array} already
 * has a length of at least {@code minLength}, it is returned directly.
 * Otherwise, a new array of size {@code minLength + padding} is returned,
 * containing the values of {@code array}, and zeroes in the remaining places.
 *
 * @param array the source array
 * @param minLength the minimum length the returned array must guarantee
 * @param padding an extra amount to "grow" the array by if growth is
 *     necessary
 * @throws IllegalArgumentException if {@code minLength} or {@code padding} is
 *     negative
 * @return an array containing the values of {@code array}, with guaranteed
 *     minimum length {@code minLength}
 */
public static byte[] ensureCapacity(
  byte[] array, int minLength, int padding) {
 checkArgument(minLength >= 0, "Invalid minLength: %s", minLength);
 checkArgument(padding >= 0, "Invalid padding: %s", padding);
 return (array.length < minLength)
   ? copyOf(array, minLength + padding)
   : array;
}

代码示例来源:origin: org.hudsonci.lib.guava/guava

/**
 * Returns an array containing the same values as {@code array}, but
 * guaranteed to be of a specified minimum length. If {@code array} already
 * has a length of at least {@code minLength}, it is returned directly.
 * Otherwise, a new array of size {@code minLength + padding} is returned,
 * containing the values of {@code array}, and zeroes in the remaining places.
 *
 * @param array the source array
 * @param minLength the minimum length the returned array must guarantee
 * @param padding an extra amount to "grow" the array by if growth is
 *     necessary
 * @throws IllegalArgumentException if {@code minLength} or {@code padding} is
 *     negative
 * @return an array containing the values of {@code array}, with guaranteed
 *     minimum length {@code minLength}
 */
public static byte[] ensureCapacity(
  byte[] array, int minLength, int padding) {
 checkArgument(minLength >= 0, "Invalid minLength: %s", minLength);
 checkArgument(padding >= 0, "Invalid padding: %s", padding);
 return (array.length < minLength)
   ? copyOf(array, minLength + padding)
   : array;
}

代码示例来源:origin: com.google.guava/guava-primitives

/**
 * Returns an array containing the same values as {@code array}, but
 * guaranteed to be of a specified minimum length. If {@code array} already
 * has a length of at least {@code minLength}, it is returned directly.
 * Otherwise, a new array of size {@code minLength + padding} is returned,
 * containing the values of {@code array}, and zeroes in the remaining places.
 *
 * @param array the source array
 * @param minLength the minimum length the returned array must guarantee
 * @param padding an extra amount to "grow" the array by if growth is
 *     necessary
 * @throws IllegalArgumentException if {@code minLength} or {@code padding} is
 *     negative
 * @return an array containing the values of {@code array}, with guaranteed
 *     minimum length {@code minLength}
 */
public static byte[] ensureCapacity(
  byte[] array, int minLength, int padding) {
 checkArgument(minLength >= 0, "Invalid minLength: %s", minLength);
 checkArgument(padding >= 0, "Invalid padding: %s", padding);
 return (array.length < minLength)
   ? copyOf(array, minLength + padding)
   : array;
}

相关文章