Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2013-10-10 01:17:05 -0400
committerRyan D. Brooks2013-10-22 18:12:27 -0400
commit989feebd0648bb7c9d4bfb473d13afee7f896d38 (patch)
tree38d5c1867454da624c9183c79bbc132663d8149e /plugins/org.eclipse.osee.framework.jdk.core
parent572141e9dd5d85360829c71b8e5770abcd91adf8 (diff)
downloadorg.eclipse.osee-989feebd0648bb7c9d4bfb473d13afee7f896d38.tar.gz
org.eclipse.osee-989feebd0648bb7c9d4bfb473d13afee7f896d38.tar.xz
org.eclipse.osee-989feebd0648bb7c9d4bfb473d13afee7f896d38.zip
refactor: Move identity classes to jdk.core
Diffstat (limited to 'plugins/org.eclipse.osee.framework.jdk.core')
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/BaseIdentity.java62
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/FullyNamed.java18
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/FullyNamedIdentity.java45
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/HasDescription.java18
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/Identifiable.java19
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/Identity.java23
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/Named.java19
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/NamedIdentity.java46
8 files changed, 250 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/BaseIdentity.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/BaseIdentity.java
new file mode 100644
index 0000000000..638a0d459e
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/BaseIdentity.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.jdk.core.type;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class BaseIdentity<T> implements Identity<T> {
+ private final T id;
+
+ public BaseIdentity(T id) {
+ this.id = id;
+ }
+
+ @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 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.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/FullyNamed.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/FullyNamed.java
new file mode 100644
index 0000000000..b094452191
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/FullyNamed.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.jdk.core.type;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public interface FullyNamed extends Named, Comparable<Named> {
+ public abstract String getUnqualifiedName();
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/FullyNamedIdentity.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/FullyNamedIdentity.java
new file mode 100644
index 0000000000..b547065819
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/FullyNamedIdentity.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * 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.jdk.core.type;
+
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class FullyNamedIdentity<T> extends NamedIdentity<T> implements FullyNamed, HasDescription {
+ private final String description;
+
+ public FullyNamedIdentity(T guid, String name) {
+ this(guid, name, "");
+ }
+
+ public FullyNamedIdentity(T guid, String name, String description) {
+ super(guid, name);
+ this.description = description;
+ }
+
+ @Override
+ public String getUnqualifiedName() {
+ String name = getName();
+ if (Strings.isValid(name)) {
+ int index = name.lastIndexOf('.');
+ name = name.substring(index + 1);
+ }
+ return name;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/HasDescription.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/HasDescription.java
new file mode 100644
index 0000000000..50e4aaa9ed
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/HasDescription.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.jdk.core.type;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public interface HasDescription {
+ public abstract String getDescription();
+}
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/Identifiable.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/Identifiable.java
new file mode 100644
index 0000000000..9c0b6484a0
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/Identifiable.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.jdk.core.type;
+
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface Identifiable<T> extends Identity<T>, Named {
+ //
+}
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/Identity.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/Identity.java
new file mode 100644
index 0000000000..468ae78e8b
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/Identity.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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.jdk.core.type;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public interface Identity<T> {
+
+ T getGuid();
+
+ boolean matches(Identity<?>... identities);
+
+}
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/Named.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/Named.java
new file mode 100644
index 0000000000..7e20b9a034
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/Named.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * 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.jdk.core.type;
+
+/**
+ * @author Andrew M. Finkbeiner
+ */
+public interface Named {
+ String getName();
+}
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/NamedIdentity.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/NamedIdentity.java
new file mode 100644
index 0000000000..618166c95d
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/NamedIdentity.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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.jdk.core.type;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class NamedIdentity<T> extends BaseIdentity<T> implements Identifiable<T>, Comparable<Named> {
+ private String name;
+
+ public NamedIdentity(T uid, String name) {
+ super(uid);
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public int compareTo(Named other) {
+ if (other != null && other.getName() != null && getName() != null) {
+ return getName().compareTo(other.getName());
+ }
+ return -1;
+ }
+
+ @Override
+ public String toString() {
+ return getName();
+ }
+} \ No newline at end of file

Back to the top