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

com.maxifier.mxcache.impl.resource.ResourceViewDependencyNodeVisitor Maven / Gradle / Ivy

/*
 * Copyright (c) 2008-2014 Maxifier Ltd. All Rights Reserved.
 */
package com.maxifier.mxcache.impl.resource;

import com.maxifier.mxcache.impl.resource.nodes.ResourceViewable;
import gnu.trove.set.hash.THashSet;

import java.util.Queue;
import java.util.Set;

/**
 * ResourceViewDependencyNodeVisitor
 *
 * @author Elena Saymanina ([email protected]) (2013-07-05 12:54)
 */
public class ResourceViewDependencyNodeVisitor implements DependencyNodeVisitor {
    private final Set resourceViewableNodes;
    private final Set allNodes;
    private final Queue queue;

    public ResourceViewDependencyNodeVisitor(Set resourceViewableNodes, Queue queue) {
        this.resourceViewableNodes = resourceViewableNodes;
        this.allNodes = new THashSet();
        this.queue = queue;
    }

    @Override
    public void visit(DependencyNode node) {
        if (node instanceof ResourceViewable) {
            resourceViewableNodes.add(node);
        }
        if (allNodes.add(node)) {
            queue.add(node);
        }
    }

    @Override
    public Set getNodes() {
        return resourceViewableNodes;
    }

    @Override
    public Queue getQueue() {
        return queue;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy