src/nodes/Connection.java
author Matthias Mann
Sat Feb 11 13:27:12 2012 +0100 (3 months ago)
changeset 262 f896aec65113
permissions -rw-r--r--
allow mouse input for scrolling, don't update text area model when nothing has changed
Matthias@224
     1
/*
Matthias@224
     2
 * Copyright (c) 2008-2011, Matthias Mann
Matthias@224
     3
 *
Matthias@224
     4
 * All rights reserved.
Matthias@224
     5
 *
Matthias@224
     6
 * Redistribution and use in source and binary forms, with or without
Matthias@224
     7
 * modification, are permitted provided that the following conditions are met:
Matthias@224
     8
 *
Matthias@224
     9
 *     * Redistributions of source code must retain the above copyright notice,
Matthias@224
    10
 *       this list of conditions and the following disclaimer.
Matthias@224
    11
 *     * Redistributions in binary form must reproduce the above copyright
Matthias@224
    12
 *       notice, this list of conditions and the following disclaimer in the
Matthias@224
    13
 *       documentation and/or other materials provided with the distribution.
Matthias@224
    14
 *     * Neither the name of Matthias Mann nor the names of its contributors may
Matthias@224
    15
 *       be used to endorse or promote products derived from this software
Matthias@224
    16
 *       without specific prior written permission.
Matthias@224
    17
 *
Matthias@224
    18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Matthias@224
    19
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Matthias@224
    20
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Matthias@224
    21
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
Matthias@224
    22
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
Matthias@224
    23
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
Matthias@224
    24
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
Matthias@224
    25
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
Matthias@224
    26
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
Matthias@224
    27
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Matthias@224
    28
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Matthias@224
    29
 */
Matthias@224
    30
package nodes;
Matthias@224
    31
Matthias@224
    32
/**
Matthias@224
    33
 *
Matthias@224
    34
 * @author Matthias Mann
Matthias@224
    35
 */
Matthias@224
    36
public class Connection {
Matthias@224
    37
Matthias@224
    38
    private final Pad source;
Matthias@224
    39
    private final Pad destination;
Matthias@224
    40
Matthias@224
    41
    public Connection(Pad source, Pad destination) {
Matthias@224
    42
        if(source == null) {
Matthias@224
    43
            throw new NullPointerException("source");
Matthias@224
    44
        }
Matthias@224
    45
        if(destination == null) {
Matthias@224
    46
            throw new NullPointerException("dest");
Matthias@224
    47
        }
Matthias@224
    48
        this.source = source;
Matthias@224
    49
        this.destination = destination;
Matthias@224
    50
    }
Matthias@224
    51
Matthias@224
    52
    public Pad getDestination() {
Matthias@224
    53
        return destination;
Matthias@224
    54
    }
Matthias@224
    55
Matthias@224
    56
    public Pad getSource() {
Matthias@224
    57
        return source;
Matthias@224
    58
    }
Matthias@224
    59
Matthias@224
    60
    @Override
Matthias@224
    61
    public boolean equals(Object obj) {
Matthias@224
    62
        if(obj == null || getClass() != obj.getClass()) {
Matthias@224
    63
            return false;
Matthias@224
    64
        }
Matthias@224
    65
        final Connection other = (Connection)obj;
Matthias@224
    66
        return (this.source == other.source) && (this.destination == other.destination);
Matthias@224
    67
    }
Matthias@224
    68
Matthias@224
    69
    @Override
Matthias@224
    70
    public int hashCode() {
Matthias@224
    71
        int hash = 7;
Matthias@224
    72
        hash = 79 * hash + System.identityHashCode(this.source);
Matthias@224
    73
        hash = 79 * hash + System.identityHashCode(this.destination);
Matthias@224
    74
        return hash;
Matthias@224
    75
    }
Matthias@224
    76
    
Matthias@224
    77
}