org.hibernate.internal.util.collections.ArrayHelper Maven / Gradle / Ivy
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*
*/
package org.hibernate.internal.util.collections;
import java.io.Serializable;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.LockOptions;
import org.hibernate.type.Type;
public final class ArrayHelper {
public static boolean contains(Object[] array, Object object) {
return indexOf( array, object ) > -1;
}
public static int indexOf(Object[] array, Object object) {
for ( int i = 0; i < array.length; i++ ) {
if ( array[i].equals( object ) )
return i;
}
return -1;
}
/*public static Object[] clone(Class elementClass, Object[] array) {
Object[] result = (Object[]) Array.newInstance( elementClass, array.length );
System.arraycopy(array, 0, result, 0, array.length);
return result;
}*/
public static String[] toStringArray(Object[] objects) {
int length=objects.length;
String[] result = new String[length];
for (int i=0; i T[] join(T[] x, T[] y) {
T[] result = (T[]) Array.newInstance( x.getClass().getComponentType(), x.length + y.length );
System.arraycopy( x, 0, result, 0, x.length );
System.arraycopy( y, 0, result, x.length, y.length );
return result;
}
public static final boolean[] TRUE = { true };
public static final boolean[] FALSE = { false };
private ArrayHelper() {}
public static String toString( Object[] array ) {
StringBuilder sb = new StringBuilder();
sb.append("[");
for (int i = 0; i < array.length; i++) {
sb.append( array[i] );
if( i=0 ) return false;
}
return true;
}
public static boolean isAllTrue(boolean[] array) {
for ( int i=0; i1 ) {
batchSize = getNextBatchSize(batchSize);
n++;
}
int[] result = new int[n];
batchSize = maxBatchSize;
for ( int i=0; i " + batchSizes[i] );
}
System.out.println( "Backward ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" );
for ( int i = batchSizes.length-1; i >= 0; i-- ) {
System.out.println( "[" + i + "] -> " + batchSizes[i] );
}
}
}