|  1 |     | 
   package org.kuali.rice.kim.api.identity;  | 
  |  2 |     | 
     | 
  |  3 |     | 
   import org.apache.commons.collections.CollectionUtils;  | 
  |  4 |     | 
   import org.kuali.rice.core.api.mo.common.Defaultable;  | 
  |  5 |     | 
   import org.kuali.rice.core.api.mo.common.active.Inactivatable;  | 
  |  6 |     | 
     | 
  |  7 |     | 
   import java.util.Collection;  | 
  |  8 |     | 
     | 
  |  9 |     | 
   public class EntityUtils { | 
  |  10 |     | 
     | 
  |  11 |    0 |        private EntityUtils() { | 
  |  12 |    0 |            throw new UnsupportedOperationException("do not call."); | 
  |  13 |     | 
       }  | 
  |  14 |     | 
     | 
  |  15 |     | 
       public static <T extends Defaultable & Inactivatable> T getDefaultItem( Collection<T> collection ) { | 
  |  16 |     | 
                     | 
  |  17 |    30 |            if (CollectionUtils.isEmpty(collection)) { | 
  |  18 |    6 |                return null;  | 
  |  19 |     | 
           }  | 
  |  20 |    24 |                    for ( T item : collection ) { | 
  |  21 |    24 |                            if ( item.isDefaultValue() && item.isActive() ) { | 
  |  22 |    24 |                                    return (T)item;  | 
  |  23 |     | 
                           }  | 
  |  24 |     | 
                   }  | 
  |  25 |     | 
                     | 
  |  26 |    0 |                    for ( T item : collection ) { | 
  |  27 |    0 |                        return item;  | 
  |  28 |     | 
                   }  | 
  |  29 |     | 
                     | 
  |  30 |    0 |                    return null;  | 
  |  31 |     | 
           }  | 
  |  32 |     | 
   }  |