Skip to content

Commit

Permalink
Updating to 21
Browse files Browse the repository at this point in the history
  • Loading branch information
madsravn committed Nov 12, 2023
1 parent b3bc4c8 commit 741461a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
6 changes: 5 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>19</java.version>
<java.version>21</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
</properties>
Expand Down Expand Up @@ -54,6 +54,10 @@
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>21</source>
<target>21</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ public int hashCode() {

@Override
public boolean equals(Object o) {
if (this == o)
if (this == o) {
return true;
if (o == null || getClass() != o.getClass())
}
if (o == null || getClass() != o.getClass()) {
return false;
}
BooleanObject that = (BooleanObject) o;
return this.value == that.value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ public int hashCode() {

@Override
public boolean equals(Object o) {
if (this == o)
if (this == o) {
return true;
if (o == null || getClass() != o.getClass())
}
if (o == null || getClass() != o.getClass()) {
return false;
}
IntegerObject that = (IntegerObject) o;
return this.value == that.value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ public int hashCode() {

@Override
public boolean equals(Object o) {
if (this == o)
// TODO: Compare with the one in Token.java
if (this == o) {
return true;
if (o == null || getClass() != o.getClass())
}
if (o == null || getClass() != o.getClass()) {
return false;
}
StringObject that = (StringObject) o;
return this.value.equals(that.value);
}
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/dk/madsravn/interpreter/tokens/Token.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,14 @@ public String toString() {

@Override
public boolean equals(Object o) {

// If the object is compared with itself then return true
if (o == this) {
return true;
}

/* Check if o is an instance of Complex or not
"null instanceof [type]" also returns false */
if (!(o instanceof Token)) {
return false;
}

// typecast o to Complex so that we can compare data members
Token c = (Token) o;

// Compare the data members and return accordingly
return c.getType().equals(this.getType()) && c.getLiteral().equals(this.getLiteral());
}

Expand Down

0 comments on commit 741461a

Please sign in to comment.