1 package org.thegalactic.util; 2 3 /* 4 * Couple.java 5 * 6 * Copyright: 2010-2015 Karell Bertet, France 7 * Copyright: 2015-2016 The Galactic Organization, France 8 * 9 * License: http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html CeCILL-B license 10 * 11 * This file is part of java-lattices. 12 * You can redistribute it and/or modify it under the terms of the CeCILL-B license. 13 */ 14 /** 15 * This class provides a representation of couple (A,B) of objects. 16 * 17 * ![Couple](Couple.png) 18 * 19 * @uml Couple.png 20 * !include resources/org/thegalactic/util/Couple.iuml 21 * 22 * class Couple #LightCyan 23 * title Couple UML graph 24 * @author jeff 25 */ 26 public class Couple { 27 28 /** 29 * Left hand side of this component. 30 */ 31 private Object left; 32 33 /** 34 * Right hand side of this component. 35 */ 36 private Object right; 37 38 /** 39 * Constructor from two objects. 40 * 41 * @param l left hand side of this component 42 * @param r right hand side of this component 43 */ 44 public Couple(Object l, Object r) { 45 this.left = l; 46 this.right = r; 47 } 48 49 /** 50 * Returns left hand side of this component. 51 * 52 * @return left hand side of this component 53 */ 54 public Object getLeft() { 55 return left; 56 } 57 58 /** 59 * Set left hand side of this component. 60 * 61 * @param left hand side of this component 62 * 63 * @return this for chaining 64 */ 65 public Couple setLeft(Object left) { 66 this.left = left; 67 return this; 68 } 69 70 /** 71 * Returns right hand side of this component. 72 * 73 * @return right hand side of this component 74 */ 75 public Object getRight() { 76 return right; 77 } 78 79 /** 80 * Set right hand side of this component. 81 * 82 * @param right hand side of this component 83 * 84 * @return this for chaining 85 */ 86 public Couple setRight(Object right) { 87 this.right = right; 88 return this; 89 } 90 91 /** 92 * Returns true if c is equals to this component. 93 * 94 * @param c Couple tested with this component 95 * 96 * @return true if c is equals to this component. 97 */ 98 public boolean equals(Couple c) { 99 return this.left == c.getLeft() && this.right == c.getRight(); 100 } 101 102 /** 103 * Compute the hash code. 104 * 105 * @return an integer representing the object 106 */ 107 @Override 108 public int hashCode() { 109 return super.hashCode(); 110 } 111 112 /** 113 * Returns a string representations of this component. 114 * 115 * @return a string representations of this component. 116 */ 117 @Override 118 public String toString() { 119 return "(" + this.left.toString() + "," + this.right.toString() + ")"; 120 } 121 }