@Test public void testGetClasses() throws ClassNotFoundException { DataStore<?,?> dataStore = DataStoreFactory.getDataStore("org.gora.mock.store.MockDataStore" , String.class, MockPersistent.class); Assert.assertNotNull(dataStore); Assert.assertEquals(String.class, dataStore.getKeyClass()); Assert.assertEquals(MockPersistent.class, dataStore.getPersistentClass()); }
@SuppressWarnings("unchecked") public static <D extends DataStore<K,T>, K, T extends Persistent> D getDataStore( Class<D> dataStoreClass, Class<K> keyClass, Class<T> persistentClass) { int hash = getDataStoreKey(dataStoreClass, keyClass, persistentClass); D dataStore = (D) dataStores.get(hash); if(dataStore == null) { dataStore = createDataStore(dataStoreClass, keyClass, persistentClass , properties); dataStores.put(hash, dataStore); } return dataStore; }
DataStoreFactory { @SuppressWarnings("unchecked") public static <D extends DataStore<K,T>, K, T extends Persistent> D getDataStore( Class<D> dataStoreClass, Class<K> keyClass, Class<T> persistentClass) { int hash = getDataStoreKey(dataStoreClass, keyClass, persistentClass); D dataStore = (D) dataStores.get(hash); if(dataStore == null) { dataStore = createDataStore(dataStoreClass, keyClass, persistentClass , properties); dataStores.put(hash, dataStore); } return dataStore; } }
DataStoreFactory { @SuppressWarnings("unchecked") public static <D extends DataStore<K,T>, K, T extends Persistent> D getDataStore( Class<D> dataStoreClass, Class<K> keyClass, Class<T> persistentClass) { int hash = getDataStoreKey(dataStoreClass, keyClass, persistentClass); D dataStore = (D) dataStores.get(hash); if(dataStore == null) { dataStore = createDataStore(dataStoreClass, keyClass, persistentClass , properties); dataStores.put(hash, dataStore); } return dataStore; } private  DataStoreFactory(); }
DataStoreFactory { @SuppressWarnings("unchecked") public static <D extends DataStore<K,T>, K, T extends Persistent> D getDataStore( Class<D> dataStoreClass, Class<K> keyClass, Class<T> persistentClass) { int hash = getDataStoreKey(dataStoreClass, keyClass, persistentClass); D dataStore = (D) dataStores.get(hash); if(dataStore == null) { dataStore = createDataStore(dataStoreClass, keyClass, persistentClass , properties); dataStores.put(hash, dataStore); } return dataStore; } private  DataStoreFactory(); static D createDataStore(Class<D> dataStoreClass
      , Class<K> keyClass, Class<T> persistent); static D createDataStore(Class<D> dataStoreClass
      , Class<K> keyClass, Class<T> persistent, String schemaName); static D createDataStore(Class<D> dataStoreClass, Class<K> keyClass
      , Class<T> persistent, Properties properties, String schemaName); static D createDataStore(Class<D> dataStoreClass
      , Class<K> keyClass, Class<T> persistent, Properties properties); @SuppressWarnings("unchecked") static D getDataStore( Class<D> dataStoreClass, Class<K> keyClass,
      Class<T> persistentClass); @SuppressWarnings("unchecked") static synchronized DataStore<K, T> getDataStore(
      String dataStoreClass, Class<K> keyClass, Class<T> persistentClass); @SuppressWarnings({ "unchecked", "rawtypes" }) static synchronized DataStore getDataStore(
      String dataStoreClass, String keyClass, String persistentClass); static DataStore<K, T> getDataStore(
      Class<K> keyClass, Class<T> persistent); static String findProperty(Properties properties
      , DataStore<?, ?> store, String baseKey, String defaultValue); static String findPropertyOrDie(Properties properties
      , DataStore<?, ?> store, String baseKey); static boolean findBooleanProperty(Properties properties
      , DataStore<?, ?> store, String baseKey, String defaultValue); static boolean getAutoCreateSchema(Properties properties
      , DataStore<?,?> store); static String getInputPath(Properties properties, DataStore<?,?> store); static String getOutputPath(Properties properties, DataStore<?,?> store); static String getMappingFile(Properties properties, DataStore<?,?> store
      , String defaultValue); static String getDefaultSchemaName(Properties properties, DataStore<?,?> store); static void setDefaultSchemaName(Properties properties, String schemaName); static void setDefaultSchemaName(Properties properties, Class<D> dataStoreClass, String schemaName); }
DataStoreFactory { @SuppressWarnings("unchecked") public static <D extends DataStore<K,T>, K, T extends Persistent> D getDataStore( Class<D> dataStoreClass, Class<K> keyClass, Class<T> persistentClass) { int hash = getDataStoreKey(dataStoreClass, keyClass, persistentClass); D dataStore = (D) dataStores.get(hash); if(dataStore == null) { dataStore = createDataStore(dataStoreClass, keyClass, persistentClass , properties); dataStores.put(hash, dataStore); } return dataStore; } private  DataStoreFactory(); static D createDataStore(Class<D> dataStoreClass
      , Class<K> keyClass, Class<T> persistent); static D createDataStore(Class<D> dataStoreClass
      , Class<K> keyClass, Class<T> persistent, String schemaName); static D createDataStore(Class<D> dataStoreClass, Class<K> keyClass
      , Class<T> persistent, Properties properties, String schemaName); static D createDataStore(Class<D> dataStoreClass
      , Class<K> keyClass, Class<T> persistent, Properties properties); @SuppressWarnings("unchecked") static D getDataStore( Class<D> dataStoreClass, Class<K> keyClass,
      Class<T> persistentClass); @SuppressWarnings("unchecked") static synchronized DataStore<K, T> getDataStore(
      String dataStoreClass, Class<K> keyClass, Class<T> persistentClass); @SuppressWarnings({ "unchecked", "rawtypes" }) static synchronized DataStore getDataStore(
      String dataStoreClass, String keyClass, String persistentClass); static DataStore<K, T> getDataStore(
      Class<K> keyClass, Class<T> persistent); static String findProperty(Properties properties
      , DataStore<?, ?> store, String baseKey, String defaultValue); static String findPropertyOrDie(Properties properties
      , DataStore<?, ?> store, String baseKey); static boolean findBooleanProperty(Properties properties
      , DataStore<?, ?> store, String baseKey, String defaultValue); static boolean getAutoCreateSchema(Properties properties
      , DataStore<?,?> store); static String getInputPath(Properties properties, DataStore<?,?> store); static String getOutputPath(Properties properties, DataStore<?,?> store); static String getMappingFile(Properties properties, DataStore<?,?> store
      , String defaultValue); static String getDefaultSchemaName(Properties properties, DataStore<?,?> store); static void setDefaultSchemaName(Properties properties, String schemaName); static void setDefaultSchemaName(Properties properties, Class<D> dataStoreClass, String schemaName); static final Log log; static final String GORA_DEFAULT_PROPERTIES_FILE; static final String GORA_DEFAULT_DATASTORE_KEY; static final String GORA; static final String DATASTORE; static final String AUTO_CREATE_SCHEMA; static final String INPUT_PATH; static final String OUTPUT_PATH; static final String MAPPING_FILE; static final String SCHEMA_NAME; static Properties properties; }