Skip to content

Commit 93f7237

Browse files
committed
actually delete obsolete operations of ArrayHelper since it's internal
1 parent f6ea07e commit 93f7237

File tree

1 file changed

+5
-217
lines changed
  • hibernate-core/src/main/java/org/hibernate/internal/util/collections

1 file changed

+5
-217
lines changed

hibernate-core/src/main/java/org/hibernate/internal/util/collections/ArrayHelper.java

Lines changed: 5 additions & 217 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,13 @@
44
*/
55
package org.hibernate.internal.util.collections;
66

7-
import java.io.Serializable;
87
import java.lang.reflect.Array;
98
import java.util.ArrayList;
109
import java.util.Arrays;
1110
import java.util.Collection;
12-
import java.util.Iterator;
1311
import java.util.List;
14-
import java.util.SortedSet;
15-
import java.util.TreeSet;
1612
import java.util.function.Consumer;
1713

18-
import org.checkerframework.checker.nullness.qual.NonNull;
19-
import org.hibernate.HibernateException;
20-
import org.hibernate.LockMode;
21-
import org.hibernate.LockOptions;
2214
import org.hibernate.internal.build.AllowReflection;
2315
import org.hibernate.type.Type;
2416

@@ -66,7 +58,6 @@ public static int indexOf(Object[] array, int end, Object object) {
6658

6759
@SuppressWarnings("unchecked")
6860
@AllowReflection
69-
@Deprecated(forRemoval = true, since = "7.3")
7061
public static <T> T[] filledArray(T value, Class<T> valueJavaType, int size) {
7162
final T[] array = (T[]) Array.newInstance( valueJavaType, size );
7263
Arrays.fill( array, value );
@@ -82,34 +73,6 @@ public static String[] toStringArray(Object[] objects) {
8273
return result;
8374
}
8475

85-
@Deprecated(forRemoval = true, since = "7.3")
86-
public static String[] fillArray(String value, int length) {
87-
final var result = new String[length];
88-
Arrays.fill( result, value );
89-
return result;
90-
}
91-
92-
@Deprecated(forRemoval = true, since = "7.3")
93-
public static int[] fillArray(int value, int length) {
94-
final var result = new int[length];
95-
Arrays.fill( result, value );
96-
return result;
97-
}
98-
99-
@Deprecated(forRemoval = true, since = "7.3")
100-
public static LockMode[] fillArray(LockMode lockMode, int length) {
101-
final var array = new LockMode[length];
102-
Arrays.fill( array, lockMode );
103-
return array;
104-
}
105-
106-
@Deprecated(forRemoval = true, since = "7.3")
107-
public static LockOptions[] fillArray(LockOptions lockOptions, int length) {
108-
final var array = new LockOptions[length];
109-
Arrays.fill( array, lockOptions );
110-
return array;
111-
}
112-
11376
public static String[] toStringArray(Collection<String> coll) {
11477
return coll.toArray( EMPTY_STRING_ARRAY );
11578
}
@@ -150,24 +113,6 @@ public static boolean[] toBooleanArray(Collection<Boolean> coll) {
150113
return arr;
151114
}
152115

153-
@Deprecated(forRemoval = true, since = "7.2")
154-
public static Object[] typecast(Object[] array, Object[] to) {
155-
return asList( array ).toArray( to );
156-
}
157-
158-
//Arrays.asList doesn't do primitive arrays
159-
// public static List toList(Object array) {
160-
// if ( array instanceof Object[] ) {
161-
// return Arrays.asList( (Object[]) array ); //faster?
162-
// }
163-
// int size = Array.getLength( array );
164-
// ArrayList<Object> list = new ArrayList<>( size );
165-
// for ( int i = 0; i < size; i++ ) {
166-
// list.add( Array.get( array, i ) );
167-
// }
168-
// return list;
169-
// }
170-
171116
public static String[] slice(String[] strings, int begin, int length) {
172117
final var result = new String[length];
173118
System.arraycopy( strings, begin, result, 0, length );
@@ -180,14 +125,6 @@ public static Object[] slice(Object[] objects, int begin, int length) {
180125
return result;
181126
}
182127

183-
public static <T> List<T> toList(Iterator<T> iter) {
184-
final List<T> list = new ArrayList<>();
185-
while ( iter.hasNext() ) {
186-
list.add( iter.next() );
187-
}
188-
return list;
189-
}
190-
191128
public static String[] join(String[] x, String[] y) {
192129
final var result = new String[x.length + y.length];
193130
System.arraycopy( x, 0, result, 0, x.length );
@@ -318,155 +255,6 @@ public static <T> void addAll(Collection<T> collection, T[] array) {
318255
public static final Type[] EMPTY_TYPE_ARRAY = {};
319256
public static final byte[] EMPTY_BYTE_ARRAY = {};
320257

321-
/**
322-
* Calculate the batch partitions needed to handle the {@code mappedBatchSize}.
323-
*
324-
* @param mappedBatchSize The {@link org.hibernate.annotations.BatchSize batch-size}.
325-
* Internally this is capped at {@code 256}
326-
*
327-
* @implNote The max batch size is capped at {@code 256}
328-
*
329-
* @return The upper bound for the partitions
330-
*
331-
* @deprecated No longer used
332-
*/
333-
@Deprecated(forRemoval = true, since = "7.2")
334-
public static int[] calculateBatchPartitions(int mappedBatchSize) {
335-
final SortedSet<Integer> partitionSizes = new TreeSet<>( Integer::compareTo );
336-
int batchSize = Math.min( mappedBatchSize, 256 );
337-
while ( batchSize > 1 ) {
338-
partitionSizes.add( batchSize );
339-
batchSize = calculateNextBatchPartitionLimit( batchSize );
340-
}
341-
return toIntArray( partitionSizes );
342-
}
343-
344-
@Deprecated(forRemoval = true, since = "7.2")
345-
private static int calculateNextBatchPartitionLimit(int batchSize) {
346-
if ( batchSize <= 10 ) {
347-
return batchSize - 1; //allow 9,8,7,6,5,4,3,2,1
348-
}
349-
else if ( batchSize / 2 < 10 ) {
350-
return 10;
351-
}
352-
else {
353-
return batchSize / 2;
354-
}
355-
}
356-
357-
@Deprecated(forRemoval = true, since = "7.2")
358-
public static int[] getBatchSizes(int maxBatchSize) {
359-
int batchSize = maxBatchSize;
360-
int n = 1;
361-
while ( batchSize > 1 ) {
362-
batchSize = getNextBatchSize( batchSize );
363-
n++;
364-
}
365-
final int[] result = new int[n];
366-
batchSize = maxBatchSize;
367-
for ( int i = 0; i < n; i++ ) {
368-
result[i] = batchSize;
369-
batchSize = getNextBatchSize( batchSize );
370-
}
371-
return result;
372-
}
373-
374-
@Deprecated(forRemoval = true, since = "7.2")
375-
private static int getNextBatchSize(int batchSize) {
376-
if ( batchSize <= 10 ) {
377-
return batchSize - 1; //allow 9,8,7,6,5,4,3,2,1
378-
}
379-
else if ( batchSize / 2 < 10 ) {
380-
return 10;
381-
}
382-
else {
383-
return batchSize / 2;
384-
}
385-
}
386-
387-
@Deprecated(forRemoval = true, since = "7.2")
388-
private static final int SEED = 23;
389-
@Deprecated(forRemoval = true, since = "7.2")
390-
private static final int PRIME_NUMBER = 37;
391-
392-
/**
393-
* calculate the array hash (only the first level)
394-
*/
395-
@Deprecated(forRemoval = true, since = "7.2")
396-
public static int hash(Object[] array) {
397-
int seed = SEED;
398-
for ( Object element : array ) {
399-
seed = hash( seed, element == null ? 0 : element.hashCode() );
400-
}
401-
return seed;
402-
}
403-
404-
/**
405-
* calculate the array hash (only the first level)
406-
*/
407-
@Deprecated(forRemoval = true, since = "7.2")
408-
public static int hash(char[] array) {
409-
int seed = SEED;
410-
for ( char anArray : array ) {
411-
seed = hash( seed, anArray );
412-
}
413-
return seed;
414-
}
415-
416-
/**
417-
* calculate the array hash (only the first level)
418-
*/
419-
@Deprecated(forRemoval = true, since = "7.2")
420-
public static int hash(byte[] bytes) {
421-
int seed = SEED;
422-
for ( byte aByte : bytes ) {
423-
seed = hash( seed, aByte );
424-
}
425-
return seed;
426-
}
427-
428-
@Deprecated(forRemoval = true, since = "7.2")
429-
private static int hash(int seed, int i) {
430-
return PRIME_NUMBER * seed + i;
431-
}
432-
433-
@Deprecated(forRemoval = true, since = "7.2")
434-
public static Serializable[] extractNonNull(Serializable[] array) {
435-
final int nonNullCount = countNonNull( array );
436-
final var result = new Serializable[nonNullCount];
437-
int i = 0;
438-
for ( Serializable element : array ) {
439-
if ( element != null ) {
440-
result[i++] = element;
441-
}
442-
}
443-
if ( i != nonNullCount ) {
444-
throw new HibernateException( "Number of non-null elements varied between iterations" );
445-
}
446-
return result;
447-
}
448-
449-
@Deprecated(forRemoval = true, since = "7.2")
450-
public static int countNonNull(Serializable[] array) {
451-
int i = 0;
452-
for ( Serializable element : array ) {
453-
if ( element != null ) {
454-
i++;
455-
}
456-
}
457-
return i;
458-
}
459-
460-
@Deprecated(forRemoval = true, since = "7.2")
461-
public static int countNonNull(Object[] array) {
462-
int i = 0;
463-
for ( Object element : array ) {
464-
if ( element != null ) {
465-
i++;
466-
}
467-
}
468-
return i;
469-
}
470258

471259
/**
472260
* Reverse the elements of the incoming array
@@ -544,6 +332,10 @@ public static boolean isEmpty(Object[] array) {
544332
return array == null || array.length == 0;
545333
}
546334

335+
public static <T> int size(T[] array) {
336+
return array == null ? 0 : array.length;
337+
}
338+
547339
public static <T> void forEach(T[] array, Consumer<T> consumer) {
548340
if ( array != null ) {
549341
//noinspection ForLoopReplaceableByForEach
@@ -556,14 +348,10 @@ public static <T> void forEach(T[] array, Consumer<T> consumer) {
556348
/**
557349
* @deprecated Use {@link Array#newInstance(Class, int)} instead.
558350
*/
559-
@Deprecated(forRemoval = true, since = "7")
351+
@Deprecated
560352
@SuppressWarnings("unchecked")
561353
@AllowReflection
562354
public static <T> T[] newInstance(Class<T> elementType, int length) {
563355
return (T[]) Array.newInstance( elementType, length );
564356
}
565-
566-
public static <T> int size(T[] array) {
567-
return array == null ? 0 : array.length;
568-
}
569357
}

0 commit comments

Comments
 (0)