Skip to content

Commit

Permalink
[BEAM-14048] Set macroFields
Browse files Browse the repository at this point in the history
  • Loading branch information
Amar3tto committed May 4, 2022
1 parent 7c0028c commit 9df1c75
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand All @@ -37,6 +38,7 @@
public class PluginConfigInstantiationUtils {

private static final Logger LOG = LoggerFactory.getLogger(PluginConfigInstantiationUtils.class);
private static final String MACRO_FIELDS_FIELD_NAME = "macroFields";

/**
* Method for instantiating {@link PluginConfig} object of specific class {@param configClass}.
Expand All @@ -58,8 +60,7 @@ public class PluginConfigInstantiationUtils {
while (currClass != null && !currClass.equals(Object.class)) {
allFields.addAll(
Arrays.stream(currClass.getDeclaredFields())
.filter(
f -> !Modifier.isStatic(f.getModifiers()) && f.isAnnotationPresent(Name.class))
.filter(f -> !Modifier.isStatic(f.getModifiers()))
.collect(Collectors.toList()));
currClass = currClass.getSuperclass();
}
Expand All @@ -83,6 +84,12 @@ public class PluginConfigInstantiationUtils {
} catch (IllegalAccessException e) {
LOG.error("Can not set a field with value {}", fieldValue);
}
} else if (field.getName().equals(MACRO_FIELDS_FIELD_NAME)) {
try {
field.set(config, Collections.emptySet());
} catch (IllegalAccessException e) {
LOG.error("Can not set macro fields");
}
}
}
}
Expand Down

0 comments on commit 9df1c75

Please sign in to comment.