All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.icfolson.aem.groovy.console.table.Table.groovy Maven / Gradle / Ivy

Go to download

The AEM Groovy Console provides an interface for running Groovy scripts in the AEM container. Scripts can be created to manipulate content in the JCR, call OSGi services, or execute arbitrary code using the AEM, Sling, or JCR APIs.

There is a newer version: 16.0.0
Show newest version
package com.icfolson.aem.groovy.console.table

class Table {

    List columns = []

    List> rows = []

    void columns(String... columnNames) {
        assert !columns, "columns are already defined"

        columns.addAll(columnNames)
    }

    void columns(List columnNames) {
        assert !columns, "columns are already defined"

        columns.addAll(columnNames)
    }

    void row(String... row) {
        assert columns, "columns must be defined before adding a row"
        assert row.length == columns.size(), "row data size does not match number of columns"

        rows.add(row as List)
    }

    void row(List row) {
        assert columns, "columns must be defined before adding a row"
        assert row.size() == columns.size(), "row data size does not match number of columns"

        rows.add(row)
    }

    void rows(List> rows) {
        assert columns, "columns must be defined before adding rows"

        rows.each { row ->
            assert row.size() == columns.size(), "one or more row data sizes does not match number of columns"
        }

        this.rows.addAll(rows)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy