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

org.nuiton.topia.it.mapping.test3.A33Abstract Maven / Gradle / Ivy

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

/*-
 * #%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.Collection;
import java.util.LinkedList;
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 A33Abstract extends AbstractTopiaEntity implements A33 {

    /**
     * Nom de l'attribut en BD : roleB33
     */
    protected Collection roleB33;

    private static final long serialVersionUID = 3918801519787651641L;

    @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_ROLE_B33, Collection.class, B33.class, roleB33);
    }

    @Override
    public void addRoleB33(B33 roleB33) {
        if (this.roleB33 == null) {
            this.roleB33 = new LinkedList();
        }
        if (roleB33.getRoleA33() == null) {
            roleB33.setRoleA33(new java.util.LinkedList());
        }
        roleB33.getRoleA33().add(this);
        this.roleB33.add(roleB33);
    }

    @Override
    public void addAllRoleB33(Iterable roleB33) {
        if (roleB33 == null) {
            return;
        }
        for (B33 item : roleB33) {
            addRoleB33(item);
        }
    }

    @Override
    public void setRoleB33(Collection roleB33) {
        this.roleB33 = roleB33;
    }

    @Override
    public void removeRoleB33(B33 roleB33) {
        if (this.roleB33 == null || !this.roleB33.remove(roleB33)) {
            throw new IllegalArgumentException("List does not contain given element");
        }
        roleB33.getRoleA33().remove(this);
    }

    @Override
    public void clearRoleB33() {
        if (this.roleB33 == null) {
            return;
        }
        for (B33 item : this.roleB33) {
            item.getRoleA33().remove(this);
        }
        this.roleB33.clear();
    }

    @Override
    public Collection getRoleB33() {
        return roleB33;
    }

    @Override
    public B33 getRoleB33ByTopiaId(String topiaId) {
        return TopiaEntityHelper.getEntityByTopiaId(roleB33, topiaId);
    }

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

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

    @Override
    public boolean isRoleB33Empty() {
        int size = sizeRoleB33();
        return size == 0;
    }

    @Override
    public boolean isRoleB33NotEmpty() {
        boolean empty = isRoleB33Empty();
        return ! empty;
    }

    @Override
    public boolean containsRoleB33(B33 roleB33) {
        boolean contains = this.roleB33 !=null && this.roleB33.contains(roleB33);
        return contains;
    }

} //A33Abstract




© 2015 - 2025 Weber Informatics LLC | Privacy Policy