package io.ebeaninternal.server.deploy;
import io.ebean.bean.BeanCollection;
import javax.persistence.PersistenceException;
import java.util.Collection;
import java.util.Map;
public class BeanCollectionUtil {
public static boolean isModified(Object collection) {
if ((collection instanceof BeanCollection<?>)) {
return ((BeanCollection<?>) collection).holdsModifications();
}
return true;
}
public static Collection<?> getActualEntries(Object o) {
if (o == null) {
return null;
}
if (o instanceof BeanCollection<?>) {
BeanCollection<?> bc = (BeanCollection<?>) o;
if (!bc.isPopulated()) {
return null;
}
return bc.getActualEntries();
}
if (o instanceof Map<?, ?>) {
return ((Map<?, ?>) o).entrySet();
} else if (o instanceof Collection<?>) {
return ((Collection<?>) o);
}
throw new PersistenceException("expecting a Map or Collection but got [" + o.getClass().getName() + "]");
}
public static Collection<?> getActualDetails(Object o) {
if (o == null) {
return null;
}
if (o instanceof BeanCollection<?>) {
BeanCollection<?> bc = (BeanCollection<?>) o;
if (!bc.isPopulated()) {
return null;
}
return bc.getActualDetails();
}
if (o instanceof Map<?, ?>) {
return ((Map<?, ?>) o).values();
} else if (o instanceof Collection<?>) {
return ((Collection<?>) o);
}
throw new PersistenceException("expecting a Map or Collection but got [" + o.getClass().getName() + "]");
}
}