001/** 002 * Copyright (C) 2007 - 2016, Jens Lehmann 003 * 004 * This file is part of DL-Learner. 005 * 006 * DL-Learner is free software; you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation; either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * DL-Learner is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 018 */ 019package org.dllearner.utilities.datastructures; 020 021/** 022 * A container which can hold two Strings, mainly used as a helper. 023 * Also used as pre form, if you want to create triple, that have the same subject 024 * @author Sebastian Hellmann 025 */ 026public class StringTuple implements Comparable<StringTuple>{ 027 028 public String a; 029 public String b; 030 031 public StringTuple(String a, String b) { 032 this.a = a; 033 this.b = b; 034 } 035 036 @Override 037 public String toString() { 038 return "<" + a + "|" + b + ">"; 039 } 040 041 @Override 042 public boolean equals(Object o) { 043 if (this == o) return true; 044 if (o == null || getClass() != o.getClass()) return false; 045 046 StringTuple that = (StringTuple) o; 047 048 if (!a.equals(that.a)) return false; 049 return b.equals(that.b); 050 } 051 052 @Override 053 public int hashCode() { 054 int result = a.hashCode(); 055 result = 31 * result + b.hashCode(); 056 return result; 057 } 058 059 @Override 060 public int compareTo(StringTuple t){ 061 int comp = a.compareTo(t.a); 062 if( comp == 0 ){ 063 return b.compareTo(t.b); 064 }else return comp; 065 } 066 067}