Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Arthorne2008-01-10 20:16:39 +0000
committerJohn Arthorne2008-01-10 20:16:39 +0000
commit9d8a7a78ed908d1b4ca3eb03d156b8edfc930b4a (patch)
treea83932c79fcc176fab913cbf801f5af864e030be
parent360c05b145a952a1d305e1ea2d8ef30fae2cc040 (diff)
downloadrt.equinox.p2-9d8a7a78ed908d1b4ca3eb03d156b8edfc930b4a.tar.gz
rt.equinox.p2-9d8a7a78ed908d1b4ca3eb03d156b8edfc930b4a.tar.xz
rt.equinox.p2-9d8a7a78ed908d1b4ca3eb03d156b8edfc930b4a.zip
Added assertModifiable convenience method
-rw-r--r--bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/spi/p2/core/repository/AbstractRepository.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/spi/p2/core/repository/AbstractRepository.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/spi/p2/core/repository/AbstractRepository.java
index 8e27b768d..6a2015208 100644
--- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/spi/p2/core/repository/AbstractRepository.java
+++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/spi/p2/core/repository/AbstractRepository.java
@@ -42,6 +42,16 @@ public abstract class AbstractRepository extends PlatformObject implements IRepo
}
/**
+ * Asserts that this repository is modifiable, throwing a runtime exception if
+ * it is not. This is suitable for use by subclasses when an attempt is made
+ * to write to a repository.
+ */
+ protected void assertModifiable() {
+ if (!isModifiable())
+ throw new UnsupportedOperationException("Repository not modifiable"); //$NON-NLS-1$
+ }
+
+ /**
* Returns a brief description of the repository.
* @return the description of the repository.
*/
@@ -112,8 +122,7 @@ public abstract class AbstractRepository extends PlatformObject implements IRepo
}
public String setProperty(String key, String value) {
- if (!isModifiable())
- throw new UnsupportedOperationException("Repository not modifiable"); //$NON-NLS-1$
+ assertModifiable();
return (String) (value == null ? properties.remove(key) : properties.put(key, value));
}

Back to the top