Simplify Triangle and Vertex with lombok

This commit is contained in:
SomeoneWithAnInternetConnection
2018-02-01 19:15:27 -05:00
committed by Adam
parent f78b73f46c
commit e396f37926
2 changed files with 10 additions and 113 deletions

View File

@@ -24,8 +24,9 @@
*/
package net.runelite.api.model;
import java.util.Objects;
import lombok.Value;
@Value
public class Triangle
{
private final Vertex a;
@@ -39,61 +40,13 @@ public class Triangle
this.c = c;
}
@Override
public String toString()
public Triangle rotate(int orientation)
{
return "Triangle{" + "a=" + a + ", b=" + b + ", c=" + c + '}';
return new Triangle(
a.rotate(orientation),
b.rotate(orientation),
c.rotate(orientation)
);
}
@Override
public int hashCode()
{
int hash = 7;
hash = 13 * hash + Objects.hashCode(this.a);
hash = 13 * hash + Objects.hashCode(this.b);
hash = 13 * hash + Objects.hashCode(this.c);
return hash;
}
@Override
public boolean equals(Object obj)
{
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
final Triangle other = (Triangle) obj;
if (!Objects.equals(this.a, other.a))
{
return false;
}
if (!Objects.equals(this.b, other.b))
{
return false;
}
if (!Objects.equals(this.c, other.c))
{
return false;
}
return true;
}
public Vertex getA()
{
return a;
}
public Vertex getB()
{
return b;
}
public Vertex getC()
{
return c;
}
}

View File

@@ -24,8 +24,10 @@
*/
package net.runelite.api.model;
import lombok.Value;
import net.runelite.api.Perspective;
@Value
public class Vertex
{
private final int x;
@@ -39,64 +41,6 @@ public class Vertex
this.z = z;
}
@Override
public String toString()
{
return "Vertex{" + "x=" + x + ", y=" + y + ", z=" + z + '}';
}
@Override
public int hashCode()
{
int hash = 7;
hash = 67 * hash + this.x;
hash = 67 * hash + this.y;
hash = 67 * hash + this.z;
return hash;
}
@Override
public boolean equals(Object obj)
{
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
final Vertex other = (Vertex) obj;
if (this.x != other.x)
{
return false;
}
if (this.y != other.y)
{
return false;
}
if (this.z != other.z)
{
return false;
}
return true;
}
public int getX()
{
return x;
}
public int getY()
{
return y;
}
public int getZ()
{
return z;
}
/**
* Rotate the vertex by the given orientation
* @param orientation