public void setType(Class type) { if (type == null || type == Object.class) this.type = null; else if (isEmpty()) this.type = type; else { type = Data.commonType(type, getCommonType()); if (type != null) this.type = type; } }
public Class getCommonType() { Class t = null; Iterator i = iterator(); while (i.hasNext()) { Object e = i.next(); if (e == null) continue; else if (t == null) t = e.getClass(); else { t = Data.commonType(t, e.getClass()); if (t == null || t == Object.class) return null; } } return t; }