org.jgrapht.nio.BaseExporter Maven / Gradle / Ivy
The newest version!
/*
* (C) Copyright 2019-2023, by Dimitrios Michail and Contributors.
*
* JGraphT : a free Java graph-theory library
*
* See the CONTRIBUTORS.md file distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the
* GNU Lesser General Public License v2.1 or later
* which is available at
* http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html.
*
* SPDX-License-Identifier: EPL-2.0 OR LGPL-2.1-or-later
*/
package org.jgrapht.nio;
import java.util.*;
import java.util.function.*;
/**
* Base implementation for an exporter.
*
* @author Dimitrios Michail
*
* @param the graph vertex type
* @param the graph edge type
*/
public abstract class BaseExporter
{
/**
* A graph id provider
*/
protected Optional> graphIdProvider;
/**
* A graph attribute provider
*/
protected Optional>> graphAttributeProvider;
/**
* A vertex id provider
*/
protected Function vertexIdProvider;
/**
* A vertex attribute provider
*/
protected Optional>> vertexAttributeProvider;
/**
* An edge id provider
*/
protected Optional> edgeIdProvider;
/**
* An edge attribute provider
*/
protected Optional>> edgeAttributeProvider;
/**
* Constructor
*
* @param vertexIdProvider the vertex id provider to use. Cannot be null.
*/
public BaseExporter(Function vertexIdProvider)
{
this.vertexIdProvider = Objects.requireNonNull(vertexIdProvider);
this.graphIdProvider = Optional.empty();
this.graphAttributeProvider = Optional.empty();
this.vertexAttributeProvider = Optional.empty();
this.edgeIdProvider = Optional.empty();
this.edgeAttributeProvider = Optional.empty();
}
/**
* Get the graph id provider.
*
* @return the graph id provider as an {@link Optional}.
*/
public Optional> getGraphIdProvider()
{
return graphIdProvider;
}
/**
* Set the graph id provider.
*
* @param graphIdProvider the graph id provider
*/
public void setGraphIdProvider(Supplier graphIdProvider)
{
this.graphIdProvider = Optional.ofNullable(graphIdProvider);
}
/**
* Get the graph attribute provider.
*
* @return the graph attribute provider as an {@link Optional}.
*/
public Optional>> getGraphAttributeProvider()
{
return graphAttributeProvider;
}
/**
* Set the graph attribute provider.
*
* @param graphAttributeProvider the graph attribute provider
*/
public void setGraphAttributeProvider(Supplier
© 2015 - 2025 Weber Informatics LLC | Privacy Policy