xuhy
2023-08-11 b659987d3e120cea0b94fdb01f1ab06260f61825
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
package com.stylefeng.guns.core.support;
 
 
import com.stylefeng.guns.core.support.exception.ToolBoxException;
 
import java.lang.reflect.Array;
import java.util.*;
import java.util.Map.Entry;
 
/**
 * 集合相关工具类,包括数组
 * 
 * @author xiaoleilu
 * 
 */
public class CollectionKit {
    
    private CollectionKit() {
        // 静态类不可实例化
    }
    
    /**
     * 以 conjunction 为分隔符将集合转换为字符串
     * 
     * @param <T> 被处理的集合
     * @param collection 集合
     * @param conjunction 分隔符
     * @return 连接后的字符串
     */
    public static <T> String join(Iterable<T> collection, String conjunction) {
        StringBuilder sb = new StringBuilder();
        boolean isFirst = true;
        for (T item : collection) {
            if (isFirst) {
                isFirst = false;
            } else {
                sb.append(conjunction);
            }
            sb.append(item);
        }
        return sb.toString();
    }
    
    /**
     * 以 conjunction 为分隔符将数组转换为字符串
     * 
     * @param <T> 被处理的集合
     * @param array 数组
     * @param conjunction 分隔符
     * @return 连接后的字符串
     */
    public static <T> String join(T[] array, String conjunction) {
        StringBuilder sb = new StringBuilder();
        boolean isFirst = true;
        for (T item : array) {
            if (isFirst) {
                isFirst = false;
            } else {
                sb.append(conjunction);
            }
            sb.append(item);
        }
        return sb.toString();
    }
    
    /**
     * 将多个集合排序并显示不同的段落(分页)
     * @param pageNo 页码
     * @param numPerPage 每页的条目数
     * @param comparator 比较器
     * @param colls 集合数组
     * @return 分页后的段落内容
     */
    @SafeVarargs
    public static <T> List<T> sortPageAll(int pageNo, int numPerPage, Comparator<T> comparator, Collection<T>... colls) {
        final List<T> result = new ArrayList<T>();
        for (Collection<T> coll : colls) {
            result.addAll(coll);
        }
        
        Collections.sort(result, comparator);
        
        //第一页且数目少于第一页显示的数目
        if(pageNo <=1 && result.size() <= numPerPage) {
            return result;
        }
        
        final int[] startEnd = PageKit.transToStartEnd(pageNo, numPerPage);
        return result.subList(startEnd[0], startEnd[1]);
    }
 
    /**
     * 将多个集合排序并显示不同的段落(分页)
     * @param pageNo 页码
     * @param numPerPage 每页的条目数
     * @param comparator 比较器
     * @param colls 集合数组
     * @return 分业后的段落内容
     */
//    @SafeVarargs
//    public static <T> List<T> sortPageAll2(int pageNo, int numPerPage, Comparator<T> comparator, Collection<T>... colls) {
//        BoundedPriorityQueue<T> queue = new BoundedPriorityQueue<T>(pageNo * numPerPage);
//        for (Collection<T> coll : colls) {
//            queue.addAll(coll);
//        }
//
//        //第一页且数目少于第一页显示的数目
//        if(pageNo <=1 && queue.size() <= numPerPage) {
//            return queue.toList();
//        }
//
//        final int[] startEnd = PageKit.transToStartEnd(pageNo, numPerPage);
//        return queue.toList().subList(startEnd[0], startEnd[1]);
//    }
 
    /**
     * 将Set排序(根据Entry的值)
     *
     * @param set 被排序的Set
     * @return 排序后的Set
     */
    public static List<Entry<Long, Long>> sortEntrySetToList(Set<Entry<Long, Long>> set) {
        List<Entry<Long, Long>> list = new LinkedList<Entry<Long, Long>>(set);
        Collections.sort(list, new Comparator<Entry<Long, Long>>(){
 
            @Override
            public int compare(Entry<Long, Long> o1, Entry<Long, Long> o2) {
                if (o1.getValue() > o2.getValue()){
                    return 1;
                }
                if (o1.getValue() < o2.getValue()){
                    return -1;
                }
                return 0;
            }
        });
        return list;
    }
 
    /**
     * 切取部分数据
     *
     * @param <T> 集合元素类型
     * @param surplusAlaDatas 原数据
     * @param partSize 每部分数据的长度
     * @return 切取出的数据或null
     */
    public static <T> List<T> popPart(Stack<T> surplusAlaDatas, int partSize) {
        if (surplusAlaDatas == null || surplusAlaDatas.size() <= 0){
            return null;
        }
 
        final List<T> currentAlaDatas = new ArrayList<T>();
        int size = surplusAlaDatas.size();
        // 切割
        if (size > partSize) {
            for (int i = 0; i < partSize; i++) {
                currentAlaDatas.add(surplusAlaDatas.pop());
            }
        } else {
            for (int i = 0; i < size; i++) {
                currentAlaDatas.add(surplusAlaDatas.pop());
            }
        }
        return currentAlaDatas;
    }
 
    /**
     * 切取部分数据
     *
     * @param <T> 集合元素类型
     * @param surplusAlaDatas 原数据
     * @param partSize 每部分数据的长度
     * @return 切取出的数据或null
     */
    public static <T> List<T> popPart(Deque<T> surplusAlaDatas, int partSize) {
        if (surplusAlaDatas == null || surplusAlaDatas.size() <= 0){
            return null;
        }
 
        final List<T> currentAlaDatas = new ArrayList<T>();
        int size = surplusAlaDatas.size();
        // 切割
        if (size > partSize) {
            for (int i = 0; i < partSize; i++) {
                currentAlaDatas.add(surplusAlaDatas.pop());
            }
        } else {
            for (int i = 0; i < size; i++) {
                currentAlaDatas.add(surplusAlaDatas.pop());
            }
        }
        return currentAlaDatas;
    }
 
    /**
     * 新建一个HashMap
     *
     * @return HashMap对象
     */
    public static <T, K> HashMap<T, K> newHashMap() {
        return new HashMap<T, K>();
    }
 
    /**
     * 新建一个HashMap
     * @param size 初始大小,由于默认负载因子0.75,传入的size会实际初始大小为size / 0.75
     * @return HashMap对象
     */
    public static <T, K> HashMap<T, K> newHashMap(int size) {
        return new HashMap<T, K>((int)(size / 0.75));
    }
 
    /**
     * 新建一个HashSet
     *
     * @return HashSet对象
     */
    public static <T> HashSet<T> newHashSet() {
        return new HashSet<T>();
    }
 
    /**
     * 新建一个HashSet
     *
     * @return HashSet对象
     */
    @SafeVarargs
    public static <T> HashSet<T> newHashSet(T... ts) {
        HashSet<T> set = new HashSet<T>();
        for (T t : ts) {
            set.add(t);
        }
        return set;
    }
 
    /**
     * 新建一个ArrayList
     *
     * @return ArrayList对象
     */
    public static <T> ArrayList<T> newArrayList() {
        return new ArrayList<T>();
    }
 
    /**
     * 新建一个ArrayList
     *
     * @return ArrayList对象
     */
    @SafeVarargs
    public static <T> ArrayList<T> newArrayList(T... values) {
        return new ArrayList<T>(Arrays.asList(values));
    }
 
    /**
     * 将新元素添加到已有数组中<br/>
     * 添加新元素会生成一个新的数组,不影响原数组
     *
     * @param buffer 已有数组
     * @param newElement 新元素
     * @return 新数组
     */
    public static <T> T[] append(T[] buffer, T newElement) {
        T[] t = resize(buffer, buffer.length + 1, newElement.getClass());
        t[buffer.length] = newElement;
        return t;
    }
 
    /**
     * 生成一个新的重新设置大小的数组
     *
     * @param buffer 原数组
     * @param newSize 新的数组大小
     * @param componentType 数组元素类型
     * @return 调整后的新数组
     */
    public static <T> T[] resize(T[] buffer, int newSize, Class<?> componentType) {
        T[] newArray = newArray(componentType, newSize);
        System.arraycopy(buffer, 0, newArray, 0, buffer.length >= newSize ? newSize : buffer.length);
        return newArray;
    }
 
    /**
     * 新建一个空数组
     * @param componentType 元素类型
     * @param newSize 大小
     * @return 空数组
     */
    @SuppressWarnings("unchecked")
    public static <T> T[] newArray(Class<?> componentType, int newSize) {
        return (T[]) Array.newInstance(componentType, newSize);
    }
 
    /**
     * 生成一个新的重新设置大小的数组<br/>
     * 新数组的类型为原数组的类型
     *
     * @param buffer 原数组
     * @param newSize 新的数组大小
     * @return 调整后的新数组
     */
    public static <T> T[] resize(T[] buffer, int newSize) {
        return resize(buffer, newSize, buffer.getClass().getComponentType());
    }
 
    /**
     * 将多个数组合并在一起<br>
     * 忽略null的数组
     *
     * @param arrays 数组集合
     * @return 合并后的数组
     */
    @SafeVarargs
    public static <T> T[] addAll(T[]... arrays) {
        if (arrays.length == 1) {
            return arrays[0];
        }
 
        int length = 0;
        for (T[] array : arrays) {
            if(array == null) {
                continue;
            }
            length += array.length;
        }
        T[] result = newArray(arrays.getClass().getComponentType().getComponentType(), length);
 
        length = 0;
        for (T[] array : arrays) {
            if(array == null) {
                continue;
            }
            System.arraycopy(array, 0, result, length, array.length);
            length += array.length;
        }
        return result;
    }
 
    /**
     * 克隆数组
     * @param array 被克隆的数组
     * @return 新数组
     */
    public static <T> T[] clone(T[] array) {
        if (array == null) {
            return null;
        }
        return array.clone();
    }
 
    /**
     * 生成一个数字列表<br>
     * 自动判定正序反序
     * @param excludedEnd 结束的数字(不包含)
     * @return 数字列表
     */
    public static int[] range(int excludedEnd) {
        return range(0, excludedEnd, 1);
    }
 
    /**
     * 生成一个数字列表<br>
     * 自动判定正序反序
     * @param includedStart 开始的数字(包含)
     * @param excludedEnd 结束的数字(不包含)
     * @return 数字列表
     */
    public static int[] range(int includedStart, int excludedEnd) {
        return range(includedStart, excludedEnd, 1);
    }
 
    /**
     * 生成一个数字列表<br>
     * 自动判定正序反序
     * @param includedStart 开始的数字(包含)
     * @param excludedEnd 结束的数字(不包含)
     * @param step 步进
     * @return 数字列表
     */
    public static int[] range(int includedStart, int excludedEnd, int step) {
        if(includedStart > excludedEnd) {
            int tmp = includedStart;
            includedStart = excludedEnd;
            excludedEnd = tmp;
        }
 
        if(step <=0) {
            step = 1;
        }
 
        int deviation = excludedEnd - includedStart;
        int length = deviation / step;
        if(deviation % step != 0) {
            length += 1;
        }
        int[] range = new int[length];
        for(int i = 0; i < length; i++) {
            range[i] = includedStart;
            includedStart += step;
        }
        return range;
    }
 
    /**
     * 截取数组的部分
     * @param list 被截取的数组
     * @param start 开始位置(包含)
     * @param end 结束位置(不包含)
     * @return 截取后的数组,当开始位置超过最大时,返回null
     */
    public static <T> List<T> sub(List<T> list, int start, int end) {
        if(list == null || list.isEmpty()) {
            return null;
        }
 
        if(start < 0) {
            start = 0;
        }
        if(end < 0) {
            end = 0;
        }
 
        if(start > end) {
            int tmp = start;
            start = end;
            end = tmp;
        }
 
        final int size = list.size();
        if(end > size) {
            if(start >= size) {
                return null;
            }
            end = size;
        }
 
        return list.subList(start, end);
    }
 
    /**
     * 截取集合的部分
     * @param list 被截取的数组
     * @param start 开始位置(包含)
     * @param end 结束位置(不包含)
     * @return 截取后的数组,当开始位置超过最大时,返回null
     */
    public static <T> List<T> sub(Collection<T> list, int start, int end) {
        if(list == null || list.isEmpty()) {
            return null;
        }
 
        return sub(new ArrayList<T>(list), start, end);
    }
 
    /**
     * 数组是否为空
     * @param array 数组
     * @return 是否为空
     */
    public static <T> boolean isEmpty(T[] array) {
        return array == null || array.length == 0;
    }
 
    /**
     * 数组是否为非空
     * @param array 数组
     * @return 是否为非空
     */
    public static <T> boolean isNotEmpty(T[] array) {
        return false == isEmpty(array);
    }
 
    /**
     * 集合是否为空
     * @param collection 集合
     * @return 是否为空
     */
    public static boolean isEmpty(Collection<?> collection) {
        return collection == null || collection.isEmpty();
    }
 
    /**
     * 集合是否为非空
     * @param collection 集合
     * @return 是否为非空
     */
    public static boolean isNotEmpty(Collection<?> collection) {
        return false == isEmpty(collection);
    }
 
    /**
     * Map是否为空
     * @param map 集合
     * @return 是否为空
     */
    public static boolean isEmpty(Map<?, ?> map) {
        return map == null || map.isEmpty();
    }
 
    /**
     * Map是否为非空
     * @param map 集合
     * @return 是否为非空
     */
    public static <T> boolean isNotEmpty(Map<?, ?> map) {
        return false == isEmpty(map);
    }
 
    /**
     * 映射键值(参考Python的zip()函数)<br>
     * 例如:<br>
     *         keys =    [a,b,c,d]<br>
     *        values = [1,2,3,4]<br>
     * 则得到的Map是 {a=1, b=2, c=3, d=4}<br>
     * 如果两个数组长度不同,则只对应最短部分
     * @param keys 键列表
     * @param values 值列表
     * @return Map
     */
    public static <T, K> Map<T, K> zip(T[] keys, K[] values) {
        if(isEmpty(keys) || isEmpty(values)) {
            return null;
        }
 
        final int size = Math.min(keys.length, values.length);
        final Map<T, K> map = new HashMap<T, K>((int)(size / 0.75));
        for(int i = 0; i < size; i++) {
            map.put(keys[i], values[i]);
        }
 
        return map;
    }
 
    /**
     * 映射键值(参考Python的zip()函数)<br>
     * 例如:<br>
     *         keys =    a,b,c,d<br>
     *        values = 1,2,3,4<br>
     *        delimiter = ,
     * 则得到的Map是 {a=1, b=2, c=3, d=4}<br>
     * 如果两个数组长度不同,则只对应最短部分
     * @param keys 键列表
     * @param values 值列表
     * @return Map
     */
    public static Map<String, String> zip(String keys, String values, String delimiter) {
        return zip(StrKit.split(keys, delimiter), StrKit.split(values, delimiter));
    }
    
    /**
     * 映射键值(参考Python的zip()函数)<br>
     * 例如:<br>
     *         keys =    [a,b,c,d]<br>
     *        values = [1,2,3,4]<br>
     * 则得到的Map是 {a=1, b=2, c=3, d=4}<br>
     * 如果两个数组长度不同,则只对应最短部分
     * @param keys 键列表
     * @param values 值列表
     * @return Map
     */
    public static <T, K> Map<T, K> zip(Collection<T> keys, Collection<K> values) {
        if(isEmpty(keys) || isEmpty(values)) {
            return null;
        }
        
        final List<T> keyList = new ArrayList<T>(keys);
        final List<K> valueList = new ArrayList<K>(values);
        
        final int size = Math.min(keys.size(), values.size());
        final Map<T, K> map = new HashMap<T, K>((int)(size / 0.75));
        for(int i = 0; i < size; i++) {
            map.put(keyList.get(i), valueList.get(i));
        }
        
        return map;
    }
    
    /**
     * 数组中是否包含元素
     * @param array 数组
     * @param value 被检查的元素
     * @return 是否包含
     */
    public static <T> boolean contains(T[] array, T value) {
        final Class<?> componetType = array.getClass().getComponentType();
        boolean isPrimitive = false;
        if(null != componetType) {
            isPrimitive = componetType.isPrimitive();
        }
        for (T t : array) {
            if(t == value) {
                return true;
            }else if(false == isPrimitive && null != value && value.equals(t)) {
                return true;
            }
        }
        return false;
    }
    
    /**
     * 将Entry集合转换为HashMap
     * @param entryCollection entry集合
     * @return Map
     */
    public static <T, K> HashMap<T, K> toMap(Collection<Entry<T, K>> entryCollection) {
        HashMap<T,K> map = new HashMap<T, K>();
        for (Entry<T, K> entry : entryCollection) {
            map.put(entry.getKey(), entry.getValue());
        }
        return map;
    }
    
    /**
     * 将集合转换为排序后的TreeSet
     * @param collection 集合
     * @param comparator 比较器
     * @return treeSet
     */
    public static <T> TreeSet<T> toTreeSet(Collection<T> collection, Comparator<T> comparator){
        final TreeSet<T> treeSet = new TreeSet<T>(comparator);
        for (T t : collection) {
            treeSet.add(t);
        }
        return treeSet;
    }
    
    /**
     * 排序集合
     * @param collection 集合
     * @param comparator 比较器
     * @return treeSet
     */
    public static <T> List<T> sort(Collection<T> collection, Comparator<T> comparator){
        List<T> list = new ArrayList<T>(collection);
        Collections.sort(list, comparator);
        return list;
    }
    
    //------------------------------------------------------------------- 基本类型的数组转换为包装类型数组
    /**
     * 将基本类型数组包装为包装类型
     * @param values 基本类型数组
     * @return 包装类型数组
     */
    public static Integer[] wrap(int... values){
        final int length = values.length;
        Integer[] array = new Integer[length];
        for(int i = 0; i < length; i++){
            array[i] = values[i];
        }
        return array;
    }
    
    /**
     * 将基本类型数组包装为包装类型
     * @param values 基本类型数组
     * @return 包装类型数组
     */
    public static Long[] wrap(long... values){
        final int length = values.length;
        Long[] array = new Long[length];
        for(int i = 0; i < length; i++){
            array[i] = values[i];
        }
        return array;
    }
    
    /**
     * 将基本类型数组包装为包装类型
     * @param values 基本类型数组
     * @return 包装类型数组
     */
    public static Character[] wrap(char... values){
        final int length = values.length;
        Character[] array = new Character[length];
        for(int i = 0; i < length; i++){
            array[i] = values[i];
        }
        return array;
    }
    
    /**
     * 将基本类型数组包装为包装类型
     * @param values 基本类型数组
     * @return 包装类型数组
     */
    public static Byte[] wrap(byte... values){
        final int length = values.length;
        Byte[] array = new Byte[length];
        for(int i = 0; i < length; i++){
            array[i] = values[i];
        }
        return array;
    }
    
    /**
     * 将基本类型数组包装为包装类型
     * @param values 基本类型数组
     * @return 包装类型数组
     */
    public static Short[] wrap(short... values){
        final int length = values.length;
        Short[] array = new Short[length];
        for(int i = 0; i < length; i++){
            array[i] = values[i];
        }
        return array;
    }
    
    /**
     * 将基本类型数组包装为包装类型
     * @param values 基本类型数组
     * @return 包装类型数组
     */
    public static Float[] wrap(float... values){
        final int length = values.length;
        Float[] array = new Float[length];
        for(int i = 0; i < length; i++){
            array[i] = values[i];
        }
        return array;
    }
    
    /**
     * 将基本类型数组包装为包装类型
     * @param values 基本类型数组
     * @return 包装类型数组
     */
    public static Double[] wrap(double... values){
        final int length = values.length;
        Double[] array = new Double[length];
        for(int i = 0; i < length; i++){
            array[i] = values[i];
        }
        return array;
    }
    
    /**
     * 将基本类型数组包装为包装类型
     * @param values 基本类型数组
     * @return 包装类型数组
     */
    public static Boolean[] wrap(boolean... values){
        final int length = values.length;
        Boolean[] array = new Boolean[length];
        for(int i = 0; i < length; i++){
            array[i] = values[i];
        }
        return array;
    }
    
    /**
     * 判定给定对象是否为数组类型
     * @param obj 对象
     * @return 是否为数组类型
     */
    public static boolean isArray(Object obj){
        return obj.getClass().isArray();
    }
    
    /**
     * 数组或集合转String
     * 
     * @param obj 集合或数组对象
     * @return 数组字符串,与集合转字符串格式相同
     */
    public static String toString(Object obj) {
        if (null == obj) {
            return null;
        }
        if (isArray(obj)) {
            try {
                return Arrays.deepToString((Object[]) obj);
            } catch (Exception e) {
                final String className = obj.getClass().getComponentType().getName();
                switch (className) {
                    case "long":
                        return Arrays.toString((long[]) obj);
                    case "int":
                        return Arrays.toString((int[]) obj);
                    case "short":
                        return Arrays.toString((short[]) obj);
                    case "char":
                        return Arrays.toString((char[]) obj);
                    case "byte":
                        return Arrays.toString((byte[]) obj);
                    case "boolean":
                        return Arrays.toString((boolean[]) obj);
                    case "float":
                        return Arrays.toString((float[]) obj);
                    case "double":
                        return Arrays.toString((double[]) obj);
                    default:
                        throw new ToolBoxException(e);
                }
            }
        }
        return obj.toString();
    }
}