This handles common functionalities for all segment stores.
This can be seen as part of the segment store contract.
Anything removing items from a segment store asside from
clear should throw an unsupportedOperationException.
If an implementation decides to support this, that is fine, but
not the expected way the object should behave.
Change-Id: I9d00960ae8826cecc63092245ca7fc447a28defb
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/83305
Reviewed-by: Hudson CI
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net>
}
}
- @Override
- public boolean remove(@Nullable Object o) {
- throw new UnsupportedOperationException();
- }
-
@Override
public boolean addAll(@Nullable Collection<? extends E> c) {
if (c == null) {
}
}
- @Override
- public boolean removeAll(@Nullable Collection<?> c) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean retainAll(@Nullable Collection<?> c) {
- throw new UnsupportedOperationException();
- }
-
@Override
public void clear() {
fLock.writeLock().lock();
*/
public class LazyArrayListStore<@NonNull E extends ISegment> implements ISegmentStore<E> {
- private static final String ERROR_MESSAGE = "Cannot remove from a segment store"; //$NON-NLS-1$
-
private final Comparator<E> COMPARATOR = Ordering.from(SegmentComparators.INTERVAL_START_COMPARATOR)
.compound(SegmentComparators.INTERVAL_END_COMPARATOR);
}
}
- @Override
- public boolean removeAll(@Nullable Collection<?> c) {
- throw new UnsupportedOperationException(ERROR_MESSAGE);
- }
-
- @Override
- public boolean retainAll(@Nullable Collection<?> c) {
- throw new UnsupportedOperationException(ERROR_MESSAGE);
- }
-
- @Override
- public boolean remove(@Nullable Object o) {
- throw new UnsupportedOperationException(ERROR_MESSAGE);
- }
-
@Override
public void clear() {
fLock.lock();
}
}
- @Override
- public boolean remove(@Nullable Object o) {
- throw new UnsupportedOperationException();
- }
-
@Override
public boolean addAll(@Nullable Collection<? extends E> c) {
if (c == null) {
}
}
- @Override
- public boolean removeAll(@Nullable Collection<?> c) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean retainAll(@Nullable Collection<?> c) {
- throw new UnsupportedOperationException();
- }
-
@Override
public void clear() {
fLock.writeLock().lock();
import com.google.common.collect.Lists;
+import org.eclipse.jdt.annotation.Nullable;
+
/**
* Interface for segment-storing backends.
*
+ * Common contract (what should not be implemented) for a segment store.
+ * <ol>
+ * <li>no remove</li>
+ * <li>no removeAll</li>
+ * <li>no retainall</li>
+ * </ol>
+ *
* @param <E>
* The type of {@link ISegment} element that will be stored in this
* database.
default void close(boolean deleteFiles) {
}
+
+ @Override
+ default boolean remove(@Nullable Object o) {
+ throw new UnsupportedOperationException("Segment stores does not support \"remove\""); //$NON-NLS-1$
+ }
+
+ @Override
+ default boolean removeAll(@Nullable Collection<?> c) {
+ throw new UnsupportedOperationException("Segment stores does not support \"removeAll\""); //$NON-NLS-1$
+ }
+
+ @Override
+ default boolean retainAll(@Nullable Collection<?> c) {
+ throw new UnsupportedOperationException("Segment stores does not support \"retainAll\""); //$NON-NLS-1$
+ }
}