Skip to content

Commit e11143b

Browse files
authored
Remove API that appears to be unnecessary with immutable types (#31)
1 parent 954e06d commit e11143b

23 files changed

+53
-362
lines changed

src/main/template/float/org/spongepowered/math/imaginary/Complex{{E}}.java.peb

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import org.spongepowered.math.vector.Vector3{{ E }};
1414
* Represent a complex number of the form {@code x + yi}. The x and y components are stored as {@code {{ e }}}s. This class is immutable.
1515
*/
1616
@Immutable
17-
public final class Complex{{ E }} implements Imaginary{{ E }}, Comparable<Complex{{ E }}>, Serializable, Cloneable {
17+
public final class Complex{{ E }} implements Imaginary{{ E }}, Comparable<Complex{{ E }}>, Serializable {
1818

1919
private static final long serialVersionUID = 1;
2020
/**
@@ -25,20 +25,14 @@ public final class Complex{{ E }} implements Imaginary{{ E }}, Comparable<Comple
2525
* An immutable identity (1, 0) complex.
2626
*/
2727
public static final Complex{{ E }} IDENTITY = new Complex{{ E }}(1, 0);
28+
2829
private final {{ e }} x;
2930
private final {{ e }} y;
3031
@SuppressWarnings("Immutable")
3132
private transient volatile boolean hashed = false;
3233
@SuppressWarnings("Immutable")
3334
private transient volatile int hashCode = 0;
3435

35-
/**
36-
* Constructs a new complex. The components are set to the identity (1, 0).
37-
*/
38-
public Complex{{ E }}() {
39-
this(1, 0);
40-
}
41-
4236
/**
4337
* Constructs a new complex from the {{ EOverload }} components.
4438
*
@@ -60,16 +54,6 @@ public final class Complex{{ E }} implements Imaginary{{ E }}, Comparable<Comple
6054
this.y = y;
6155
}
6256

63-
/**
64-
* Copy constructor.
65-
*
66-
* @param c The complex to copy
67-
*/
68-
public Complex{{ E }}(final Complex{{ E }} c) {
69-
this.x = c.x;
70-
this.y = c.y;
71-
}
72-
7357
/**
7458
* Gets the x (real) component of this complex.
7559
*
@@ -513,11 +497,6 @@ public final class Complex{{ E }} implements Imaginary{{ E }}, Comparable<Comple
513497
return (int) Math.signum(this.lengthSquared() - that.lengthSquared());
514498
}
515499

516-
@Override
517-
public Complex{{ E }} clone() {
518-
return new Complex{{ E }}(this);
519-
}
520-
521500
@Override
522501
public String toString() {
523502
return "(" + this.x + ", " + this.y + ")";

src/main/template/float/org/spongepowered/math/imaginary/Quaternion{{E}}.java.peb

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import org.spongepowered.math.vector.Vector3{{ E }};
1515
* immutable.</p>
1616
*/
1717
@Immutable
18-
public final class Quaternion{{ E }} implements Imaginary{{ E }}, Comparable<Quaternion{{ E }}>, Serializable, Cloneable {
18+
public final class Quaternion{{ E }} implements Imaginary{{ E }}, Comparable<Quaternion{{ E }}>, Serializable {
1919

2020
private static final long serialVersionUID = 1;
2121
/**
@@ -35,13 +35,6 @@ public final class Quaternion{{ E }} implements Imaginary{{ E }}, Comparable<Qua
3535
@SuppressWarnings("Immutable")
3636
private transient volatile int hashCode = 0;
3737

38-
/**
39-
* Constructs a new quaternion. The components are set to the identity (0, 0, 0, 1).
40-
*/
41-
public Quaternion{{ E }}() {
42-
this(0, 0, 0, 1);
43-
}
44-
4538
/**
4639
* Constructs a new quaternion from the {{ EOverload }} components.
4740
*
@@ -69,15 +62,6 @@ public final class Quaternion{{ E }} implements Imaginary{{ E }}, Comparable<Qua
6962
this.w = w;
7063
}
7164

72-
/**
73-
* Copy constructor.
74-
*
75-
* @param q The quaternion to copy
76-
*/
77-
public Quaternion{{ E }}(final Quaternion{{ E }} q) {
78-
this(q.x, q.y, q.z, q.w);
79-
}
80-
8165
/**
8266
* Gets the x (imaginary) component of this quaternion.
8367
*
@@ -579,11 +563,6 @@ public final class Quaternion{{ E }} implements Imaginary{{ E }}, Comparable<Qua
579563
return (int) Math.signum(this.lengthSquared() - q.lengthSquared());
580564
}
581565

582-
@Override
583-
public Quaternion{{ E }} clone() {
584-
return new Quaternion{{ E }}(this);
585-
}
586-
587566
@Override
588567
public String toString() {
589568
return "(" + this.x + ", " + this.y + ", " + this.z + ", " + this.w + ")";

src/main/template/float/org/spongepowered/math/matrix/Matrix2{{E}}.java.peb

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,24 @@ import org.spongepowered.math.vector.Vector2{{ E }};
1313
* A 2x2 matrix containing values of type {@code {{ e }}}.`
1414
*/
1515
@Immutable
16-
public final class Matrix2{{ E }} implements Matrix{{ E }}, Serializable, Cloneable {
16+
public final class Matrix2{{ E }} implements Matrix{{ E }}, Serializable {
1717

1818
private static final long serialVersionUID = 1;
1919
public static final Matrix2{{ E }} ZERO = new Matrix2{{ E }}(
20-
0, 0,
21-
0, 0);
22-
public static final Matrix2{{ E }} IDENTITY = new Matrix2{{ E }}();
20+
0, 0,
21+
0, 0
22+
);
23+
public static final Matrix2{{ E }} IDENTITY = new Matrix2{{ E }}(
24+
1, 0,
25+
0, 1
26+
);
2327
private final {{ e }} m00, m01;
2428
private final {{ e }} m10, m11;
2529
@SuppressWarnings("Immutable")
2630
private transient volatile boolean hashed = false;
2731
@SuppressWarnings("Immutable")
2832
private transient volatile int hashCode = 0;
2933

30-
public Matrix2{{ E }}() {
31-
this(
32-
1, 0,
33-
0, 1);
34-
}
35-
36-
public Matrix2{{ E }}(final Matrix2{{ E }} m) {
37-
this(
38-
m.m00, m.m01,
39-
m.m10, m.m11);
40-
}
41-
4234
public Matrix2{{ E }}(final Matrix3{{ E }} m) {
4335
this(
4436
m.get(0, 0), m.get(0, 1),
@@ -370,11 +362,6 @@ public final class Matrix2{{ E }} implements Matrix{{ E }}, Serializable, Clonea
370362
return this.hashCode;
371363
}
372364

373-
@Override
374-
public Matrix2{{ E }} clone() {
375-
return new Matrix2{{ E }}(this);
376-
}
377-
378365
public static Matrix2{{ E }} from(final {{ e }} n) {
379366
return n == 0 ? Matrix2{{ E}}.ZERO : new Matrix2{{ E }}(n, n, n, n);
380367
}

src/main/template/float/org/spongepowered/math/matrix/Matrix3{{E}}.java.peb

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,19 @@ import org.spongepowered.math.vector.Vector2{{ E }};
1010
import org.spongepowered.math.vector.Vector3{{ E }};
1111

1212
@Immutable
13-
public final class Matrix3{{ E }} implements Matrix{{ E }}, Serializable, Cloneable {
13+
public final class Matrix3{{ E }} implements Matrix{{ E }}, Serializable {
1414

1515
private static final long serialVersionUID = 1;
1616
public static final Matrix3{{ E }} ZERO = new Matrix3{{ E }}(
1717
0, 0, 0,
1818
0, 0, 0,
1919
0, 0, 0
2020
);
21-
public static final Matrix3{{ E }} IDENTITY = new Matrix3{{ E }}();
21+
public static final Matrix3{{ E }} IDENTITY = new Matrix3{{ E }}(
22+
1, 0, 0,
23+
0, 1, 0,
24+
0, 0, 1
25+
);
2226
private final {{ e }} m00, m01, m02;
2327
private final {{ e }} m10, m11, m12;
2428
private final {{ e }} m20, m21, m22;
@@ -27,14 +31,6 @@ public final class Matrix3{{ E }} implements Matrix{{ E }}, Serializable, Clonea
2731
@SuppressWarnings("Immutable")
2832
private transient volatile int hashCode = 0;
2933

30-
public Matrix3{{ E }}() {
31-
this(
32-
1, 0, 0,
33-
0, 1, 0,
34-
0, 0, 1
35-
);
36-
}
37-
3834
public Matrix3{{ E }}(final Matrix2{{ E }} m) {
3935
this(
4036
m.get(0, 0), m.get(0, 1), 0,
@@ -43,14 +39,6 @@ public final class Matrix3{{ E }} implements Matrix{{ E }}, Serializable, Clonea
4339
);
4440
}
4541

46-
public Matrix3{{ E }}(final Matrix3{{ E }} m) {
47-
this(
48-
m.m00, m.m01, m.m02,
49-
m.m10, m.m11, m.m12,
50-
m.m20, m.m21, m.m22
51-
);
52-
}
53-
5442
public Matrix3{{ E }}(final Matrix4{{ E }} m) {
5543
this(
5644
m.get(0, 0), m.get(0, 1), m.get(0, 2),
@@ -474,11 +462,6 @@ public final class Matrix3{{ E }} implements Matrix{{ E }}, Serializable, Clonea
474462
return this.hashCode;
475463
}
476464

477-
@Override
478-
public Matrix3{{ E }} clone() {
479-
return new Matrix3{{ E }}(this);
480-
}
481-
482465
public static Matrix3{{ E }} from(final {{ e }} n) {
483466
return n == 0 ? Matrix3{{ E }}.ZERO : new Matrix3{{ E }}(n, n, n, n, n, n, n, n, n);
484467
}

src/main/template/float/org/spongepowered/math/matrix/Matrix4{{E}}.java.peb

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import org.spongepowered.math.vector.Vector3{{ E }};
1212
import org.spongepowered.math.vector.Vector4{{ E }};
1313

1414
@Immutable
15-
public final class Matrix4{{ E }} implements Matrix{{ E }}, Serializable, Cloneable {
15+
public final class Matrix4{{ E }} implements Matrix{{ E }}, Serializable {
1616

1717
private static final long serialVersionUID = 1;
1818
public static final Matrix4{{ E }} ZERO = new Matrix4{{ E }}(
@@ -21,7 +21,12 @@ public final class Matrix4{{ E }} implements Matrix{{ E }}, Serializable, Clonea
2121
0, 0, 0, 0,
2222
0, 0, 0, 0
2323
);
24-
public static final Matrix4{{ E }} IDENTITY = new Matrix4{{ E }}();
24+
public static final Matrix4{{ E }} IDENTITY = new Matrix4{{ E }}(
25+
1, 0, 0, 0,
26+
0, 1, 0, 0,
27+
0, 0, 1, 0,
28+
0, 0, 0, 1
29+
);
2530
private final {{ e }} m00, m01, m02, m03;
2631
private final {{ e }} m10, m11, m12, m13;
2732
private final {{ e }} m20, m21, m22, m23;
@@ -31,14 +36,6 @@ public final class Matrix4{{ E }} implements Matrix{{ E }}, Serializable, Clonea
3136
@SuppressWarnings("Immutable")
3237
private transient volatile int hashCode = 0;
3338

34-
public Matrix4{{ E }}() {
35-
this(
36-
1, 0, 0, 0,
37-
0, 1, 0, 0,
38-
0, 0, 1, 0,
39-
0, 0, 0, 1);
40-
}
41-
4239
public Matrix4{{ E }}(final Matrix2{{ E }} m) {
4340
this(
4441
m.get(0, 0), m.get(0, 1), 0, 0,
@@ -55,14 +52,6 @@ public final class Matrix4{{ E }} implements Matrix{{ E }}, Serializable, Clonea
5552
0, 0, 0, 0);
5653
}
5754

58-
public Matrix4{{ E }}(final Matrix4{{ E }} m) {
59-
this(
60-
m.m00, m.m01, m.m02, m.m03,
61-
m.m10, m.m11, m.m12, m.m13,
62-
m.m20, m.m21, m.m22, m.m23,
63-
m.m30, m.m31, m.m32, m.m33);
64-
}
65-
6655
public Matrix4{{ E }}(final MatrixN{{ E }} m) {
6756
this.m00 = m.get(0, 0);
6857
this.m01 = m.get(0, 1);
@@ -599,11 +588,6 @@ public final class Matrix4{{ E }} implements Matrix{{ E }}, Serializable, Clonea
599588
return this.hashCode;
600589
}
601590

602-
@Override
603-
public Matrix4{{ E }} clone() {
604-
return new Matrix4{{ E }}(this);
605-
}
606-
607591
public static Matrix4{{ E }} from(final {{ e }} n) {
608592
return n == 0 ? Matrix4{{ E }}.ZERO : new Matrix4{{ E }}(n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n);
609593
}

src/main/template/float/org/spongepowered/math/vector/Vector2{{E}}.java.peb

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import org.spongepowered.math.HashFunctions;
1010
import org.spongepowered.math.TrigMath;
1111

1212
@Immutable
13-
public final class Vector2{{ E }} implements Vector{{ E }}, Comparable<Vector2{{ E }}>, Serializable, Cloneable {
13+
public final class Vector2{{ E }} implements Vector{{ E }}, Comparable<Vector2{{ E }}>, Serializable {
1414

1515
private static final long serialVersionUID = 1;
1616
public static final Vector2{{ E }} ZERO = new Vector2{{ E }}(0, 0);
@@ -24,14 +24,6 @@ public final class Vector2{{ E }} implements Vector{{ E }}, Comparable<Vector2{{
2424
@SuppressWarnings("Immutable")
2525
private transient volatile int hashCode = 0;
2626

27-
public Vector2{{ E }}() {
28-
this(0, 0);
29-
}
30-
31-
public Vector2{{ E }}(final Vector2{{ E }} v) {
32-
this(v.x, v.y);
33-
}
34-
3527
public Vector2{{ E }}(final Vector3{{ E }} v) {
3628
this(v.x(), v.y());
3729
}
@@ -373,11 +365,6 @@ public final class Vector2{{ E }} implements Vector{{ E }}, Comparable<Vector2{{
373365
return this.hashCode;
374366
}
375367

376-
@Override
377-
public Vector2{{ E }} clone() {
378-
return new Vector2{{ E }}(this);
379-
}
380-
381368
@Override
382369
public String toString() {
383370
return "(" + this.x + ", " + this.y + ")";

src/main/template/float/org/spongepowered/math/vector/Vector3{{E}}.java.peb

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import org.spongepowered.math.HashFunctions;
99
import org.spongepowered.math.TrigMath;
1010

1111
@Immutable
12-
public final class Vector3{{ E }} implements Vector{{ E }}, Comparable<Vector3{{ E }}>, Serializable, Cloneable {
12+
public final class Vector3{{ E }} implements Vector{{ E }}, Comparable<Vector3{{ E }}>, Serializable {
1313

1414
private static final long serialVersionUID = 1;
1515
public static final Vector3{{ E }} ZERO = new Vector3{{ E }}(0, 0, 0);
@@ -28,10 +28,6 @@ public final class Vector3{{ E }} implements Vector{{ E }}, Comparable<Vector3{{
2828
@SuppressWarnings("Immutable")
2929
private transient volatile int hashCode = 0;
3030

31-
public Vector3{{ E }}() {
32-
this(0, 0, 0);
33-
}
34-
3531
public Vector3{{ E }}(final Vector2{{ E }} v) {
3632
this(v, 0);
3733
}
@@ -44,10 +40,6 @@ public final class Vector3{{ E }} implements Vector{{ E }}, Comparable<Vector3{{
4440
this(v.x(), v.y(), z);
4541
}
4642

47-
public Vector3{{ E }}(final Vector3{{ E }} v) {
48-
this(v.x, v.y, v.z);
49-
}
50-
5143
public Vector3{{ E }}(final Vector4{{ E }} v) {
5244
this(v.x(), v.y(), v.z());
5345
}
@@ -407,11 +399,6 @@ public final class Vector3{{ E }} implements Vector{{ E }}, Comparable<Vector3{{
407399
return this.hashCode;
408400
}
409401

410-
@Override
411-
public Vector3{{ E }} clone() {
412-
return new Vector3{{ E }}(this);
413-
}
414-
415402
@Override
416403
public String toString() {
417404
return "(" + this.x + ", " + this.y + ", " + this.z + ")";

0 commit comments

Comments
 (0)