public class OpenPNGImagePluginConfiguration implements Configuration { private static OpenPNGImagePluginConfiguration conf = null; public int maxWidth = 1000; private OpenPNGImagePluginConfiguration() { } public static OpenPNGImagePluginConfiguration getInstance() { if (conf == null) { conf = new OpenPNGImagePluginConfiguration(); } return conf; } }You can just perform:
OpenPNGImagePluginConfiguration conf = OpenPNGImagePluginConfiguration.getInstance(); int maxWidth = conf.maxWidth;
public class OpenPNGImagePluginConfiguration implements Configuration { private static OpenPNGImagePluginConfiguration conf = null; private Set<String> set = new HashSet<>(); public int maxWidth = 1000; public boolean limitWidth = false; private OpenPNGImagePluginConfiguration() { set.add("maxWidth"); set.add("limitWidth"); } public static OpenPNGImagePluginConfiguration getInstance() { if (conf == null) { conf = new OpenPNGImagePluginConfiguration(); } return conf; } @Override public Set<String> getConfigurationPropertiesNames(String confName) { return set; } @Override public boolean hasConfigurationProperty(String propertyName, String confName) { return propertyName.equals("maxWidth") || propertyName.equals("limitWidth"); } @Override public Object getConfigurationProperty(File dir, String propertyName, String confName) { switch (propertyName) { case "maxWidth": return maxWidth; case "limitWidth": return limitWidth; default: return null; } } @Override public Class getConfigurationPropertyType(String propertyName, String confName) { switch (propertyName) { case "maxWidth": return Integer.class; case "limitWidth": return Boolean.class; default: return null; } } @Override public void setConfigurationProperty(File dir, String propertyName, String confName, Object property) { switch (propertyName) { case "maxWidth": maxWidth = (Integer) property; break; case "limitWidth": limitWidth = (Boolean) property; break; } } }
Copyright 2006-2023 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences