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

org.wicketstuff.DefaultAddAtStartStore Maven / Gradle / Ivy

package org.wicketstuff;

import org.apache.wicket.Component;

import java.util.*;
import java.util.concurrent.ConcurrentLinkedDeque;

/**
 * default store for elements added at start in quickview
 */
public class DefaultAddAtStartStore implements IAddAtStartStore {

    private ConcurrentLinkedDeque orderedIds = new ConcurrentLinkedDeque<>();

    public ConcurrentLinkedDeque getOrderedIds() {
        return orderedIds;
    }

    private Setids=new HashSet<>();

    public SetgetIds(){
        return ids;
    }

    @Override
    public boolean contains(final Component component) {
       return contains(component.getId());
    }

    @Override
    public boolean contains(final String componentId) {
        boolean contains = getIds().contains(componentId);
        return contains;
    }


    @Override
    public Iterator iterator() {
        return getOrderedIds().iterator();
    }


    @Override
    public int size() {
        return getIds().size();
    }

    /**
     * adds components id in store along with their indexes
     *
     * @param components component that are added at start
     */
    @Override
    public void add(final Component... components) {
        for (int i = components.length-1; i >=0; i--) {
            Component c = components[i];
            getOrderedIds().addFirst(c.getId());
            getIds().add(c.getId());
        }
    }


    /**
     * remove component id from store
     *
     * @param component
     */
    @Override
    public void remove(final Component component) {
        remove(component.getId());
    }

    /**
     * remove component id from store
     *
     * @param id
     */
    @Override
    public void remove(final String id) {
        getIds().remove(id);
        getOrderedIds().remove(id);
    }



}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy