| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| VetoableGraphChangeEvent |
|
| 1.0;1 |
| 1 | /* | |
| 2 | ||
| 3 | dsh-observable-graph Observable decorators for graph interfaces. | |
| 4 | Copyright (c) 2008-2013 held jointly by the individual authors. | |
| 5 | ||
| 6 | This library is free software; you can redistribute it and/or modify it | |
| 7 | under the terms of the GNU Lesser General Public License as published | |
| 8 | by the Free Software Foundation; either version 3 of the License, or (at | |
| 9 | your option) any later version. | |
| 10 | ||
| 11 | This library is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or | |
| 13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public | |
| 14 | License for more details. | |
| 15 | ||
| 16 | You should have received a copy of the GNU Lesser General Public License | |
| 17 | along with this library; if not, write to the Free Software Foundation, | |
| 18 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
| 19 | ||
| 20 | > http://www.fsf.org/licensing/licenses/lgpl.html | |
| 21 | > http://www.opensource.org/licenses/lgpl-license.php | |
| 22 | ||
| 23 | */ | |
| 24 | package org.dishevelled.observable.graph.event; | |
| 25 | ||
| 26 | import java.util.EventObject; | |
| 27 | ||
| 28 | import org.dishevelled.graph.Edge; | |
| 29 | import org.dishevelled.graph.Node; | |
| 30 | ||
| 31 | import org.dishevelled.observable.graph.ObservableGraph; | |
| 32 | ||
| 33 | /** | |
| 34 | * An event object representing a vetoable change about to be made to an observable graph. | |
| 35 | * | |
| 36 | * @param <N> node value type | |
| 37 | * @param <E> edge value type | |
| 38 | * @author Michael Heuer | |
| 39 | * @version $Revision$ $Date$ | |
| 40 | */ | |
| 41 | public class VetoableGraphChangeEvent<N, E> | |
| 42 | extends EventObject | |
| 43 | { | |
| 44 | /** Node about to be removed, if any. */ | |
| 45 | private final Node<N, E> node; | |
| 46 | ||
| 47 | /** Edge about to be removed if any. */ | |
| 48 | private final Edge<N, E> edge; | |
| 49 | ||
| 50 | /** Node value for an about to be created node, if any. */ | |
| 51 | private final N nodeValue; | |
| 52 | ||
| 53 | /** Source node for an about to be created edge, if any. */ | |
| 54 | private final Node<N, E> sourceNode; | |
| 55 | ||
| 56 | /** Target node for an about to be created edge, if any. */ | |
| 57 | private final Node<N, E> targetNode; | |
| 58 | ||
| 59 | /** Edge value for an about to be created edge, if any. */ | |
| 60 | private final E edgeValue; | |
| 61 | ||
| 62 | ||
| 63 | /** | |
| 64 | * Create a new vetoable graph change event with the | |
| 65 | * specified observable graph as the event source. | |
| 66 | * | |
| 67 | * @param source source of the event, must not be null | |
| 68 | */ | |
| 69 | public VetoableGraphChangeEvent(final ObservableGraph<N, E> source) | |
| 70 | { | |
| 71 | 6 | super(source); |
| 72 | 5 | node = null; |
| 73 | 5 | edge = null; |
| 74 | 5 | nodeValue = null; |
| 75 | 5 | sourceNode = null; |
| 76 | 5 | targetNode = null; |
| 77 | 5 | edgeValue = null; |
| 78 | 5 | } |
| 79 | ||
| 80 | /** | |
| 81 | * Create a new vetoable graph change event with the | |
| 82 | * specified observable graph as the event source and the specified | |
| 83 | * about to be removed node. | |
| 84 | * | |
| 85 | * @param source source of the event, must not be null | |
| 86 | * @param node about to be removed node | |
| 87 | */ | |
| 88 | public VetoableGraphChangeEvent(final ObservableGraph<N, E> source, final Node<N, E> node) | |
| 89 | { | |
| 90 | 6 | super(source); |
| 91 | 6 | this.node = node; |
| 92 | 6 | edge = null; |
| 93 | 6 | nodeValue = null; |
| 94 | 6 | sourceNode = null; |
| 95 | 6 | targetNode = null; |
| 96 | 6 | edgeValue = null; |
| 97 | 6 | } |
| 98 | ||
| 99 | /** | |
| 100 | * Create a new vetoable graph change event with the | |
| 101 | * specified observable graph as the event source and the | |
| 102 | * specified about to be removed edge. | |
| 103 | * | |
| 104 | * @param source source of the event, must not be null | |
| 105 | * @param edge about to be removed edge | |
| 106 | */ | |
| 107 | public VetoableGraphChangeEvent(final ObservableGraph<N, E> source, final Edge<N, E> edge) | |
| 108 | { | |
| 109 | 6 | super(source); |
| 110 | 6 | node = null; |
| 111 | 6 | this.edge = edge; |
| 112 | 6 | nodeValue = null; |
| 113 | 6 | sourceNode = null; |
| 114 | 6 | targetNode = null; |
| 115 | 6 | edgeValue = null; |
| 116 | 6 | } |
| 117 | ||
| 118 | /** | |
| 119 | * Create a new vetoable graph change event with the | |
| 120 | * specified observable graph as the event source and the specified | |
| 121 | * node value for an about to be created node. | |
| 122 | * | |
| 123 | * @param source source of the event, must not be null | |
| 124 | * @param nodeValue node value for an about to be created node | |
| 125 | */ | |
| 126 | public VetoableGraphChangeEvent(final ObservableGraph<N, E> source, final N nodeValue) | |
| 127 | { | |
| 128 | 13 | super(source); |
| 129 | 13 | node = null; |
| 130 | 13 | edge = null; |
| 131 | 13 | this.nodeValue = nodeValue; |
| 132 | 13 | sourceNode = null; |
| 133 | 13 | targetNode = null; |
| 134 | 13 | edgeValue = null; |
| 135 | 13 | } |
| 136 | ||
| 137 | /** | |
| 138 | * Create a new vetoable graph change event with the | |
| 139 | * specified observable graph as the event source and specified | |
| 140 | * source node, target node, and edge value for an about to be | |
| 141 | * created edge. | |
| 142 | * | |
| 143 | * @param source source of the event, must not be null | |
| 144 | * @param sourceNode source node for an about to be created edge | |
| 145 | * @param targetNode target node for an about to be created edge | |
| 146 | * @param edgeValue edge value for an about to be created edge | |
| 147 | */ | |
| 148 | public VetoableGraphChangeEvent(final ObservableGraph<N, E> source, | |
| 149 | final Node<N, E> sourceNode, | |
| 150 | final Node<N, E> targetNode, | |
| 151 | final E edgeValue) | |
| 152 | { | |
| 153 | 7 | super(source); |
| 154 | 7 | node = null; |
| 155 | 7 | edge = null; |
| 156 | 7 | nodeValue = null; |
| 157 | 7 | this.sourceNode = sourceNode; |
| 158 | 7 | this.targetNode = targetNode; |
| 159 | 7 | this.edgeValue = edgeValue; |
| 160 | 7 | } |
| 161 | ||
| 162 | ||
| 163 | /** | |
| 164 | * Return the source of this vetoable graph change event as an | |
| 165 | * <code>ObservableGraph</code>. | |
| 166 | * | |
| 167 | * @return the source of this vetoable graph change event as an | |
| 168 | * <code>ObservableGraph</code> | |
| 169 | */ | |
| 170 | public final ObservableGraph<N, E> getObservableGraph() | |
| 171 | { | |
| 172 | 6 | return (ObservableGraph<N, E>) super.getSource(); |
| 173 | } | |
| 174 | ||
| 175 | /** | |
| 176 | * Return the about to be removed node, if any. | |
| 177 | * | |
| 178 | * @return the about to be removed node, if any | |
| 179 | */ | |
| 180 | public final Node<N, E> getNode() | |
| 181 | { | |
| 182 | 3 | return node; |
| 183 | } | |
| 184 | ||
| 185 | /** | |
| 186 | * Return the about to be removed edge, if any. | |
| 187 | * | |
| 188 | * @return the about to be removed edge, if any | |
| 189 | */ | |
| 190 | public final Edge<N, E> getEdge() | |
| 191 | { | |
| 192 | 3 | return edge; |
| 193 | } | |
| 194 | ||
| 195 | /** | |
| 196 | * Return the node value for the about to be created node, if any. | |
| 197 | * | |
| 198 | * @return the node value for the about to be created node, if any | |
| 199 | */ | |
| 200 | public final N getNodeValue() | |
| 201 | { | |
| 202 | 3 | return nodeValue; |
| 203 | } | |
| 204 | ||
| 205 | /** | |
| 206 | * Return the source node for the about to be created edge, if any. | |
| 207 | * | |
| 208 | * @return the source node for the about to be created edge, if any | |
| 209 | */ | |
| 210 | public final Node<N, E> getSourceNode() | |
| 211 | { | |
| 212 | 3 | return sourceNode; |
| 213 | } | |
| 214 | ||
| 215 | /** | |
| 216 | * Return the target node for the about to be created edge, if any. | |
| 217 | * | |
| 218 | * @return the target node for the about to be created edge, if any | |
| 219 | */ | |
| 220 | public final Node<N, E> getTargetNode() | |
| 221 | { | |
| 222 | 3 | return targetNode; |
| 223 | } | |
| 224 | ||
| 225 | /** | |
| 226 | * Return the edge value for the about to be created edge, if any. | |
| 227 | * | |
| 228 | * @return the edge value for the about to be created edge, if any | |
| 229 | */ | |
| 230 | public final E getEdgeValue() | |
| 231 | { | |
| 232 | 3 | return edgeValue; |
| 233 | } | |
| 234 | } |