/** * {@inheritDoc} This implementation delegates to {@code beginRead()} or * {@code beginWrite()}, depending on the {@code LockMode} argument. * Subclasses can override these protected methods to perform additional * steps when a configuration is locked. * * @since 2.0 * @throws NullPointerException if the argument is <b>null</b> */ @Override public final void lock(final LockMode mode) { switch (mode) { case READ: beginRead(false); break; case WRITE: beginWrite(false); break; default: throw new IllegalArgumentException("Unsupported LockMode: " + mode); } }
/** * {@inheritDoc} This implementation handles synchronization and delegates * to {@code sizeInternal()}. */ @Override public final int size() { beginRead(false); try { return sizeInternal(); } finally { endRead(); } }
/** * {@inheritDoc} This implementation handles synchronization and delegates * to {@code isEmptyInternal()}. */ @Override public final boolean isEmpty() { beginRead(false); try { return isEmptyInternal(); } finally { endRead(); } }
/** * {@inheritDoc} This implementation handles synchronization and delegates * to {@code containsKeyInternal()}. */ @Override public final boolean containsKey(final String key) { beginRead(false); try { return containsKeyInternal(key); } finally { endRead(); } }
/** * {@inheritDoc} This implementation ensures proper synchronization. * Subclasses have to define the abstract {@code getPropertyInternal()} * method which is called from here. */ @Override public final Object getProperty(final String key) { beginRead(false); try { return getPropertyInternal(key); } finally { endRead(); } }
/** * {@inheritDoc} This implementation takes care of synchronization and then * delegates to {@code getKeysInternal()} for obtaining the actual iterator. * Note that depending on a concrete implementation, an iteration may fail * if the configuration is updated concurrently. */ @Override public final Iterator<String> getKeys() { beginRead(false); try { return getKeysInternal(); } finally { endRead(); } }
/** * {@inheritDoc} This implementation returns keys that either match the * prefix or start with the prefix followed by a dot ('.'). So the call * {@code getKeys("db");} will find the keys {@code db}, * {@code db.user}, or {@code db.password}, but not the key * {@code dbdriver}. */ @Override public final Iterator<String> getKeys(final String prefix) { beginRead(false); try { return getKeysInternal(prefix); } finally { endRead(); } }