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 private EntityUtils() {
12 throw new UnsupportedOperationException("do not call.");
13 }
14
15 public static <T extends Defaultable & Inactivatable> T getDefaultItem( Collection<T> collection ) {
16
17 if (CollectionUtils.isEmpty(collection)) {
18 return null;
19 }
20 for ( T item : collection ) {
21 if ( item.isDefaultValue() && item.isActive() ) {
22 return (T)item;
23 }
24 }
25
26 for ( T item : collection ) {
27 return item;
28 }
29
30 return null;
31 }
32 }