Skip to content

Commit

Permalink
fixed property doc, improvements to the allProperties() method
Browse files Browse the repository at this point in the history
  • Loading branch information
lolocohen committed Apr 29, 2018
1 parent 045bbd3 commit 6d83231
Show file tree
Hide file tree
Showing 2 changed files with 466 additions and 465 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.slf4j.*;

/**
*
* Extract JPPF properties defined as public constants in a given class.
* @author Laurent Cohen
*/
public class ConfigurationUtils {
Expand All @@ -35,18 +35,19 @@ public class ConfigurationUtils {
private static Logger log = LoggerFactory.getLogger(ConfigurationUtils.class);

/**
* Get the list of all predefined configuration properties.
* Get the list of all predefined configuration properties in the specified class.
* @param c the class containing the proeprties constants.
* @return A list of {@link JPPFProperty} instances.
*/
public synchronized static List<JPPFProperty<?>> allProperties(final Class<?> c) {
final List<JPPFProperty<?>> properties = new ArrayList<>();
try {
// compute the base loalisation bundle name
final String i18nBase = c.getPackage().getName() + ".i18n." + c.getSimpleName();
final Field[] fields = c.getDeclaredFields();
for (Field field: fields) {
final int mod = field.getModifiers();
if (Modifier.isStatic(mod) && Modifier.isPublic(mod) && Modifier.isFinal(mod) && (JPPFProperty.class == field.getType())) {
if (Modifier.isStatic(mod) && Modifier.isPublic(mod) && Modifier.isFinal(mod) && JPPFProperty.class.isAssignableFrom(field.getType())) {
if (!field.isAccessible()) field.setAccessible(true);
final JPPFProperty<?> prop = (JPPFProperty<?>) field.get(null);
if (prop instanceof AbstractJPPFProperty) ((AbstractJPPFProperty<?>) prop).setI18nBase(i18nBase);
Expand Down
Loading

0 comments on commit 6d83231

Please sign in to comment.