net.sourceforge.jaulp.collections
Class ListUtils

java.lang.Object
  extended by net.sourceforge.jaulp.collections.ListUtils

public class ListUtils
extends java.lang.Object

Utility class for the use of List object.

Version:
1.0
Author:
Asterios Raptis

Constructor Summary
ListUtils()
           
 
Method Summary
static
<T> boolean
containAtleastOneObject(java.util.List<T> toSearch, java.util.List<T> search)
          This Method look in the List toSearch if at least one Object exists in the List search.
static
<T> T
getFirst(java.util.List<T> list)
          Gets the first object from the given List.
static
<T> T
getLast(java.util.List<T> list)
          Gets the last object from the given List.
static
<T> java.util.List<T>
getSameElementsFromLists(java.util.List<T> toSearch, java.util.List<T> search)
          The Method looks at both List and if they have same objects they are added to one List and will returns the result.
static boolean isNullOrEmpty(java.util.List list)
          Checks if a List is null or empty.
static void printCollection(java.util.Collection collection)
          Helper-Method for printing a Collection in the console.
static void printCollection(java.util.Collection collection, java.io.OutputStream out)
          Helper-Method for printing a Collection in the OutputStream.
static java.lang.Object removeFirst(java.util.List list)
          Removes the first object from the given List.
static java.lang.Object removeLast(java.util.List list)
          Removes the last object from the given List.
static
<T> java.util.List<T>
removeLastValues(java.util.ArrayList<T> v, int remove)
          The Method removeLastValues(ArrayList, int) remove the last Values.
static
<T> java.util.List<T>
revertOrder(java.util.List<T> listToRevert)
          Reverts the order from the given List.
static java.util.List splitListToParts(java.util.List list, int times)
          Splits the List to Parts to the specified times
static
<T> java.util.List<java.util.List<T>>
splitSetToParts(java.util.Set<T> set, int times)
          Splits the Set to Parts to the specified times
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListUtils

public ListUtils()
Method Detail

containAtleastOneObject

public static <T> boolean containAtleastOneObject(java.util.List<T> toSearch,
                                                  java.util.List<T> search)
This Method look in the List toSearch if at least one Object exists in the List search.

Parameters:
toSearch - The List to search.
search - The List to inspect.
Returns:
Returns true if there is at least one Object equal from the two List otherwise false.

getFirst

public static <T> T getFirst(java.util.List<T> list)
Gets the first object from the given List.

Parameters:
list - the List.
Returns:
Returns the first object from the given List or null if the List is empty or null.

getLast

public static <T> T getLast(java.util.List<T> list)
Gets the last object from the given List.

Parameters:
list - the List.
Returns:
Returns the last object from the given List or null if the List is empty or null.

getSameElementsFromLists

public static <T> java.util.List<T> getSameElementsFromLists(java.util.List<T> toSearch,
                                                             java.util.List<T> search)
The Method looks at both List and if they have same objects they are added to one List and will returns the result.

Parameters:
toSearch - The List to search.
search - The List to inspect.
Returns:
The List with the same objects.

isNullOrEmpty

public static boolean isNullOrEmpty(java.util.List list)
Checks if a List is null or empty.

Parameters:
list - The List to check.
Returns:
true if the list is null or empty otherwise false.

printCollection

public static void printCollection(java.util.Collection collection)
Helper-Method for printing a Collection in the console.

Parameters:
collection - The Collection to print.

printCollection

public static void printCollection(java.util.Collection collection,
                                   java.io.OutputStream out)
Helper-Method for printing a Collection in the OutputStream.

Parameters:
collection - The Collection to print.

removeFirst

public static java.lang.Object removeFirst(java.util.List list)
Removes the first object from the given List.

Parameters:
list - the List.
Returns:
Removes and returns the first object from the given List or null if the List is empty or null.

removeLast

public static java.lang.Object removeLast(java.util.List list)
Removes the last object from the given List.

Parameters:
list - the List.
Returns:
Removes and returns the last object from the given List or null if the List is empty or null.

removeLastValues

public static <T> java.util.List<T> removeLastValues(java.util.ArrayList<T> v,
                                                     int remove)
The Method removeLastValues(ArrayList, int) remove the last Values.

Parameters:
v - The Vector with the received Messages.
remove - How much to remove.

revertOrder

public static <T> java.util.List<T> revertOrder(java.util.List<T> listToRevert)
Reverts the order from the given List.

Parameters:
listToRevert - The List to revert.
Returns:
The reverted List.

splitListToParts

public static java.util.List splitListToParts(java.util.List list,
                                              int times)
Splits the List to Parts to the specified times

Parameters:
list - The List to Split
times - How to split.
Returns:
An List with the Splitted Parts

splitSetToParts

public static <T> java.util.List<java.util.List<T>> splitSetToParts(java.util.Set<T> set,
                                                                    int times)
Splits the Set to Parts to the specified times

Parameters:
set - The Set to Split
times - How to split.
Returns:
An ArrayList with the Splitted Parts


Copyright © 2010. All Rights Reserved.