}
@Override
- public DOMMountPointBuilder createMountPoint(final YangInstanceIdentifier path) {
- checkState(!mountPoints.containsKey(path), "Mount point already exists");
+ public synchronized DOMMountPointBuilder createMountPoint(final YangInstanceIdentifier path) {
+ checkNotExists(path, mountPoints.get(requireNonNull(path)));
return new DOMMountPointBuilderImpl(path);
}
private ObjectRegistration<DOMMountPoint> registerMountPoint(final SimpleDOMMountPoint mountPoint) {
final YangInstanceIdentifier mountPointId = mountPoint.getIdentifier();
synchronized (mountPoints) {
- final DOMMountPoint prev = mountPoints.putIfAbsent(mountPointId, mountPoint);
- checkState(prev == null, "Mount point %s already exists as %s", mountPointId, prev);
+ checkNotExists(mountPointId, mountPoints.putIfAbsent(mountPointId, mountPoint));
}
listeners.streamListeners().forEach(listener -> {
try {
});
}
- private final class DOMMountPointBuilderImpl implements DOMMountPointBuilder {
+ private static void checkNotExists(final YangInstanceIdentifier id, final DOMMountPoint mountPoint) {
+ checkState(mountPoint == null, "Mount point %s already exists as %s", id, mountPoint);
+ }
+ private final class DOMMountPointBuilderImpl implements DOMMountPointBuilder {
private final MutableClassToInstanceMap<DOMService> services = MutableClassToInstanceMap.create();
private final YangInstanceIdentifier path;