if (ec == null) throw new IllegalStateException("EditingContext is null. Required to know which model group to use.");
    public static EOAttribute createAggregateAttribute(EOEditingContext ec,                                                       String function,                                                       String attributeName,                                                       String entityName) {        if (ec == null)            throw new IllegalStateException("EditingContext is null. Required to know which model group to use.");        if (function == null)            throw new IllegalStateException("Function is null.");        if (attributeName == null)            throw new IllegalStateException("Attribute name is null.");        if (entityName == null)            throw new IllegalStateException("Entity name is null.");                EOEntity entity = EOUtilities.entityNamed(ec, entityName);        if (entity == null)            throw new IllegalStateException("Unable find entity named: " + entityName);                EOAttribute attribute = entity.attributeNamed(attributeName);        if (attribute == null)            throw new IllegalStateException("Unable find attribute named: " + attributeName                                            + " for entity: " + entityName);                EOAttribute aggregate = new EOAttribute();        aggregate.setName("p_object" + function + "Attribute");        aggregate.setColumnName("p_object" + function + "Attribute");        aggregate.setClassName("java.lang.Number");        aggregate.setValueType("i");        aggregate.setReadFormat(function + "(t0." + attribute.columnName() + ")");        return aggregate;    }