Simplify Triangle and Vertex with lombok
This commit is contained in:
committed by
Adam
parent
f78b73f46c
commit
e396f37926
@@ -24,8 +24,9 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.api.model;
|
package net.runelite.api.model;
|
||||||
|
|
||||||
import java.util.Objects;
|
import lombok.Value;
|
||||||
|
|
||||||
|
@Value
|
||||||
public class Triangle
|
public class Triangle
|
||||||
{
|
{
|
||||||
private final Vertex a;
|
private final Vertex a;
|
||||||
@@ -39,61 +40,13 @@ public class Triangle
|
|||||||
this.c = c;
|
this.c = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public Triangle rotate(int orientation)
|
||||||
public String toString()
|
|
||||||
{
|
{
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,10 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.api.model;
|
package net.runelite.api.model;
|
||||||
|
|
||||||
|
import lombok.Value;
|
||||||
import net.runelite.api.Perspective;
|
import net.runelite.api.Perspective;
|
||||||
|
|
||||||
|
@Value
|
||||||
public class Vertex
|
public class Vertex
|
||||||
{
|
{
|
||||||
private final int x;
|
private final int x;
|
||||||
@@ -39,64 +41,6 @@ public class Vertex
|
|||||||
this.z = z;
|
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
|
* Rotate the vertex by the given orientation
|
||||||
* @param orientation
|
* @param orientation
|
||||||
|
|||||||
Reference in New Issue
Block a user