Coverage Report - org.dishevelled.observable.graph.event.GraphChangeEvent
 
Classes in this File Line Coverage Branch Coverage Complexity
GraphChangeEvent
100%
15/15
N/A
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 change 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 GraphChangeEvent<N, E>
 42  
     extends EventObject
 43  
 {
 44  
     /** Newly created or removed node, if any. */
 45  
     private final Node<N, E> node;
 46  
 
 47  
     /** Newly created or removed edge, if any. */
 48  
     private final Edge<N, E> edge;
 49  
 
 50  
 
 51  
     /**
 52  
      * Create a new graph change event with the specified
 53  
      * observable graph as the event source.
 54  
      *
 55  
      * @param source source of the event, must not be null
 56  
      */
 57  
     public GraphChangeEvent(final ObservableGraph<N, E> source)
 58  
     {
 59  5
         super(source);
 60  4
         this.node = null;
 61  4
         this.edge = null;
 62  4
     }
 63  
 
 64  
     /**
 65  
      * Create a new graph change event with the specified
 66  
      * observable graph as the event source and the specified
 67  
      * newly created or removed node.
 68  
      *
 69  
      * @param source source of the event, must not be null
 70  
      * @param node newly created or removed node, if any
 71  
      */
 72  
     public GraphChangeEvent(final ObservableGraph<N, E> source, final Node<N, E> node)
 73  
     {
 74  6
         super(source);
 75  6
         this.node = node;
 76  6
         this.edge = null;
 77  6
     }
 78  
 
 79  
     /**
 80  
      * Create a new graph change event with the specified
 81  
      * observable graph as the event source and the specified
 82  
      * newly created or removed edge.
 83  
      *
 84  
      * @param source source of the event, must not be null
 85  
      * @param edge newly created or removed edge, if any
 86  
      */
 87  
     public GraphChangeEvent(final ObservableGraph<N, E> source, final Edge<N, E> edge)
 88  
     {
 89  4
         super(source);
 90  4
         this.node = null;
 91  4
         this.edge = edge;
 92  4
     }
 93  
 
 94  
 
 95  
     /**
 96  
      * Return the source of this graph change event as an
 97  
      * <code>ObservableGraph</code>.
 98  
      *
 99  
      * @return the source of this graph change event as an
 100  
      *    <code>ObservableGraph</code>
 101  
      */
 102  
     public final ObservableGraph<N, E> getObservableGraph()
 103  
     {
 104  6
         return (ObservableGraph<N, E>) super.getSource();
 105  
     }
 106  
 
 107  
     /**
 108  
      * Return the newly created or removed node for this graph change
 109  
      * event, if any.
 110  
      *
 111  
      * @return the newly created or removed node for this graph change
 112  
      *    event, if any
 113  
      */
 114  
     public final Node<N, E> getNode()
 115  
     {
 116  5
         return node;
 117  
     }
 118  
 
 119  
     /**
 120  
      * Return the newly created or removed edge for this graph change
 121  
      * event, if any.
 122  
      *
 123  
      * @return the newly created or removed edge for this graph change
 124  
      *    event, if any
 125  
      */
 126  
     public final Edge<N, E> getEdge()
 127  
     {
 128  3
         return edge;
 129  
     }
 130  
 }