class CreateAggregate extends SchemaStatement {

    private String name;
    private String javaClassName;
    private boolean ifNotExists;
    private boolean force;

    public CreateAggregate(ServerSession session, Schema schema) {
        super(session, schema);
    }

    @Override
    public int getType() {
        return SQLStatement.CREATE_AGGREGATE;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setJavaClassName(String string) {
        this.javaClassName = string;
    }

    public void setIfNotExists(boolean ifNotExists) {
        this.ifNotExists = ifNotExists;
    }

    public void setForce(boolean force) {
        this.force = force;
    }

    @Override
    public int update() {<FILL_FUNCTION_BODY>}
}

        session.getUser().checkAdmin();
        DbObjectLock lock = schema.tryExclusiveLock(DbObjectType.AGGREGATE, session);
        if (lock == null)
            return -1;

        if (schema.findAggregate(session, name) != null || schema.findFunction(session, name) != null) {
            if (!ifNotExists) {
                throw DbException.get(ErrorCode.FUNCTION_ALIAS_ALREADY_EXISTS_1, name);
            }
        } else {
            int id = getObjectId();
            UserAggregate aggregate = new UserAggregate(schema, id, name, javaClassName, force);
            schema.add(session, aggregate, lock);
        }
        return 0;
    
<methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema