org.kuali.rice.core.api.mo
Class ModelObjectUtils

java.lang.Object
  extended by org.kuali.rice.core.api.mo.ModelObjectUtils

public class ModelObjectUtils
extends Object

A set of simple utilities to assist with common idioms in immutable model objects and their builders.

Author:
Kuali Rice Team (rice.collab@kuali.org)

Method Summary
static
<T> List<T>
buildImmutableCopy(List<? extends ModelBuilder> builderList)
          Takes the given list of ModelBuilder objects and invokes the ModelBuilder.build() method on each of them, adding them to a new list and return an unmodifiable copy.
static
<T> List<T>
createImmutableCopy(List<T> listToCopy)
          Takes the given list and returns an unmodifiable copy of that list containing the same elements as the original list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

buildImmutableCopy

public static <T> List<T> buildImmutableCopy(List<? extends ModelBuilder> builderList)
Takes the given list of ModelBuilder objects and invokes the ModelBuilder.build() method on each of them, adding them to a new list and return an unmodifiable copy. If the given list is empty or null, will return an empty and unmodifiable list.

Type Parameters:
T - the type of the object that is built by the builders in the list, it is up to the caller of this method to ensure they define the proper parameterized list for the return type.
Parameters:
builderList - the list of builders to build and add to resulting list, may be empty or null
Returns:
an unmodifiable list containing objects built from the given list of model builders

createImmutableCopy

public static <T> List<T> createImmutableCopy(List<T> listToCopy)
Takes the given list and returns an unmodifiable copy of that list containing the same elements as the original list. This method handles a null list being passed to it by returning an unmodifiable empty list.

Type Parameters:
T - the type of the elements in the given list
Parameters:
listToCopy - the list to copy
Returns:
an unmodifiable copy containing the same elements as the given list


Copyright © 2004-2011 The Kuali Foundation. All Rights Reserved.