ByteArrayUtils.java

  1. /*
  2.  *    Copyright 2009-2022 the original author or authors.
  3.  *
  4.  *    Licensed under the Apache License, Version 2.0 (the "License");
  5.  *    you may not use this file except in compliance with the License.
  6.  *    You may obtain a copy of the License at
  7.  *
  8.  *       https://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  *    Unless required by applicable law or agreed to in writing, software
  11.  *    distributed under the License is distributed on an "AS IS" BASIS,
  12.  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  *    See the License for the specific language governing permissions and
  14.  *    limitations under the License.
  15.  */
  16. package org.apache.ibatis.type;

  17. /**
  18.  * @author Clinton Begin
  19.  */
  20. class ByteArrayUtils {

  21.   private ByteArrayUtils() {
  22.     // Prevent Instantiation
  23.   }

  24.   static byte[] convertToPrimitiveArray(Byte[] objects) {
  25.     final byte[] bytes = new byte[objects.length];
  26.     for (int i = 0; i < objects.length; i++) {
  27.       bytes[i] = objects[i];
  28.     }
  29.     return bytes;
  30.   }

  31.   static Byte[] convertToObjectArray(byte[] bytes) {
  32.     final Byte[] objects = new Byte[bytes.length];
  33.     for (int i = 0; i < bytes.length; i++) {
  34.       objects[i] = bytes[i];
  35.     }
  36.     return objects;
  37.   }
  38. }