|
@@ -9,25 +9,24 @@ import java.util.HashMap;
|
|
|
*
|
|
|
* @author Arthur Brandao
|
|
|
*/
|
|
|
-@SuppressWarnings("unchecked")
|
|
|
-public class LispElement<E> {
|
|
|
+public class LispElement {
|
|
|
|
|
|
/**
|
|
|
* Garde en cache les elements deja créer pour eviter de recreer plusieurs fois les meme elements
|
|
|
*/
|
|
|
- private static Map<Object, LispElement<?>> cache = new HashMap<>();
|
|
|
+ private static Map<Object, LispElement> cache = new HashMap<>();
|
|
|
|
|
|
/**
|
|
|
* La valeur de l'element
|
|
|
*/
|
|
|
- public final E value;
|
|
|
+ public final Object value;
|
|
|
|
|
|
/**
|
|
|
* Constructeur privée pour construire un element à partir de valueOf
|
|
|
*
|
|
|
* @param val
|
|
|
*/
|
|
|
- private LispElement(E val) {
|
|
|
+ private LispElement(Object val) {
|
|
|
this.value = val;
|
|
|
cache.put(val, this);
|
|
|
}
|
|
@@ -100,7 +99,7 @@ public class LispElement<E> {
|
|
|
} else if(this == obj) {
|
|
|
return true;
|
|
|
} else if(obj instanceof LispElement) {
|
|
|
- LispElement<?> other = (LispElement<?>) obj;
|
|
|
+ LispElement other = (LispElement) obj;
|
|
|
return this.value.equals(other.value);
|
|
|
}
|
|
|
return false;
|
|
@@ -117,7 +116,7 @@ public class LispElement<E> {
|
|
|
* @param elt L'element à parser
|
|
|
* @return Un LispElement contenant la valeur extraite
|
|
|
*/
|
|
|
- public static <T> LispElement<T> valueOf(String elt) {
|
|
|
+ public static LispElement valueOf(String elt) {
|
|
|
try {
|
|
|
return generate(new BigInteger(elt));
|
|
|
} catch(NumberFormatException ex) {
|
|
@@ -142,7 +141,7 @@ public class LispElement<E> {
|
|
|
* @param elt
|
|
|
* @return
|
|
|
*/
|
|
|
- public static <T> LispElement<T> generate(Object elt) {
|
|
|
+ public static LispElement generate(Object elt) {
|
|
|
if(elt.getClass() == Integer.class) {
|
|
|
elt = BigInteger.valueOf((Integer) elt);
|
|
|
}
|
|
@@ -153,9 +152,9 @@ public class LispElement<E> {
|
|
|
throw new IllegalArgumentException("Object class is not a Lisp element");
|
|
|
}
|
|
|
if(cache.containsKey(elt)) {
|
|
|
- return (LispElement<T>) cache.get(elt);
|
|
|
+ return cache.get(elt);
|
|
|
}
|
|
|
- return new LispElement<>((T) elt);
|
|
|
+ return new LispElement(elt);
|
|
|
}
|
|
|
|
|
|
}
|