diff options
author | jmisinco | 2013-06-13 20:40:23 +0000 |
---|---|---|
committer | jmisinco | 2013-06-14 16:14:53 +0000 |
commit | 4c7fa436c1f79c6a57a813193779ca9e1495fc78 (patch) | |
tree | 51e41691bf01db08c510bbb9f7e3fd7020575b08 /plugins/org.eclipse.osee.framework.core.model | |
parent | a87d6a9b6f138ed893e5d62e770d7ca47dd1957c (diff) | |
download | org.eclipse.osee-4c7fa436c1f79c6a57a813193779ca9e1495fc78.tar.gz org.eclipse.osee-4c7fa436c1f79c6a57a813193779ca9e1495fc78.tar.xz org.eclipse.osee-4c7fa436c1f79c6a57a813193779ca9e1495fc78.zip |
refactor: Remove unecessary calls to AbstractOseeCache.decache
Change-Id: I905738b4ec9206a2de725bbcc4d3641c3e232b69
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.model')
6 files changed, 15 insertions, 27 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/BranchFactory.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/BranchFactory.java index 1923759c43e..c58c332800b 100644 --- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/BranchFactory.java +++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/BranchFactory.java @@ -44,14 +44,13 @@ public class BranchFactory implements IOseeTypeFactory { Branch branch = cache.getByGuid(guid); if (branch == null) { branch = create(guid, name, branchType, branchState, isArchived); + cache.cache(branch); } else { - cache.decache(branch); branch.setName(name); branch.setArchived(isArchived); branch.setBranchState(branchState); branch.setBranchType(branchType); } - cache.cache(branch); return branch; } @@ -62,15 +61,14 @@ public class BranchFactory implements IOseeTypeFactory { branch = create(guid, name, branchType, branchState, isArchived); branch.setId(uniqueId); branch.setStorageState(storageState); + cache.cache(branch); } else { - cache.decache(branch); branch.setName(name); branch.setArchived(isArchived); branch.setBranchState(branchState); branch.setBranchType(branchType); branch.setStorageState(storageState); } - cache.cache(branch); return branch; } } diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/AbstractOseeCache.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/AbstractOseeCache.java index d25fe98fceb..e3e91e3b53a 100644 --- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/AbstractOseeCache.java +++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/AbstractOseeCache.java @@ -14,7 +14,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; -import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; @@ -40,8 +39,8 @@ import org.eclipse.osee.framework.logging.OseeLog; public abstract class AbstractOseeCache<K, T extends AbstractOseeType<K>> implements IOseeCache<K, T> { private final HashCollection<String, T> nameToTypeMap = new HashCollection<String, T>(true, CopyOnWriteArrayList.class); - private final Map<Integer, T> idToTypeMap = new ConcurrentHashMap<Integer, T>(); - private final Map<K, T> guidToTypeMap = new ConcurrentHashMap<K, T>(); + private final ConcurrentHashMap<Integer, T> idToTypeMap = new ConcurrentHashMap<Integer, T>(); + private final ConcurrentHashMap<K, T> guidToTypeMap = new ConcurrentHashMap<K, T>(); private final IOseeDataAccessor<K, T> dataAccessor; private final OseeCacheEnum cacheId; @@ -170,7 +169,7 @@ public abstract class AbstractOseeCache<K, T extends AbstractOseeType<K>> implem Conditions.checkNotNull(type, "type to cache"); ensurePopulated(); nameToTypeMap.put(type.getName(), type); - guidToTypeMap.put(type.getGuid(), type); + guidToTypeMap.putIfAbsent(type.getGuid(), type); cacheById(type); if (isNameUniquenessEnforced()) { checkNameUnique(type); @@ -201,7 +200,7 @@ public abstract class AbstractOseeCache<K, T extends AbstractOseeType<K>> implem Conditions.checkNotNull(type, "type to cache"); ensurePopulated(); if (type.isIdValid()) { - idToTypeMap.put(type.getId(), type); + idToTypeMap.putIfAbsent(type.getId(), type); } } @@ -336,13 +335,12 @@ public abstract class AbstractOseeCache<K, T extends AbstractOseeType<K>> implem @Override public void storeItems(T... items) throws OseeCoreException { - Conditions.checkNotNull(items, "items to store"); storeItems(Arrays.asList(items)); } @Override public void storeItems(Collection<T> toStore) throws OseeCoreException { - Conditions.checkNotNull(toStore, "items to store"); + Conditions.checkDoesNotContainNulls(toStore, "items to store"); if (!toStore.isEmpty()) { getDataAccessor().store(toStore); synchronized (this) { diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/ArtifactTypeFactory.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/ArtifactTypeFactory.java index e6da8324079..98fb98a3e9d 100644 --- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/ArtifactTypeFactory.java +++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/ArtifactTypeFactory.java @@ -32,12 +32,11 @@ public final class ArtifactTypeFactory implements IOseeTypeFactory { ArtifactType artifactType = cache.getByGuid(guid); if (artifactType == null) { artifactType = create(guid, isAbstract, name); + cache.cache(artifactType); } else { - cache.decache(artifactType); artifactType.setName(name); artifactType.setAbstract(isAbstract); } - cache.cache(artifactType); return artifactType; } @@ -48,12 +47,11 @@ public final class ArtifactTypeFactory implements IOseeTypeFactory { artifactType = create(guid, isAbstract, name); artifactType.setId(uniqueId); artifactType.setStorageState(storageState); + cache.cache(artifactType); } else { - cache.decache(artifactType); artifactType.setName(name); artifactType.setAbstract(isAbstract); } - cache.cache(artifactType); return artifactType; } } diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/AttributeTypeFactory.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/AttributeTypeFactory.java index 8f57a29b8d0..49300ec7a5b 100644 --- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/AttributeTypeFactory.java +++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/AttributeTypeFactory.java @@ -50,12 +50,11 @@ public class AttributeTypeFactory implements IOseeTypeFactory { create(guid, typeName, baseAttributeTypeId, attributeProviderNameId, fileTypeExtension, defaultValue, minOccurrences, maxOccurrences, description, taggerId, mediaType); attributeType.setOseeEnumType(oseeEnumType); + cache.cache(attributeType); } else { - cache.decache(attributeType); attributeType.setFields(typeName, baseAttributeTypeId, attributeProviderNameId, fileTypeExtension, defaultValue, oseeEnumType, minOccurrences, maxOccurrences, description, taggerId, mediaType); } - cache.cache(attributeType); return attributeType; } @@ -69,12 +68,11 @@ public class AttributeTypeFactory implements IOseeTypeFactory { attributeType.setOseeEnumType(oseeEnumType); attributeType.setId(uniqueId); attributeType.setStorageState(storageState); + cache.cache(attributeType); } else { - cache.decache(attributeType); attributeType.setFields(typeName, baseAttributeTypeId, attributeProviderNameId, fileTypeExtension, defaultValue, oseeEnumType, minOccurrences, maxOccurrences, description, taggerId, mediaType); } - cache.cache(attributeType); return attributeType; } } diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/OseeEnumTypeFactory.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/OseeEnumTypeFactory.java index e0d5dfcad88..e1fa16ef0a9 100644 --- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/OseeEnumTypeFactory.java +++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/OseeEnumTypeFactory.java @@ -43,11 +43,10 @@ public class OseeEnumTypeFactory implements IOseeTypeFactory { oseeEnumType = createEnumType(guid, enumTypeName); oseeEnumType.setId(enumTypeId); oseeEnumType.setStorageState(storageState); + cache.cache(oseeEnumType); } else { - cache.decache(oseeEnumType); oseeEnumType.setName(enumTypeName); } - cache.cache(oseeEnumType); return oseeEnumType; } @@ -56,11 +55,10 @@ public class OseeEnumTypeFactory implements IOseeTypeFactory { OseeEnumType oseeEnumType = cache.getByGuid(guid); if (oseeEnumType == null) { oseeEnumType = createEnumType(guid, enumTypeName); + cache.cache(oseeEnumType); } else { - cache.decache(oseeEnumType); oseeEnumType.setName(enumTypeName); } - cache.cache(oseeEnumType); return oseeEnumType; } diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/RelationTypeFactory.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/RelationTypeFactory.java index 85867929327..bce32db2442 100644 --- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/RelationTypeFactory.java +++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/RelationTypeFactory.java @@ -42,12 +42,11 @@ public class RelationTypeFactory implements IOseeTypeFactory { relationType = create(guid, typeName, sideAName, sideBName, artifactTypeSideA, artifactTypeSideB, multiplicity, defaultOrderTypeGuid); + cache.cache(relationType); } else { - cache.decache(relationType); relationType.setFields(typeName, sideAName, sideBName, artifactTypeSideA, artifactTypeSideB, multiplicity, defaultOrderTypeGuid); } - cache.cache(relationType); return relationType; } @@ -60,12 +59,11 @@ public class RelationTypeFactory implements IOseeTypeFactory { defaultOrderTypeGuid); relationType.setId(typeId); relationType.setStorageState(storageState); + cache.cache(relationType); } else { - cache.decache(relationType); relationType.setFields(typeName, sideAName, sideBName, artifactTypeSideA, artifactTypeSideB, multiplicity, defaultOrderTypeGuid); } - cache.cache(relationType); return relationType; } } |