From 150369124953929a3c286d1607b7984120b96cb9 Mon Sep 17 00:00:00 2001 From: Erik Brakkee Date: Sat, 31 Jul 2010 12:53:48 +0000 Subject: [PATCH] --- .../java/org/wamblee/general/ObjectElem.java | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 support/general/src/main/java/org/wamblee/general/ObjectElem.java diff --git a/support/general/src/main/java/org/wamblee/general/ObjectElem.java b/support/general/src/main/java/org/wamblee/general/ObjectElem.java new file mode 100644 index 00000000..dbc9fed8 --- /dev/null +++ b/support/general/src/main/java/org/wamblee/general/ObjectElem.java @@ -0,0 +1,49 @@ +/* + * Copyright 2005-2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wamblee.general; + +/** + * This class provided an equality operation based on the object reference + * of the wrapped object. This is required because we cannto assume that the + * equals operation has any meaning for different types of persistent + * objects. This allows us to use the standard collection classes for + * detecting cyclic dependences and avoiding recursion. + */ +public class ObjectElem { + private Object object; + + /** + * Constructs the wrapper. + * @param aObject Object. + */ + public ObjectElem(Object aObject) { + object = aObject; + } + + public boolean equals(Object aObj) { + if (aObj == null) { + return false; + } + if (!(aObj instanceof ObjectElem)) { + return false; + } + return ((ObjectElem) aObj).object == object; + } + + public int hashCode() { + return object.hashCode(); + } +} \ No newline at end of file -- 2.31.1