Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed to the Nervousync Studio (NSYC) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*/
package com.nervousync.utils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
/**
* @author Steven Wee [email protected]
* @version $Revision: 1.0 $ $Date: Jan 13, 2010 4:27:49 PM $
*/
public final class CollectionUtils {
private CollectionUtils() {
}
/**
* Sort number collection
* @param collection
* @return
*/
public static List sort(Collection collection) {
List returnList = new ArrayList();
Iterator iterator = collection.iterator();
while (iterator.hasNext()) {
returnList.add(iterator.next());
}
Collections.sort(returnList);
return returnList;
}
/**
* Sort number collection and reverse result
* @param collection
* @return
*/
public static List sortAndReverse(Collection collection) {
List returnList = new ArrayList();
Iterator iterator = collection.iterator();
while (iterator.hasNext()) {
returnList.add(iterator.next());
}
Collections.sort(returnList);
Collections.reverse(returnList);
return returnList;
}
/**
* Return true if the supplied Collection is null
* or empty. Otherwise, return false.
* @param collection the Collection to check
* @return whether the given Collection is empty
*/
public static boolean isEmpty(Collection> collection) {
return (collection == null || collection.isEmpty());
}
/**
* Return true if the supplied Map is null
* or empty. Otherwise, return false.
* @param map the Map to check
* @return whether the given Map is empty
*/
public static boolean isEmpty(Map, ?> map) {
return (map == null || map.isEmpty());
}
/**
* Convert the supplied array into a List. A primitive array gets
* converted into a List of the appropriate wrapper type.
*
A null source value will be converted to an
* empty List.
* @param source the (potentially primitive) array
* @return the converted List result
* @see ObjectUtils#toObjectArray(Object)
*/
public static List> arrayToList(Object source) {
return Arrays.asList(ObjectUtils.toObjectArray(source));
}
/**
* Convert arrays to list
* @param a
* @return
*/
public static List asList(T[] a) {
return Arrays.asList(a);
}
/**
* Merge the given array into the given Collection.
* @param array the array to merge (may be null)
* @param collection the target Collection to merge the array into
*/
public static void mergeArrayIntoCollection(Object array, Collection