Package com.cedarsoftware.util.convert
Class CollectionConversions
java.lang.Object
com.cedarsoftware.util.convert.CollectionConversions
Converts between arrays and collections while preserving collection characteristics.
Handles conversion from arrays to various collection types including:
- JDK collections (ArrayList, HashSet, etc.)
- Concurrent collections (ConcurrentSet, etc.)
- Special collections (Unmodifiable, Synchronized, etc.)
- Cedar Software collections (CaseInsensitiveSet, CompactSet, etc.)
- Author:
- John DeRegnaucourt ([email protected])
Copyright (c) Cedar Software LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
License
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
arrayToCollection
(Object array, Class<?> targetType) Converts an array to a collection, supporting special collection types and nested arrays.static Object
collectionToCollection
(Collection<?> source, Class<?> targetType) Converts a collection to another collection type, preserving characteristics.
-
Method Details
-
arrayToCollection
Converts an array to a collection, supporting special collection types and nested arrays.- Parameters:
array
- The source array to converttargetType
- The target collection type- Returns:
- A collection of the specified target type
-
collectionToCollection
Converts a collection to another collection type, preserving characteristics.- Parameters:
source
- The source collection to converttargetType
- The target collection type- Returns:
- A collection of the specified target type
-