001/* Copyright (C) 2013 TU Dortmund
002 * This file is part of AutomataLib, http://www.automatalib.net/.
003 * 
004 * AutomataLib is free software; you can redistribute it and/or
005 * modify it under the terms of the GNU Lesser General Public
006 * License version 3.0 as published by the Free Software Foundation.
007 * 
008 * AutomataLib is distributed in the hope that it will be useful,
009 * but WITHOUT ANY WARRANTY; without even the implied warranty of
010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
011 * Lesser General Public License for more details.
012 * 
013 * You should have received a copy of the GNU Lesser General Public
014 * License along with AutomataLib; if not, see
015 * http://www.gnu.de/documents/lgpl.en.html.
016 */
017package net.automatalib.graphs.abstractimpl;
018
019import java.util.HashMap;
020
021import net.automatalib.commons.util.mappings.MapMapping;
022import net.automatalib.commons.util.mappings.MutableMapping;
023import net.automatalib.graphs.IndefiniteGraph;
024
025public abstract class AbstractIndefiniteGraph<N, E> implements IndefiniteGraph<N, E> {
026
027        /**
028         * Provides a realization for {@link IndefiniteGraph#createStaticNodeMapping()}
029         * by defaulting to a {@link HashMap} backed mapping.
030         * @see IndefiniteGraph#createStaticNodeMapping()
031         */
032        public static <N,E,V> MutableMapping<N,V> createStaticNodeMapping(IndefiniteGraph<N,E> $this) {
033                return new MapMapping<>(new HashMap<N,V>());
034        }
035        
036        /**
037         * Provides a realization for {@link IndefiniteGraph#createDynamicNodeMapping()}
038         * by defaulting to a {@link HashMap} backed mapping.
039         * @see IndefiniteGraph#createDynamicNodeMapping()
040         */
041        public static <N,E,V> MutableMapping<N,V> createDynamicNodeMapping(IndefiniteGraph<N,E> $this) {
042                return new MapMapping<>(new HashMap<N,V>());
043        }
044        
045
046        /*
047         * (non-Javadoc)
048         * @see net.automatalib.graphs.IndefiniteGraph#createStaticNodeMapping()
049         */
050        @Override
051        public <V> MutableMapping<N, V> createStaticNodeMapping() {
052                return createStaticNodeMapping(this);
053        }
054
055        /*
056         * (non-Javadoc)
057         * @see net.automatalib.graphs.IndefiniteGraph#createDynamicNodeMapping()
058         */
059        @Override
060        public <V> MutableMapping<N, V> createDynamicNodeMapping() {
061                return createDynamicNodeMapping(this);
062        }
063
064}