@Test public void testFindProperty() { Properties properties = DataStoreFactory.properties; DataStore<String, MockPersistent> store = new DataFileAvroStore<String,MockPersistent>(); String fooValue = DataStoreFactory.findProperty(properties, store , "foo_property", "foo_default"); Assert.assertEquals("foo_value", fooValue); String bazValue = DataStoreFactory.findProperty(properties, store , "baz_property", "baz_default"); Assert.assertEquals("baz_value", bazValue); String barValue = DataStoreFactory.findProperty(properties, store , "bar_property", "bar_default"); Assert.assertEquals("bar_value", barValue); }
public static String findProperty(Properties properties , DataStore<?, ?> store, String baseKey, String defaultValue) { Class<?> clazz = store.getClass(); while(true) { String fullKey = GORA + "." + org.gora.util.StringUtils.getClassname(clazz) + "." + baseKey; String value = getProperty(properties, fullKey); if(value != null) { return value; } value = getProperty(properties, fullKey.toLowerCase()); if(value != null) { return value; } if(clazz.equals(DataStoreBase.class)) { break; } clazz = clazz.getSuperclass(); if(clazz == null) { break; } } String fullKey = GORA + "." + DATASTORE + "." + baseKey; String value = getProperty(properties, fullKey); if(value != null) { return value; } return defaultValue; }
DataStoreFactory { public static String findProperty(Properties properties , DataStore<?, ?> store, String baseKey, String defaultValue) { Class<?> clazz = store.getClass(); while(true) { String fullKey = GORA + "." + org.gora.util.StringUtils.getClassname(clazz) + "." + baseKey; String value = getProperty(properties, fullKey); if(value != null) { return value; } value = getProperty(properties, fullKey.toLowerCase()); if(value != null) { return value; } if(clazz.equals(DataStoreBase.class)) { break; } clazz = clazz.getSuperclass(); if(clazz == null) { break; } } String fullKey = GORA + "." + DATASTORE + "." + baseKey; String value = getProperty(properties, fullKey); if(value != null) { return value; } return defaultValue; } }
DataStoreFactory { public static String findProperty(Properties properties , DataStore<?, ?> store, String baseKey, String defaultValue) { Class<?> clazz = store.getClass(); while(true) { String fullKey = GORA + "." + org.gora.util.StringUtils.getClassname(clazz) + "." + baseKey; String value = getProperty(properties, fullKey); if(value != null) { return value; } value = getProperty(properties, fullKey.toLowerCase()); if(value != null) { return value; } if(clazz.equals(DataStoreBase.class)) { break; } clazz = clazz.getSuperclass(); if(clazz == null) { break; } } String fullKey = GORA + "." + DATASTORE + "." + baseKey; String value = getProperty(properties, fullKey); if(value != null) { return value; } return defaultValue; } private  DataStoreFactory(); }
DataStoreFactory { public static String findProperty(Properties properties , DataStore<?, ?> store, String baseKey, String defaultValue) { Class<?> clazz = store.getClass(); while(true) { String fullKey = GORA + "." + org.gora.util.StringUtils.getClassname(clazz) + "." + baseKey; String value = getProperty(properties, fullKey); if(value != null) { return value; } value = getProperty(properties, fullKey.toLowerCase()); if(value != null) { return value; } if(clazz.equals(DataStoreBase.class)) { break; } clazz = clazz.getSuperclass(); if(clazz == null) { break; } } String fullKey = GORA + "." + DATASTORE + "." + baseKey; String value = getProperty(properties, fullKey); if(value != null) { return value; } return defaultValue; } 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 { public static String findProperty(Properties properties , DataStore<?, ?> store, String baseKey, String defaultValue) { Class<?> clazz = store.getClass(); while(true) { String fullKey = GORA + "." + org.gora.util.StringUtils.getClassname(clazz) + "." + baseKey; String value = getProperty(properties, fullKey); if(value != null) { return value; } value = getProperty(properties, fullKey.toLowerCase()); if(value != null) { return value; } if(clazz.equals(DataStoreBase.class)) { break; } clazz = clazz.getSuperclass(); if(clazz == null) { break; } } String fullKey = GORA + "." + DATASTORE + "." + baseKey; String value = getProperty(properties, fullKey); if(value != null) { return value; } return defaultValue; } 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; }