Datastore { public static Class<? extends Datastore> toClass(LogicalDatastoreType datastoreType) { switch (datastoreType) { case CONFIGURATION: return CONFIGURATION; case OPERATIONAL: return OPERATIONAL; default: throw new IllegalArgumentException("Unknown datastore type " + datastoreType); } } 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 testDatastoreToClass() { assertEquals(Datastore.CONFIGURATION, Datastore.toClass(LogicalDatastoreType.CONFIGURATION)); assertEquals(Datastore.OPERATIONAL, Datastore.toClass(LogicalDatastoreType.OPERATIONAL)); assertThrows(NullPointerException.class, () -> Datastore.toClass(null)); }