-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add x_get_lock, synchronized changes (#1381)
- Loading branch information
1 parent
eb3b3a0
commit a019b99
Showing
10 changed files
with
367 additions
and
61 deletions.
There are no files selected for viewing
94 changes: 94 additions & 0 deletions
94
src/main/java/com/laytonsmith/PureUtilities/Quadruplet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package com.laytonsmith.PureUtilities; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* Creates an object quadruplet. The hashcode and equals functions have been overridden to use the underlying object's hash | ||
* code and equals combined. The underlying objects may be null. | ||
* | ||
* @param <A> The first object's type. | ||
* @param <B> The second object's type. | ||
* @param <C> The third object's type. | ||
* @param <D> The fourth object's type. | ||
*/ | ||
public class Quadruplet<A, B, C, D> { | ||
|
||
private final A fst; | ||
private final B snd; | ||
private final C trd; | ||
private final D frth; | ||
|
||
/** | ||
* Creates a new Quadruplet with the specified values. | ||
* | ||
* @param a | ||
* @param b | ||
* @param c | ||
* @param d | ||
*/ | ||
public Quadruplet(A a, B b, C c, D d) { | ||
fst = a; | ||
snd = b; | ||
trd = c; | ||
frth = d; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "<" | ||
+ Objects.toString(fst) + ", " | ||
+ Objects.toString(snd) + ", " | ||
+ Objects.toString(trd) + ", " | ||
+ Objects.toString(frth) + ">"; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int hash = 7; | ||
hash = 47 * hash + Objects.hashCode(this.fst); | ||
hash = 47 * hash + Objects.hashCode(this.snd); | ||
hash = 47 * hash + Objects.hashCode(this.trd); | ||
hash = 47 * hash + Objects.hashCode(this.frth); | ||
return hash; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if(obj == null) { | ||
return false; | ||
} | ||
if(getClass() != obj.getClass()) { | ||
return false; | ||
} | ||
final Quadruplet<?, ?, ?, ?> other = (Quadruplet<?, ?, ?, ?>) obj; | ||
if(!Objects.equals(this.fst, other.fst)) { | ||
return false; | ||
} | ||
if(!Objects.equals(this.snd, other.snd)) { | ||
return false; | ||
} | ||
if(!Objects.equals(this.trd, other.trd)) { | ||
return false; | ||
} | ||
if(!Objects.equals(this.frth, other.frth)) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
public A getFirst() { | ||
return fst; | ||
} | ||
|
||
public B getSecond() { | ||
return snd; | ||
} | ||
|
||
public C getThird() { | ||
return trd; | ||
} | ||
|
||
public D getFourth() { | ||
return frth; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.