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

net.n2oapp.framework.config.io.common.BadgeAwareIO Maven / Gradle / Ivy

There is a newer version: 7.28.2
Show newest version
package net.n2oapp.framework.config.io.common;

import net.n2oapp.framework.api.metadata.global.view.widget.table.ShapeType;
import net.n2oapp.framework.api.metadata.io.IOProcessor;
import net.n2oapp.framework.api.metadata.meta.badge.BadgeAware;
import net.n2oapp.framework.api.metadata.meta.badge.Position;
import org.jdom2.Element;

/**
 * Интерфейс чтения/записи компонентов {@link BadgeAware}
 */
public interface BadgeAwareIO {

    /**
     * Чтение/запись элемента, не использующего ссылки на поля
     */
    default void badge(Element e, T m, IOProcessor p) {
        p.attribute(e, "badge", m::getBadge, m::setBadge);
        p.attribute(e, "badge-color", m::getBadgeColor, m::setBadgeColor);
        p.attribute(e, "badge-image", m::getBadgeImage, m::setBadgeImage);
        defaults(e, m, p);
    }

    /**
     * Чтение/запись элемента, ссылающегося на поля
     */
    default void refBadge(Element e, T m, IOProcessor p) {
        p.attribute(e, "badge-field-id", m::getBadgeFieldId, m::setBadgeFieldId);
        p.attribute(e, "badge-color-field-id", m::getBadgeColorFieldId, m::setBadgeColorFieldId);
        p.attribute(e, "badge-image-field-id", m::getBadgeImageFieldId, m::setBadgeImageFieldId);
        defaults(e, m, p);
    }

    /**
     * Чтение/запись общих свойств
     */
    private void defaults(Element e, T m, IOProcessor p) {
        p.attributeEnum(e, "badge-position", m::getBadgePosition, m::setBadgePosition, Position.class);
        p.attributeEnum(e, "badge-image-position", m::getBadgeImagePosition, m::setBadgeImagePosition, Position.class);
        p.attributeEnum(e, "badge-shape", m::getBadgeShape, m::setBadgeShape, ShapeType.class);
        p.attributeEnum(e, "badge-image-shape", m::getBadgeImageShape, m::setBadgeImageShape, ShapeType.class);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy