diff options
author | Ryan D. Brooks | 2017-09-11 19:31:28 +0000 |
---|---|---|
committer | Ryan D. Brooks | 2017-09-12 19:21:24 +0000 |
commit | 7bcfc609099e7d145d12c8c6d71097de9342a1f7 (patch) | |
tree | 9088e3eb70e758fccb9f679f015277ec5a879f94 | |
parent | fa5b684415321e793990878bbd96961a335af97c (diff) | |
download | org.eclipse.osee-7bcfc609099e7d145d12c8c6d71097de9342a1f7.tar.gz org.eclipse.osee-7bcfc609099e7d145d12c8c6d71097de9342a1f7.tar.xz org.eclipse.osee-7bcfc609099e7d145d12c8c6d71097de9342a1f7.zip |
refactor: Use generics properly in client attribute hierarchy
Change-Id: I8405e0bdcea69aeba1bbc7f7d361c551417f1a2f
4 files changed, 16 insertions, 20 deletions
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 8b2b809fb3f..ce3dccac37e 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 @@ import org.eclipse.osee.framework.skynet.core.artifact.Attribute; /** * @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 @@ public abstract class AbstractAttributeDataProvider implements IAttributeDataPro /** * @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 905de7f8ea2..1b10d7b10c3 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 @@ import org.eclipse.osee.framework.skynet.core.artifact.Attribute; /** * @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 3394741c9b0..ac0969fcc36 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 @@ import org.eclipse.osee.jdbc.JdbcConstants; /** * @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 @@ public class DefaultAttributeDataProvider extends AbstractAttributeDataProvider } @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 @@ public class DefaultAttributeDataProvider extends AbstractAttributeDataProvider 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 @@ public class DefaultAttributeDataProvider extends AbstractAttributeDataProvider @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 42c6d6d87b7..7616ebe6173 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 |