Last active
July 24, 2017 23:27
-
-
Save eltabo/8953176 to your computer and use it in GitHub Desktop.
TheEvilMapLikeMonsterThatMakeYouHateMe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package snippet; | |
import java.util.Collection; | |
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.Set; | |
public class TheEvilMapLikeMonsterThatMakeYouHateMe<K>{ | |
private HashMap<K, Object> innerMap = new HashMap<K, Object>(); | |
public boolean equals(Object o) { | |
return innerMap.equals(o); | |
} | |
public int size() { | |
return innerMap.size(); | |
} | |
public boolean isEmpty() { | |
return innerMap.isEmpty(); | |
} | |
public int hashCode() { | |
return innerMap.hashCode(); | |
} | |
public boolean containsKey(K key) { | |
return innerMap.containsKey(key); | |
} | |
public String toString() { | |
return innerMap.toString(); | |
} | |
public <Y extends Object>Object put(K key, Y value) { | |
return innerMap.put(key, value); | |
} | |
public void putAll(Map<? extends K, ? extends Object> m) { | |
innerMap.putAll(m); | |
} | |
@SuppressWarnings("unchecked") | |
public <Y extends Object>Y remove(Y key) { | |
return (Y)innerMap.remove(key); | |
} | |
public void clear() { | |
innerMap.clear(); | |
} | |
public <Y extends Object> boolean containsValue(Y value) { | |
return innerMap.containsValue(value); | |
} | |
public Object clone() { | |
return innerMap.clone(); | |
} | |
public Set<K> keySet() { | |
return innerMap.keySet(); | |
} | |
public Collection<Object> values() { | |
return innerMap.values(); | |
} | |
public Set<java.util.Map.Entry<K, Object>> entrySet() { | |
return innerMap.entrySet(); | |
} | |
@SuppressWarnings("unchecked") | |
public <Y extends Object>Y get(Object s){ | |
return (Y)innerMap.get(s); | |
} | |
public static void main(String[] args) { | |
TheEvilMapLikeMonsterThatMakeYouHateMe<String> evil = new TheEvilMapLikeMonsterThatMakeYouHateMe<String>(); | |
evil.put("a", 1); | |
evil.put("b", 2f); | |
evil.put("c", "b"); | |
int a = evil.get("a"); | |
float b = evil.get("b"); | |
String c = evil.get("c"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fix class reference in main method.
P.S. 100% evil