diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-03-25 19:14:18 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-03-25 19:14:18 -0400 |
| commit | 9716b1ac09eb92c4ed001be4350d54b41b953239 (patch) | |
| tree | 606e56d2375e22464e956f89bb44af38cba008c7 /BJC-Utils2/src/main/java/bjc/utils/data/Identity.java | |
| parent | 42990231fee502552b769b9af4c04ac0dcaeb195 (diff) | |
Add static constructors
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/Identity.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/data/Identity.java | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/Identity.java b/BJC-Utils2/src/main/java/bjc/utils/data/Identity.java index c356e5a..72fe68c 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/Identity.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/Identity.java @@ -48,17 +48,17 @@ public class Identity<ContainedType> implements IHolder<ContainedType> { */ @Override public boolean equals(Object obj) { - if(this == obj) + if (this == obj) return true; - else if(obj == null) + else if (obj == null) return false; - else if(getClass() != obj.getClass()) return false; + else if (getClass() != obj.getClass()) return false; Identity<?> other = (Identity<?>) obj; - if(heldValue == null) { - if(other.heldValue != null) return false; - } else if(!heldValue.equals(other.heldValue)) return false; + if (heldValue == null) { + if (other.heldValue != null) return false; + } else if (!heldValue.equals(other.heldValue)) return false; return true; } @@ -104,4 +104,25 @@ public class Identity<ContainedType> implements IHolder<ContainedType> { public <UnwrappedType> UnwrappedType unwrap(Function<ContainedType, UnwrappedType> unwrapper) { return unwrapper.apply(heldValue); } + + /** + * Create a new identity container. + * + * @param val + * The contained value. + * + * @return A new identity container. + */ + public static <ContainedType> Identity<ContainedType> id(ContainedType val) { + return new Identity<>(val); + } + + /** + * Create a new empty identity container. + * + * @return A new empty identity container. + */ + public static <ContainedType> Identity<ContainedType> id() { + return new Identity<>(); + } }
\ No newline at end of file |
