Google Collections Equivalent to Apache Commons ArrayUtils.toObject and ArrayUtils.toPrimitive Collections

Because everyone praises Google Collections (like here ) Why can't I find an equivalent ArrayUtils.toObject()and ArrayUtils.toPrimitive()? Is it really unsuitable? did i miss this?

+3
source share
1 answer

Honestly, I'm not sure that any of these methods should even qualify as an operation related to the collection, and so I wonder why they are even there in the first place.

To clarify the bit, collections are usually a group of objects with some semantic data linking them together, while arrays are just a predefined set of something. This semantic data can be information about the acceptance or rejection of zeros, duplicates, objects of incorrect types or invalid field values, etc.

In most cases, since not all collections collect internal arrays, however, the array itself is not a collection. To qualify as a collection, it needs some appropriate magic, such as deleting and adding objects to arbitrary positions, and arrays cannot do this. I doubt very much that you will ever see array support in Google collections, since arrays are not collections.

, Google Collections Google Guava, / , , com.google.common.primitives, Booleans#asList(boolean... backingArray) Booleans#toArray(Collection<Boolean> collection).

, Apache Commons Collection .toObject() .toPrimitive() , .

+8

Source: https://habr.com/ru/post/1726888/


All Articles