summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/data/Identity.java
diff options
context:
space:
mode:
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.java33
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