@Test public void testCreateEncryptionContextTableNameOverrideMap_expectedOverride() { Map<String, String> tableNameOverrides = new HashMap<>(); tableNameOverrides.put("OriginalTableName", "MyNewTableName"); Function<EncryptionContext, EncryptionContext> nameOverrideMap = overrideEncryptionContextTableNameUsingMap(tableNameOverrides); EncryptionContext context = EncryptionContext.builder().tableName("OriginalTableName").build(); EncryptionContext newContext = nameOverrideMap.apply(context); assertEquals("OriginalTableName", context.getTableName()); assertEquals("MyNewTableName", newContext.getTableName()); }
static UnaryOperator<EncryptionContext> overrideEncryptionContextTableNameUsingMap( Map<String, String> tableNameOverrideMap) { return encryptionContext -> { if (tableNameOverrideMap == null || encryptionContext == null || encryptionContext.getTableName() == null) { return encryptionContext; } String newTableName = tableNameOverrideMap.get(encryptionContext.getTableName()); if (newTableName != null) { return encryptionContext.toBuilder().tableName(newTableName).build(); } else { return encryptionContext; } }; }
EncryptionContextOperators { static UnaryOperator<EncryptionContext> overrideEncryptionContextTableNameUsingMap( Map<String, String> tableNameOverrideMap) { return encryptionContext -> { if (tableNameOverrideMap == null || encryptionContext == null || encryptionContext.getTableName() == null) { return encryptionContext; } String newTableName = tableNameOverrideMap.get(encryptionContext.getTableName()); if (newTableName != null) { return encryptionContext.toBuilder().tableName(newTableName).build(); } else { return encryptionContext; } }; } }
EncryptionContextOperators { static UnaryOperator<EncryptionContext> overrideEncryptionContextTableNameUsingMap( Map<String, String> tableNameOverrideMap) { return encryptionContext -> { if (tableNameOverrideMap == null || encryptionContext == null || encryptionContext.getTableName() == null) { return encryptionContext; } String newTableName = tableNameOverrideMap.get(encryptionContext.getTableName()); if (newTableName != null) { return encryptionContext.toBuilder().tableName(newTableName).build(); } else { return encryptionContext; } }; } private  EncryptionContextOperators(); }
EncryptionContextOperators { static UnaryOperator<EncryptionContext> overrideEncryptionContextTableNameUsingMap( Map<String, String> tableNameOverrideMap) { return encryptionContext -> { if (tableNameOverrideMap == null || encryptionContext == null || encryptionContext.getTableName() == null) { return encryptionContext; } String newTableName = tableNameOverrideMap.get(encryptionContext.getTableName()); if (newTableName != null) { return encryptionContext.toBuilder().tableName(newTableName).build(); } else { return encryptionContext; } }; } private  EncryptionContextOperators();  }
EncryptionContextOperators { static UnaryOperator<EncryptionContext> overrideEncryptionContextTableNameUsingMap( Map<String, String> tableNameOverrideMap) { return encryptionContext -> { if (tableNameOverrideMap == null || encryptionContext == null || encryptionContext.getTableName() == null) { return encryptionContext; } String newTableName = tableNameOverrideMap.get(encryptionContext.getTableName()); if (newTableName != null) { return encryptionContext.toBuilder().tableName(newTableName).build(); } else { return encryptionContext; } }; } private  EncryptionContextOperators();   }