Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2013-10-10 06:40:52 +0000
committerRyan D. Brooks2013-10-21 21:52:31 +0000
commit29e5cbd3ada4944d87be066441d8b77a2a345285 (patch)
tree719f427eea77bd3d6f2fab43a67760f303fa259b /plugins/org.eclipse.osee.framework.core
parent19d8e47107f2bb747487556f9914b5dc6971c086 (diff)
downloadorg.eclipse.osee-29e5cbd3ada4944d87be066441d8b77a2a345285.tar.gz
org.eclipse.osee-29e5cbd3ada4944d87be066441d8b77a2a345285.tar.xz
org.eclipse.osee-29e5cbd3ada4944d87be066441d8b77a2a345285.zip
refactor: Make AbstractIdentity a concrete class
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core')
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/AbstractIdentity.java47
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/AbstractNamedIdentity.java6
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/BaseIdentity.java46
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/NamedIdentity.java11
4 files changed, 43 insertions, 67 deletions
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/AbstractIdentity.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/AbstractIdentity.java
deleted file mode 100644
index 2a4d0875067..00000000000
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/AbstractIdentity.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.osee.framework.core.data;
-
-/**
- * @author Roberto E. Escobar
- */
-public abstract class AbstractIdentity<T> implements Identity<T> {
-
- @Override
- public int hashCode() {
- return getGuid().hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof Identity) {
- return getGuid().equals(((Identity<?>) obj).getGuid());
- }
- return false;
- }
-
- @Override
- public String toString() {
- return String.valueOf(getGuid());
- }
-
- @Override
- public boolean matches(Identity<?>... identities) {
- for (Identity<?> identity : identities) {
- if (equals(identity)) {
- return true;
- }
- }
- return false;
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/AbstractNamedIdentity.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/AbstractNamedIdentity.java
index 48badad4d22..b6851dcc3f4 100644
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/AbstractNamedIdentity.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/AbstractNamedIdentity.java
@@ -16,7 +16,11 @@ import org.eclipse.osee.framework.jdk.core.util.Strings;
/**
* @author Ryan D. Brooks
*/
-public abstract class AbstractNamedIdentity<T> extends AbstractIdentity<T> implements FullyNamed, HasDescription {
+public abstract class AbstractNamedIdentity<T> extends BaseIdentity<T> implements FullyNamed, HasDescription {
+
+ public AbstractNamedIdentity(T uid) {
+ super(uid);
+ }
@Override
public String getUnqualifiedName() {
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/BaseIdentity.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/BaseIdentity.java
index 9238cf3d9d2..e19d0e24baf 100644
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/BaseIdentity.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/BaseIdentity.java
@@ -14,21 +14,49 @@ package org.eclipse.osee.framework.core.data;
/**
* @author Roberto E. Escobar
*/
-public class BaseIdentity<T> extends AbstractIdentity<T> {
+public class BaseIdentity<T> implements Identity<T> {
+ private final T id;
- private final T guid;
+ public BaseIdentity(T id) {
+ this.id = id;
+ }
- public BaseIdentity(T guid) {
- super();
- this.guid = guid;
- if (guid == null) {
- throw new IllegalArgumentException("uuid cannot be null");
+ @Override
+ public T getGuid() {
+ return id;
+ }
+
+ @Override
+ public int hashCode() {
+ return getGuid().hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ boolean equal = false;
+ if (obj instanceof Identity) {
+ Identity<T> identity = (Identity<T>) obj;
+ if (getGuid() == identity.getGuid()) {
+ equal = true;
+ } else if (getGuid() != null) {
+ equal = getGuid().equals(identity.getGuid());
+ }
}
+ return equal;
}
@Override
- public T getGuid() {
- return guid;
+ public String toString() {
+ return String.valueOf(getGuid());
}
+ @Override
+ public boolean matches(Identity<?>... identities) {
+ for (Identity<?> identity : identities) {
+ if (equals(identity)) {
+ return true;
+ }
+ }
+ return false;
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/NamedIdentity.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/NamedIdentity.java
index 06516d1acff..42e6af712e6 100644
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/NamedIdentity.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/NamedIdentity.java
@@ -18,7 +18,6 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException;
*/
public class NamedIdentity<T> extends AbstractNamedIdentity<T> {
private String name;
- private final T guid;
private final String description;
public NamedIdentity(T guid, String name) {
@@ -26,20 +25,12 @@ public class NamedIdentity<T> extends AbstractNamedIdentity<T> {
}
public NamedIdentity(T guid, String name, String description) {
- if (guid == null) {
- throw new IllegalArgumentException("uuid cannot be null");
- }
- this.guid = guid;
+ super(guid);
this.name = name;
this.description = description;
}
@Override
- public T getGuid() {
- return guid;
- }
-
- @Override
public String getName() {
return name;
}

Back to the top