Mercurial > hg > IndexMetaContextualizer
diff src/main/java/de/mpiwg/indexmeta/utils/QuadKey.java @ 0:dfce13a5f5f9
nit project!
author | Jorge Urzua <jurzua@mpiwg-berlin.mpg.de> |
---|---|
date | Thu, 11 Apr 2013 15:25:26 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/mpiwg/indexmeta/utils/QuadKey.java Thu Apr 11 15:25:26 2013 +0200 @@ -0,0 +1,116 @@ +package de.mpiwg.indexmeta.utils; + +public class QuadKey<F, S, T> { + private F firstKey; + private S secondKey; + private T thirdKey; + private Object ownKey; + /* + public QuadKey(Long firstKey, Long secondKey, Long thirdKey, Long ownKey){ + this.firstKey = firstKey; + this.secondKey = secondKey; + this.thirdKey = thirdKey; + this.ownKey = ownKey; + }*/ + + public QuadKey(F firstKey, S secondKey, T thirdKey, Long ownKey){ + this.firstKey = firstKey; + this.secondKey = secondKey; + this.thirdKey = thirdKey; + this.ownKey = ownKey; + } + + /* + public boolean containsKey(Object key){ + if(key != null){ + if(key.equals(firstKey) || key.equals(secondKey) || key.equals(ownKey)){ + return true; + } + } + return false; + }*/ + + + public boolean equalsFirstKey(Object key){ + if(firstKey != null && key != null){ + return firstKey.equals(key); + }else if(firstKey == null && key == null){ + return true; + } + return false; + } + + public boolean equalsSecondKey(Object key){ + if(secondKey != null && key != null){ + return secondKey.equals(key); + }else if(secondKey == null && key == null){ + return true; + } + return false; + } + + public boolean equalsThirdKey(Object key){ + if(thirdKey != null && key != null){ + return thirdKey.equals(key); + }else if(thirdKey == null && key == null){ + return true; + } + return false; + } + + public boolean equalsOwnKey(Object key){ + if(ownKey != null && key != null){ + return ownKey.equals(key); + }else if(ownKey == null && key == null){ + return true; + } + return false; + } + + public Object getFirstKey() { + return firstKey; + } + + public void setFirstKey(F firstKey) { + this.firstKey = firstKey; + } + + public Object getSecondKey() { + return secondKey; + } + + public void setSecondKey(S secondKey) { + this.secondKey = secondKey; + } + + public Object getOwnKey() { + return ownKey; + } + + public void setOwnKey(Object ownKey) { + this.ownKey = ownKey; + } + + public Object getThirdKey() { + return thirdKey; + } + + public void setThirdKey(T thirdKey) { + this.thirdKey = thirdKey; + } + + @Override + public boolean equals(Object o){ + if(o instanceof QuadKey){ + QuadKey other = (QuadKey)o; + + if(this.equalsOwnKey(other.getOwnKey()) && + this.equalsFirstKey(other.getFirstKey()) && + this.equalsSecondKey(other.getSecondKey()) && + this.equalsThirdKey(other.getThirdKey())){ + return true; + } + } + return false; + } +}