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

org.jgrapht.io.AbstractBaseImporter Maven / Gradle / Ivy

There is a newer version: 1.5.2
Show newest version
/*
 * (C) Copyright 2017-2017, by Dimitrios Michail and Contributors.
 *
 * JGraphT : a free Java graph-theory library
 *
 * This program and the accompanying materials are dual-licensed under
 * either
 *
 * (a) the terms of the GNU Lesser General Public License version 2.1
 * as published by the Free Software Foundation, or (at your option) any
 * later version.
 *
 * or (per the licensee's choosing)
 *
 * (b) the terms of the Eclipse Public License v1.0 as published by
 * the Eclipse Foundation.
 */
package org.jgrapht.io;

import java.util.*;

import org.jgrapht.*;

/**
 * Base implementation for a graph importer.
 *
 * @param  the graph vertex type
 * @param  the graph edge type
 *
 * @author Dimitrios Michail
 * @since March 2017
 */
abstract class AbstractBaseImporter
{
    /**
     * Constructs new vertices
     */
    protected VertexProvider vertexProvider;

    /**
     * Constructs new edges
     */
    protected EdgeProvider edgeProvider;

    /**
     * Updates already constructed vertices
     */
    protected ComponentUpdater vertexUpdater;

    /**
     * Updates graph properties
     */
    protected ComponentUpdater> graphUpdater;

    /**
     * Constructor
     *
     * @param vertexProvider the vertex provider. Must not be null.
     * @param edgeProvider the edge provider. Must not be null.
     */
    public AbstractBaseImporter(VertexProvider vertexProvider, EdgeProvider edgeProvider)
    {
        this(vertexProvider, edgeProvider, (c, a) -> {
        }, (c, a) -> {
        });
    }

    /**
     * Constructor
     *
     * @param vertexProvider the vertex provider. Must not be null.
     * @param edgeProvider the edge provider. Must not be null.
     * @param vertexUpdater the vertex updater. Must not be null.
     * @param graphUpdater the graph updater. Must not be null.
     */
    public AbstractBaseImporter(
        VertexProvider vertexProvider, EdgeProvider edgeProvider,
        ComponentUpdater vertexUpdater, ComponentUpdater> graphUpdater)
    {
        this.vertexProvider =
            Objects.requireNonNull(vertexProvider, "Vertex provider cannot be null");
        this.edgeProvider = Objects.requireNonNull(edgeProvider, "Edge provider cannot be null");
        this.vertexUpdater = Objects.requireNonNull(vertexUpdater, "Vertex updater cannot be null");
        this.graphUpdater = Objects.requireNonNull(graphUpdater, "Graph updater cannot be null");
    }

    /**
     * Get the vertex provider
     *
     * @return the vertex provider
     */
    public VertexProvider getVertexProvider()
    {
        return vertexProvider;
    }

    /**
     * Set the vertex provider
     *
     * @param vertexProvider the new vertex provider. Must not be null.
     */
    public void setVertexProvider(VertexProvider vertexProvider)
    {
        this.vertexProvider =
            Objects.requireNonNull(vertexProvider, "Vertex provider cannot be null");
    }

    /**
     * Get the edge provider
     *
     * @return The edge provider
     */
    public EdgeProvider getEdgeProvider()
    {
        return edgeProvider;
    }

    /**
     * Set the edge provider.
     *
     * @param edgeProvider the new edge provider. Must not be null.
     */
    public void setEdgeProvider(EdgeProvider edgeProvider)
    {
        this.edgeProvider = Objects.requireNonNull(edgeProvider, "Edge provider cannot be null");
    }

    /**
     * Get the vertex updater
     *
     * @return the vertex updater
     */
    public ComponentUpdater getVertexUpdater()
    {
        return vertexUpdater;
    }

    /**
     * Set the vertex updater.
     *
     * @param vertexUpdater the new vertex updater. Must not be null.
     */
    public void setVertexUpdater(ComponentUpdater vertexUpdater)
    {
        this.vertexUpdater = Objects.requireNonNull(vertexUpdater, "Vertex updater cannot be null");
    }

    /**
     * Get the graph updater.
     *
     * @return the graph updater
     */
    public ComponentUpdater> getGraphUpdater()
    {
        return graphUpdater;
    }

    /**
     * Set the graph updater.
     *
     * @param graphUpdater the new graph updater. Must not be null.
     */
    public void setGraphUpdater(ComponentUpdater> graphUpdater)
    {
        this.graphUpdater = Objects.requireNonNull(graphUpdater, "Graph updater cannot be null");
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy