Datastore { public static LogicalDatastoreType toType(Class<? extends Datastore> datastoreClass) { if (datastoreClass.equals(Configuration.class)) { return LogicalDatastoreType.CONFIGURATION; } else if (Operational.class.equals(datastoreClass)) { return LogicalDatastoreType.OPERATIONAL; } else { throw new IllegalArgumentException("Unknown datastore class " + datastoreClass); } } private  Datastore(); static LogicalDatastoreType toType(Class<? extends Datastore> datastoreClass); static Class<? extends Datastore> toClass(LogicalDatastoreType datastoreType); static final Class<Configuration> CONFIGURATION; static final Class<Operational> OPERATIONAL; }
@Test public void testDatastoreToType() { assertEquals(LogicalDatastoreType.CONFIGURATION, Datastore.toType(Datastore.CONFIGURATION)); assertEquals(LogicalDatastoreType.OPERATIONAL, Datastore.toType(Datastore.OPERATIONAL)); assertThrows(NullPointerException.class, () -> Datastore.toType(null)); }