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

org.nuiton.topia.it.mapping.test6.A6Abstract Maven / Gradle / Ivy

The newest version!
package org.nuiton.topia.it.mapping.test6;

/*-
 * #%L
 * ToPIA :: IT
 * %%
 * Copyright (C) 2004 - 2024 Code Lutin
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public
 * License along with this program.  If not, see
 * .
 * #L%
 */

import java.util.LinkedList;
import java.util.List;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.TopiaEntityVisitor;
import org.nuiton.topia.persistence.TopiaException;
import org.nuiton.topia.persistence.internal.AbstractTopiaEntity;
import org.nuiton.topia.persistence.util.TopiaEntityHelper;

public abstract class A6Abstract extends AbstractTopiaEntity implements A6 {

    /**
     * Nom de l'attribut en BD : b6
     */
    protected List b6;

    private static final long serialVersionUID = 3545521917772837938L;

    @Override
    public void accept(TopiaEntityVisitor visitor) throws TopiaException {
        visitor.start(this);
        accept0(visitor);
        visitor.end(this);
    }

    protected void accept0(TopiaEntityVisitor visitor) throws TopiaException {
        visitor.visit(this, PROPERTY_B6, List.class, B6.class, b6);
    }

    @Override
    public void addB6(B6 b6) {
        fireOnPreWrite(PROPERTY_B6, null, b6);
        if (this.b6 == null) {
            this.b6 = new LinkedList();
        }
        this.b6.add(b6);
        fireOnPostWrite(PROPERTY_B6, this.b6.size(), null, b6);
    }

    @Override
    public void addB6(int index, B6 b6) {
        fireOnPreWrite(PROPERTY_B6, null, b6);
        if (this.b6 == null) {
            this.b6 = new LinkedList();
        }
        this.b6.add(index, b6);
        fireOnPostWrite(PROPERTY_B6, index, null, b6);
    }

    @Override
    public void addAllB6(Iterable b6) {
        if (b6 == null) {
            return;
        }
        for (B6 item : b6) {
            addB6(item);
        }
    }

    @Override
    public void setB6(List b6) {
        // Copy elements to keep data for fire with new reference
        List oldValue = this.b6 != null ? new LinkedList(this.b6) : null;
        fireOnPreWrite(PROPERTY_B6, oldValue, b6);
        this.b6 = b6;
        fireOnPostWrite(PROPERTY_B6, oldValue, b6);
    }

    @Override
    public void removeB6(B6 b6) {
        fireOnPreWrite(PROPERTY_B6, b6, null);
        if (this.b6 == null || !this.b6.remove(b6)) {
            throw new IllegalArgumentException("List does not contain given element");
        }
        fireOnPostWrite(PROPERTY_B6, this.b6.size() + 1, b6, null);
    }

    @Override
    public void removeB6(int index) {
        fireOnPreWrite(PROPERTY_B6, b6, null);
        if (this.b6 == null) {
            throw new IllegalArgumentException("List does not contain given element");
        }
        B6 oldValue = this.b6.remove(index);
        if (oldValue == null) {
            throw new IllegalArgumentException("List does not contain given element");
        }
        fireOnPostWrite(PROPERTY_B6, index, oldValue, null);
    }

    @Override
    public void clearB6() {
        if (this.b6 == null) {
            return;
        }
        List oldValue = new LinkedList(this.b6);
        fireOnPreWrite(PROPERTY_B6, oldValue, this.b6);
        this.b6.clear();
        fireOnPostWrite(PROPERTY_B6, oldValue, this.b6);
    }

    @Override
    public List getB6() {
        return b6;
    }

    @Override
    public B6 getB6(int index) {
        return TopiaEntityHelper.getEntityByIndex(b6, index);
    }

    @Override
    public B6 getB6ByTopiaId(String topiaId) {
        return TopiaEntityHelper.getEntityByTopiaId(b6, topiaId);
    }

    @Override
    public List getB6TopiaIds() {
        List topiaIds = new LinkedList();
        List tmp = getB6();
        if (tmp != null) {
            for (TopiaEntity topiaEntity : tmp) {
                topiaIds.add(topiaEntity.getTopiaId());
            }
        }
        return topiaIds;
    }

    @Override
    public int sizeB6() {
        if (b6 == null) {
            return 0;
        }
        return b6.size();
    }

    @Override
    public boolean isB6Empty() {
        int size = sizeB6();
        return size == 0;
    }

    @Override
    public boolean isB6NotEmpty() {
        boolean empty = isB6Empty();
        return ! empty;
    }

    @Override
    public boolean containsB6(B6 b6) {
        boolean contains = this.b6 !=null && this.b6.contains(b6);
        return contains;
    }

} //A6Abstract




© 2015 - 2025 Weber Informatics LLC | Privacy Policy