@Test public void testFindProperty() { Properties properties = DataStoreFactory.createProps(); DataStore<String, MockPersistent> store = new DataFileAvroStore<>(); String fooValue = DataStoreFactory.findProperty(properties, store, "foo_property", "foo_default"); assertEquals("foo_value", fooValue); String bazValue = DataStoreFactory.findProperty(properties, store, "baz_property", "baz_default"); assertEquals("baz_value", bazValue); String barValue = DataStoreFactory.findProperty(properties, store, "bar_property", "bar_default"); assertEquals("bar_value", barValue); String capValue = DataStoreFactory.findProperty(properties, store, "cap_property", "cap_default"); assertEquals("cap_value", capValue); String secondCapValue = DataStoreFactory.findProperty(properties, store, "CAP_property", "cap_default"); assertEquals("cap_value", secondCapValue); }
public static String findProperty(Properties properties , DataStore<?, ?> store, String baseKey, String defaultValue) { Class<?> clazz = store.getClass(); while(true) { String fullKey = GORA + "." + org.apache.gora.util.StringUtils.getClassname(clazz).toLowerCase(Locale.getDefault()) + "." + baseKey; String value = getProperty(properties, fullKey); if(value != null) { return value; } value = getProperty(properties, fullKey.toLowerCase(Locale.getDefault())); 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.apache.gora.util.StringUtils.getClassname(clazz).toLowerCase(Locale.getDefault()) + "." + baseKey; String value = getProperty(properties, fullKey); if(value != null) { return value; } value = getProperty(properties, fullKey.toLowerCase(Locale.getDefault())); 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.apache.gora.util.StringUtils.getClassname(clazz).toLowerCase(Locale.getDefault()) + "." + baseKey; String value = getProperty(properties, fullKey); if(value != null) { return value; } value = getProperty(properties, fullKey.toLowerCase(Locale.getDefault())); 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.apache.gora.util.StringUtils.getClassname(clazz).toLowerCase(Locale.getDefault()) + "." + baseKey; String value = getProperty(properties, fullKey); if(value != null) { return value; } value = getProperty(properties, fullKey.toLowerCase(Locale.getDefault())); 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 Properties createProps(); static D createDataStore(Class<D> dataStoreClass
      , Class<K> keyClass, Class<T> persistent, Configuration conf); static D createDataStore(Class<D> dataStoreClass , Class<K> keyClass, 
      Class<T> persistent, Configuration conf, String schemaName); static D createDataStore(Class<D> dataStoreClass, Class<K> keyClass
      , Class<T> persistent, Configuration conf, Properties properties, String schemaName); static D createDataStore(Class<D> dataStoreClass
      , Class<K> keyClass, Class<T> persistent, Configuration conf, Properties properties); static D getDataStore( Class<D> dataStoreClass, Class<K> keyClass,
      Class<T> persistentClass, Configuration conf); @SuppressWarnings("unchecked") static DataStore<K, T> getDataStore(
      String dataStoreClass, Class<K> keyClass, Class<T> persistentClass, Configuration conf); @SuppressWarnings({ "unchecked" }) static DataStore<K, T> getDataStore(
      String dataStoreClass, String keyClass, String persistentClass, Configuration conf); @SuppressWarnings({ "unchecked" }) static DataStore<K, T> getDataStore(
      String keyClass, String persistentClass, Properties props, Configuration conf); @SuppressWarnings({ "unchecked" }) static DataStore<K, T> getDataStore(
      String dataStoreClass, String keyClass, String persistentClass, Properties props, Configuration conf); @SuppressWarnings("unchecked") static DataStore<K, T> getDataStore(
      Class<K> keyClass, Class<T> persistent, Configuration conf); @SuppressWarnings("unchecked") static DataStore<K, T> getDataStore(
          Class<K> keyClass, Class<T> persistent, Configuration conf, boolean isCacheEnabled); 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 getDefaultDataStore(Properties properties); 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.apache.gora.util.StringUtils.getClassname(clazz).toLowerCase(Locale.getDefault()) + "." + baseKey; String value = getProperty(properties, fullKey); if(value != null) { return value; } value = getProperty(properties, fullKey.toLowerCase(Locale.getDefault())); 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 Properties createProps(); static D createDataStore(Class<D> dataStoreClass
      , Class<K> keyClass, Class<T> persistent, Configuration conf); static D createDataStore(Class<D> dataStoreClass , Class<K> keyClass, 
      Class<T> persistent, Configuration conf, String schemaName); static D createDataStore(Class<D> dataStoreClass, Class<K> keyClass
      , Class<T> persistent, Configuration conf, Properties properties, String schemaName); static D createDataStore(Class<D> dataStoreClass
      , Class<K> keyClass, Class<T> persistent, Configuration conf, Properties properties); static D getDataStore( Class<D> dataStoreClass, Class<K> keyClass,
      Class<T> persistentClass, Configuration conf); @SuppressWarnings("unchecked") static DataStore<K, T> getDataStore(
      String dataStoreClass, Class<K> keyClass, Class<T> persistentClass, Configuration conf); @SuppressWarnings({ "unchecked" }) static DataStore<K, T> getDataStore(
      String dataStoreClass, String keyClass, String persistentClass, Configuration conf); @SuppressWarnings({ "unchecked" }) static DataStore<K, T> getDataStore(
      String keyClass, String persistentClass, Properties props, Configuration conf); @SuppressWarnings({ "unchecked" }) static DataStore<K, T> getDataStore(
      String dataStoreClass, String keyClass, String persistentClass, Properties props, Configuration conf); @SuppressWarnings("unchecked") static DataStore<K, T> getDataStore(
      Class<K> keyClass, Class<T> persistent, Configuration conf); @SuppressWarnings("unchecked") static DataStore<K, T> getDataStore(
          Class<K> keyClass, Class<T> persistent, Configuration conf, boolean isCacheEnabled); 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 getDefaultDataStore(Properties properties); 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 Logger log; static final String GORA_DEFAULT_PROPERTIES_FILE; static final String GORA_DEFAULT_DATASTORE_KEY; static final String GORA_DEFAULT_CACHE_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; }