Explorar o código

Ajout méthode is[Type]

Arthur Brandao %!s(int64=6) %!d(string=hai) anos
pai
achega
556e11bb3c
Modificáronse 1 ficheiros con 16 adicións e 0 borrados
  1. 16 0
      src/migl/lisp/LispElement.java

+ 16 - 0
src/migl/lisp/LispElement.java

@@ -90,6 +90,22 @@ public class LispElement {
 		}
 		throw new IllegalStateException("Not a String");
 	}
+	
+	public boolean isInt() {
+		return this.value.getClass() == BigInteger.class;
+	}
+	
+	public boolean isNumber() {
+		return this.isInt() || (this.value.getClass() == Double.class);
+	}
+	
+	public boolean isBoolean() {
+		return this.value.getClass() == LispBoolean.class;
+	}
+	
+	public boolean isStr() {
+		return this.value.getClass() == String.class;
+	}
 
 	@Override
 	public int hashCode() {