From 9716b1ac09eb92c4ed001be4350d54b41b953239 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Sat, 25 Mar 2017 19:14:18 -0400 Subject: Add static constructors --- .../src/main/java/bjc/utils/data/Identity.java | 33 ++++++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/Identity.java') 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 implements IHolder { */ @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 implements IHolder { public UnwrappedType unwrap(Function unwrapper) { return unwrapper.apply(heldValue); } + + /** + * Create a new identity container. + * + * @param val + * The contained value. + * + * @return A new identity container. + */ + public static Identity id(ContainedType val) { + return new Identity<>(val); + } + + /** + * Create a new empty identity container. + * + * @return A new empty identity container. + */ + public static Identity id() { + return new Identity<>(); + } } \ No newline at end of file -- cgit v1.2.3