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

org.nuiton.topia.it.mapping.test5.A5Abstract Maven / Gradle / Ivy

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

/*-
 * #%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 A5Abstract extends AbstractTopiaEntity implements A5 {

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

    private static final long serialVersionUID = 3906419893594252133L;

    @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_B5, Collection.class, B5.class, b5);
    }

    @Override
    public void addB5(B5 b5) {
        if (this.b5 == null) {
            this.b5 = new LinkedList();
        }
        this.b5.add(b5);
    }

    @Override
    public void addAllB5(Iterable b5) {
        if (b5 == null) {
            return;
        }
        for (B5 item : b5) {
            addB5(item);
        }
    }

    @Override
    public void setB5(Collection b5) {
        this.b5 = b5;
    }

    @Override
    public void removeB5(B5 b5) {
        if (this.b5 == null || !this.b5.remove(b5)) {
            throw new IllegalArgumentException("List does not contain given element");
        }
    }

    @Override
    public void clearB5() {
        if (this.b5 == null) {
            return;
        }
        this.b5.clear();
    }

    @Override
    public Collection getB5() {
        return b5;
    }

    @Override
    public B5 getB5ByTopiaId(String topiaId) {
        return TopiaEntityHelper.getEntityByTopiaId(b5, topiaId);
    }

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

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

    @Override
    public boolean isB5Empty() {
        int size = sizeB5();
        return size == 0;
    }

    @Override
    public boolean isB5NotEmpty() {
        boolean empty = isB5Empty();
        return ! empty;
    }

    @Override
    public boolean containsB5(B5 b5) {
        boolean contains = this.b5 !=null && this.b5.contains(b5);
        return contains;
    }

} //A5Abstract




© 2015 - 2025 Weber Informatics LLC | Privacy Policy