| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| AbstractDecoratedGraph |
|
| 1.0;1 |
| 1 | /* | |
| 2 | This file is part of Combean. | |
| 3 | ||
| 4 | Combean is free software; you can redistribute it and/or modify | |
| 5 | it under the terms of the GNU General Public License as published by | |
| 6 | the Free Software Foundation; either version 2 of the License, or | |
| 7 | (at your option) any later version. | |
| 8 | ||
| 9 | Combean is distributed in the hope that it will be useful, | |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | GNU General Public License for more details. | |
| 13 | ||
| 14 | You should have received a copy of the GNU General Public License | |
| 15 | along with Combean; if not, write to the Free Software | |
| 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 17 | */ | |
| 18 | /* | |
| 19 | * Created on 25.03.2005 | |
| 20 | * | |
| 21 | */ | |
| 22 | package net.sourceforge.combean.graph.decorators; | |
| 23 | ||
| 24 | import net.sourceforge.combean.interfaces.graph.Graph; | |
| 25 | import net.sourceforge.combean.interfaces.graph.prop.AddEdgeGraphProp; | |
| 26 | import net.sourceforge.combean.interfaces.graph.prop.AddNodeGraphProp; | |
| 27 | import net.sourceforge.combean.interfaces.graph.prop.NestedGraphProp; | |
| 28 | ||
| 29 | /** | |
| 30 | * Convenience base class for decorators of graphs, i.e., classes which | |
| 31 | * implement a graph property and enhance the functionality of an inner | |
| 32 | * graph property object by intercepting calls to it. | |
| 33 | * | |
| 34 | * @author schickin | |
| 35 | * | |
| 36 | */ | |
| 37 | public abstract class AbstractDecoratedGraph implements NestedGraphProp { | |
| 38 | ||
| 39 | 69 | private Graph g = null; |
| 40 | ||
| 41 | /** | |
| 42 | * Constructor | |
| 43 | * | |
| 44 | * @param g the graph to be decorated | |
| 45 | */ | |
| 46 | public AbstractDecoratedGraph(Graph g) { | |
| 47 | 69 | super(); |
| 48 | ||
| 49 | 69 | this.g = g; |
| 50 | 69 | } |
| 51 | ||
| 52 | /* (non-Javadoc) | |
| 53 | * @see net.sourceforge.combean.interfaces.graph.Graph#getNodeClass() | |
| 54 | */ | |
| 55 | public Class getNodeClass() { | |
| 56 | 0 | return this.g.getNodeClass(); |
| 57 | } | |
| 58 | ||
| 59 | /* (non-Javadoc) | |
| 60 | * @see net.sourceforge.combean.interfaces.graph.Graph#getEdgeClass() | |
| 61 | */ | |
| 62 | public Class getEdgeClass() { | |
| 63 | 0 | return this.g.getEdgeClass(); |
| 64 | } | |
| 65 | ||
| 66 | /* (non-Javadoc) | |
| 67 | * @see net.sourceforge.combean.interfaces.graph.NestedGraphProp#getNestedGraph() | |
| 68 | */ | |
| 69 | public Graph getNestedGraph() { | |
| 70 | 48 | return this.g; |
| 71 | } | |
| 72 | ||
| 73 | /** | |
| 74 | * Check whether the given property refers to the fact that the graph | |
| 75 | * shall be modifiable | |
| 76 | * | |
| 77 | * @param wantedProp | |
| 78 | * @return true if either the set of edges or of the nodes in the graph | |
| 79 | * is modifiable. | |
| 80 | */ | |
| 81 | protected boolean isModifiableGraphProp(Class wantedProp) { | |
| 82 | 27 | return AddNodeGraphProp.class.isAssignableFrom(wantedProp) || |
| 83 | AddEdgeGraphProp.class.isAssignableFrom(wantedProp); | |
| 84 | } | |
| 85 | } |