= DataTable
:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Represents a collection of domain objects (typically entity instances).

== API

[source,java]
.DataTable.java
----
class DataTable {
  DataTable(ObjectSpecification elementType)     // <.>
  DataTable(ObjectSpecification elementType, Predicate<ObjectAssociation> columnFilter)     // <.>
  DataTable(ObjectSpecification elementType, Can<? extends ObjectAssociation> dataColumns)     // <.>
  DataTable(ObjectSpecification elementType, String tableFriendlyName, Can<? extends ObjectAssociation> dataColumns, Can<ManagedObject> dataElements)
  DataTable forDomainType(Class<?> domainType)     // <.>
  DataTable forDomainType(Class<?> domainType, Predicate<ObjectAssociation> columnFilter)     // <.>
  String getLogicalName()     // <.>
  int getElementCount()     // <.>
  Stream<ManagedObject> streamDataElements()
  DataTable addDataElementsFrom(DataTable otherTable)     // <.>
  DataTable setDataElements(Iterable<ManagedObject> dataElements)     // <.>
  void setDataElementPojos(Iterable<?> dataElementPojos)     // <.>
  DataTable populateEntities()     // <.>
  DataTable populateEntities(Query<?> query)     // <.>
  DataTable visit(CellVisitor visitor)
  DataTable visit(CellVisitor visitor, Predicate<DataColumn> columnFilter)
  Blob exportToBlob(CollectionContentsExporter exporter)     // <.>
  Predicate<ObjectAssociation> columnFilterIncluding(Where whereToInclude)
  Predicate<ObjectAssociation> columnFilterExcludingMixins()
  Predicate<ObjectAssociation> columnFilterIncludingEnabledForSnapshot()
}
----

<.> xref:#DataTable_ObjectSpecification[DataTable(ObjectSpecification)]
+
--
Returns an empty xref:refguide:core:index/metamodel/tabular/simple/DataTable.adoc[DataTable] for given domain object type, with all properties as columns, excluding mixed-in ones. (For more control on which columns to include, consider a different constructor.)
--
<.> xref:#DataTable_ObjectSpecification_Predicate[DataTable(ObjectSpecification, Predicate)]
+
--
Returns an empty xref:refguide:core:index/metamodel/tabular/simple/DataTable.adoc[DataTable] for given domain object type, with all (including mixed-in) associations as columns, that pass given _columnFilter_ . If the filter is _null_ it acts as a pass-through.
--
<.> xref:#DataTable_ObjectSpecification_Can[DataTable(ObjectSpecification, Can)]
+
--
Returns an empty xref:refguide:core:index/metamodel/tabular/simple/DataTable.adoc[DataTable] for given domain object type.
--
<.> xref:#forDomainType_Class[forDomainType(Class)]
+
--
Returns an empty xref:refguide:core:index/metamodel/tabular/simple/DataTable.adoc[DataTable] for given domain object type, with all properties as columns, excluding mixed-in ones. (For more control on which columns to include, consider _#forDomainType(Class, Predicate)_ or a constructor that fits.)
--
<.> xref:#forDomainType_Class_Predicate[forDomainType(Class, Predicate)]
+
--
Returns an empty xref:refguide:core:index/metamodel/tabular/simple/DataTable.adoc[DataTable] for given domain object type, with all (including mixed-in) associations as columns, that pass given _columnFilter_ . If the filter is _null_ it acts as a pass-through.
--
<.> xref:#getLogicalName_[getLogicalName()]
+
--
Unique within application scope, can act as an id.
--
<.> xref:#getElementCount_[getElementCount()]
+
--
Count data rows.
--
<.> xref:#addDataElementsFrom_DataTable[addDataElementsFrom(DataTable)]
+
--
Adds all data-elements from the other table to this table.
--
<.> xref:#setDataElements_Iterable[setDataElements(Iterable)]
+
--
Sets the data-elements of this table, which make up the rows of this table.
--
<.> xref:#setDataElementPojos_Iterable[setDataElementPojos(Iterable)]
+
--
Sets the data-elements of this table from given pojos, that are adapted to xref:refguide:core:index/metamodel/object/ManagedObject.adoc[ManagedObject] (s).
--
<.> xref:#populateEntities_[populateEntities()]
+
--
Populates this table from the underlying (default) persistence layer.
--
<.> xref:#populateEntities_Query[populateEntities(Query)]
+
--
Populates this table from the underlying (default) persistence layer, using given xref:refguide:applib:index/query/Query.adoc[Query] to refine the result.
--
<.> xref:#exportToBlob_CollectionContentsExporter[exportToBlob(CollectionContentsExporter)]
+
--
Typical use-case:
--

== Members

[#DataTable_ObjectSpecification]
=== DataTable(ObjectSpecification)

Returns an empty xref:refguide:core:index/metamodel/tabular/simple/DataTable.adoc[DataTable] for given domain object type, with all properties as columns, excluding mixed-in ones. (For more control on which columns to include, consider a different constructor.)

The table can be populated later on using _DataTable#setDataElements(Iterable)_ or _#setDataElementPojos(Iterable)_ .

[#DataTable_ObjectSpecification_Predicate]
=== DataTable(ObjectSpecification, Predicate)

Returns an empty xref:refguide:core:index/metamodel/tabular/simple/DataTable.adoc[DataTable] for given domain object type, with all (including mixed-in) associations as columns, that pass given _columnFilter_ . If the filter is _null_ it acts as a pass-through.

The table can be populated later on using _DataTable#setDataElements(Iterable)_ or _#setDataElementPojos(Iterable)_ .

[#DataTable_ObjectSpecification_Can]
=== DataTable(ObjectSpecification, Can)

Returns an empty xref:refguide:core:index/metamodel/tabular/simple/DataTable.adoc[DataTable] for given domain object type.

The table can be populated later on using _DataTable#setDataElements(Iterable)_ or _#setDataElementPojos(Iterable)_ .

[#forDomainType_Class]
=== forDomainType(Class)

Returns an empty xref:refguide:core:index/metamodel/tabular/simple/DataTable.adoc[DataTable] for given domain object type, with all properties as columns, excluding mixed-in ones. (For more control on which columns to include, consider _#forDomainType(Class, Predicate)_ or a constructor that fits.)

The table can be populated later on using _DataTable#setDataElements(Iterable)_ or _#setDataElementPojos(Iterable)_ .

[#forDomainType_Class_Predicate]
=== forDomainType(Class, Predicate)

Returns an empty xref:refguide:core:index/metamodel/tabular/simple/DataTable.adoc[DataTable] for given domain object type, with all (including mixed-in) associations as columns, that pass given _columnFilter_ . If the filter is _null_ it acts as a pass-through.

The table can be populated later on using _DataTable#setDataElements(Iterable)_ or _#setDataElementPojos(Iterable)_ .

[#getLogicalName_]
=== getLogicalName()

Unique within application scope, can act as an id.

[#getElementCount_]
=== getElementCount()

Count data rows.

[#addDataElementsFrom_DataTable]
=== addDataElementsFrom(DataTable)

Adds all data-elements from the other table to this table.

[#setDataElements_Iterable]
=== setDataElements(Iterable)

Sets the data-elements of this table, which make up the rows of this table.

[#setDataElementPojos_Iterable]
=== setDataElementPojos(Iterable)

Sets the data-elements of this table from given pojos, that are adapted to xref:refguide:core:index/metamodel/object/ManagedObject.adoc[ManagedObject] (s).

[#populateEntities_]
=== populateEntities()

Populates this table from the underlying (default) persistence layer.

[#populateEntities_Query]
=== populateEntities(Query)

Populates this table from the underlying (default) persistence layer, using given xref:refguide:applib:index/query/Query.adoc[Query] to refine the result.

[#exportToBlob_CollectionContentsExporter]
=== exportToBlob(CollectionContentsExporter)

Typical use-case:

----
{@code
----
