Search in sources :

Example 1 with ImageData

use of com.adobe.cq.wcm.core.components.models.datalayer.ImageData in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class DataLayerSupplierImpl method extend.

/**
 * Construct a DataLayerSupplier from existing ComponentData.
 *
 * @param data The existing component data.
 * @return A new DataLayerSupplier that uses the field values from the provided component data.
 */
public static DataLayerSupplier extend(@NotNull final ComponentData data) {
    // set component field value suppliers
    final DataLayerSupplierImpl supplier = new DataLayerSupplierImpl(DataLayerSupplier.EMPTY_SUPPLIER).setId(data::getId).setType(data::getType).setLastModifiedDate(data::getLastModifiedDate).setParentId(data::getParentId).setTitle(data::getTitle).setDescription(data::getDescription).setText(data::getText).setLinkUrl(data::getLinkUrl);
    // set page field value suppliers
    if (data instanceof PageData) {
        PageData pageData = (PageData) data;
        supplier.setUrl(pageData::getUrl).setTags(pageData::getTags).setTemplatePath(pageData::getTemplatePath).setLanguage(pageData::getLanguage);
    }
    // set container field value suppliers
    if (data instanceof ContainerData) {
        supplier.setShownItems(((ContainerData) data)::getShownItems);
    }
    // set image component field value suppliers
    if (data instanceof ImageData) {
        supplier.setAssetData(((ImageData) data)::getAssetData);
    }
    return supplier;
}
Also used : PageData(com.adobe.cq.wcm.core.components.models.datalayer.PageData) ImageData(com.adobe.cq.wcm.core.components.models.datalayer.ImageData) ContainerData(com.adobe.cq.wcm.core.components.models.datalayer.ContainerData)

Aggregations

ContainerData (com.adobe.cq.wcm.core.components.models.datalayer.ContainerData)1 ImageData (com.adobe.cq.wcm.core.components.models.datalayer.ImageData)1 PageData (com.adobe.cq.wcm.core.components.models.datalayer.PageData)1