This is simple check if all datastore are instances of the specified
contract -- simplify the expression with Streams.allMatch()
and Class.isInstance().
Change-Id: I260d3b2296f085023a722c3f59e08c4926e91b2d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
extBuilder.put(DOMDataTreeCommitCohortRegistry.class, new DOMDataTreeCommitCohortRegistry() {
@Override
public <T extends DOMDataTreeCommitCohort> DOMDataTreeCommitCohortRegistration<T> registerCommitCohort(
extBuilder.put(DOMDataTreeCommitCohortRegistry.class, new DOMDataTreeCommitCohortRegistry() {
@Override
public <T extends DOMDataTreeCommitCohort> DOMDataTreeCommitCohortRegistration<T> registerCommitCohort(
- DOMDataTreeIdentifier path, T cohort) {
+ final DOMDataTreeIdentifier path, final T cohort) {
DOMStore store = getDOMStore(path.getDatastoreType());
return ((DOMDataTreeCommitCohortRegistry) store).registerCommitCohort(path, cohort);
}
DOMStore store = getDOMStore(path.getDatastoreType());
return ((DOMDataTreeCommitCohortRegistry) store).registerCommitCohort(path, cohort);
}
extensions = extBuilder.build();
}
extensions = extBuilder.build();
}
- private static boolean isSupported(Map<LogicalDatastoreType, DOMStore> datastores,
- Class<?> expDOMStoreInterface) {
- for (DOMStore ds : datastores.values()) {
- if (!expDOMStoreInterface.isAssignableFrom(ds.getClass())) {
- return false;
- }
- }
-
- return true;
+ private static boolean isSupported(final Map<LogicalDatastoreType, DOMStore> datastores,
+ final Class<?> expDOMStoreInterface) {
+ return datastores.values().stream().allMatch(expDOMStoreInterface::isInstance);
}
public void setCloseable(final AutoCloseable closeable) {
}
public void setCloseable(final AutoCloseable closeable) {