diff options
author | John Arthorne | 2008-01-10 20:16:39 +0000 |
---|---|---|
committer | John Arthorne | 2008-01-10 20:16:39 +0000 |
commit | 9d8a7a78ed908d1b4ca3eb03d156b8edfc930b4a (patch) | |
tree | a83932c79fcc176fab913cbf801f5af864e030be | |
parent | 360c05b145a952a1d305e1ea2d8ef30fae2cc040 (diff) | |
download | rt.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.java | 13 |
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)); } |