refactor: Use generics properly in client attribute hierarchy
Change-Id: I8405e0bdcea69aeba1bbc7f7d361c551417f1a2f
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/providers/AbstractAttributeDataProvider.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/providers/AbstractAttributeDataProvider.java
index 8b2b809..ce3dcca 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/providers/AbstractAttributeDataProvider.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/providers/AbstractAttributeDataProvider.java
@@ -15,10 +15,10 @@
/**
* @author Roberto E. Escobar
*/
-public abstract class AbstractAttributeDataProvider implements IAttributeDataProvider {
- private final Attribute<?> attribute;
+public abstract class AbstractAttributeDataProvider<T> implements IAttributeDataProvider {
+ private final Attribute<T> attribute;
- public AbstractAttributeDataProvider(Attribute<?> attribute) {
+ public AbstractAttributeDataProvider(Attribute<T> attribute) {
super();
this.attribute = attribute;
}
@@ -26,7 +26,7 @@
/**
* @return the attribute
*/
- protected Attribute<?> getAttribute() {
+ protected Attribute<T> getAttribute() {
return attribute;
}
}
\ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/providers/ClobAttributeDataProvider.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/providers/ClobAttributeDataProvider.java
index 905de7f..1b10d7b1 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/providers/ClobAttributeDataProvider.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/providers/ClobAttributeDataProvider.java
@@ -15,9 +15,8 @@
/**
* @author Roberto E. Escobar
*/
-public class ClobAttributeDataProvider extends DefaultAttributeDataProvider {
- public ClobAttributeDataProvider(Attribute<?> attribute) {
+public class ClobAttributeDataProvider<T> extends DefaultAttributeDataProvider<T> {
+ public ClobAttributeDataProvider(Attribute<T> attribute) {
super(attribute);
}
-
}
\ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/providers/DefaultAttributeDataProvider.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/providers/DefaultAttributeDataProvider.java
index 3394741..ac0969f 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/providers/DefaultAttributeDataProvider.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/providers/DefaultAttributeDataProvider.java
@@ -23,15 +23,14 @@
/**
* @author Roberto E. Escobar
*/
-public class DefaultAttributeDataProvider extends AbstractAttributeDataProvider implements ICharacterAttributeDataProvider {
- private Object rawValue;
+public class DefaultAttributeDataProvider<T> extends AbstractAttributeDataProvider<T> implements ICharacterAttributeDataProvider<T> {
+ private T rawValue;
private final DataStore dataStore;
- public DefaultAttributeDataProvider(Attribute<?> attribute) {
+ public DefaultAttributeDataProvider(Attribute<T> attribute) {
super(attribute);
this.dataStore = new DataStore(new AttributeResourceProcessor(attribute));
- this.rawValue = "";
}
@Override
@@ -67,7 +66,7 @@
}
@Override
- public boolean setValue(Object value) throws OseeCoreException {
+ public boolean setValue(T value) {
Conditions.checkNotNull(value, "attribute value");
boolean response = false;
if (value.toString().equals(getValueAsString())) {
@@ -83,13 +82,13 @@
return BinaryContentUtils.generateFileName(getAttribute());
}
- private void storeValue(Object value) throws OseeCoreException {
+ private void storeValue(T value) {
if (value != null && value instanceof String && ((String) value).length() > JdbcConstants.JDBC__MAX_VARCHAR_LENGTH) {
try {
byte[] compressed =
Lib.compressStream(new ByteArrayInputStream(((String) value).getBytes("UTF-8")), getInternalFileName());
dataStore.setContent(compressed, "zip", "application/zip", "ISO-8859-1");
- this.rawValue = "";
+ this.rawValue = null;
} catch (IOException ex) {
OseeCoreException.wrapAndThrow(ex);
}
@@ -107,7 +106,7 @@
@Override
public void loadData(Object... objects) throws OseeCoreException {
if (objects != null && objects.length > 1) {
- storeValue(objects[0]);
+ storeValue((T) objects[0]);
dataStore.setLocator((String) objects[1]);
}
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/providers/ICharacterAttributeDataProvider.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/providers/ICharacterAttributeDataProvider.java
index 42c6d6d..7616ebe 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/providers/ICharacterAttributeDataProvider.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/providers/ICharacterAttributeDataProvider.java
@@ -10,14 +10,12 @@
*******************************************************************************/
package org.eclipse.osee.framework.skynet.core.attribute.providers;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-
/**
* @author Roberto E. Escobar
*/
-public interface ICharacterAttributeDataProvider extends IAttributeDataProvider {
+public interface ICharacterAttributeDataProvider<T> extends IAttributeDataProvider {
- public String getValueAsString() throws OseeCoreException;
+ public String getValueAsString();
- public boolean setValue(Object value) throws OseeCoreException;
+ public boolean setValue(T value);
}
\ No newline at end of file