You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2018/09/27 22:24:26 UTC
svn commit: r1842194 [6/34] - in /commons/proper/configuration/trunk/src:
main/java/org/apache/commons/configuration2/
main/java/org/apache/commons/configuration2/beanutils/
main/java/org/apache/commons/configuration2/builder/
main/java/org/apache/comm...
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/XMLListReference.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/XMLListReference.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/XMLListReference.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/XMLListReference.java Thu Sep 27 22:24:23 2018
@@ -51,7 +51,7 @@ final class XMLListReference
*
* @param e the associated element
*/
- private XMLListReference(Element e)
+ private XMLListReference(final Element e)
{
element = e;
}
@@ -75,8 +75,8 @@ final class XMLListReference
* @param node the affected configuration node
* @param elem the current XML element
*/
- public static void assignListReference(Map<ImmutableNode, Object> refs,
- ImmutableNode node, Element elem)
+ public static void assignListReference(final Map<ImmutableNode, Object> refs,
+ final ImmutableNode node, final Element elem)
{
if (refs != null)
{
@@ -96,20 +96,20 @@ final class XMLListReference
* @param handler the reference node handler
* @return a flag whether this node is relevant for list handling
*/
- public static boolean isListNode(ImmutableNode node,
- ReferenceNodeHandler handler)
+ public static boolean isListNode(final ImmutableNode node,
+ final ReferenceNodeHandler handler)
{
if (hasListReference(node, handler))
{
return true;
}
- ImmutableNode parent = handler.getParent(node);
+ final ImmutableNode parent = handler.getParent(node);
if (parent != null)
{
for (int i = 0; i < handler.getChildrenCount(parent, null); i++)
{
- ImmutableNode child = handler.getChild(parent, i);
+ final ImmutableNode child = handler.getChild(parent, i);
if (hasListReference(child, handler) && nameEquals(node, child))
{
return true;
@@ -131,15 +131,15 @@ final class XMLListReference
* @param handler the reference node handler
* @return a flag whether this is the first node of a list
*/
- public static boolean isFirstListItem(ImmutableNode node,
- ReferenceNodeHandler handler)
+ public static boolean isFirstListItem(final ImmutableNode node,
+ final ReferenceNodeHandler handler)
{
- ImmutableNode parent = handler.getParent(node);
+ final ImmutableNode parent = handler.getParent(node);
ImmutableNode firstItem = null;
int idx = 0;
while (firstItem == null)
{
- ImmutableNode child = handler.getChild(parent, idx);
+ final ImmutableNode child = handler.getChild(parent, idx);
if (nameEquals(node, child))
{
firstItem = child;
@@ -163,16 +163,16 @@ final class XMLListReference
* @throws ConfigurationRuntimeException if the list delimiter handler does
* not support the transformation of list items to a string
*/
- public static String listValue(ImmutableNode node,
- ReferenceNodeHandler nodeHandler,
- ListDelimiterHandler delimiterHandler)
+ public static String listValue(final ImmutableNode node,
+ final ReferenceNodeHandler nodeHandler,
+ final ListDelimiterHandler delimiterHandler)
{
// cannot be null if the current node is a list node
- ImmutableNode parent = nodeHandler.getParent(node);
- List<ImmutableNode> items =
+ final ImmutableNode parent = nodeHandler.getParent(node);
+ final List<ImmutableNode> items =
nodeHandler.getChildren(parent, node.getNodeName());
- List<Object> values = new ArrayList<>(items.size());
- for (ImmutableNode n : items)
+ final List<Object> values = new ArrayList<>(items.size());
+ for (final ImmutableNode n : items)
{
values.add(n.getValue());
}
@@ -181,7 +181,7 @@ final class XMLListReference
return String.valueOf(delimiterHandler.escapeList(values,
ListDelimiterHandler.NOOP_TRANSFORMER));
}
- catch (UnsupportedOperationException e)
+ catch (final UnsupportedOperationException e)
{
throw new ConfigurationRuntimeException(
"List handling not supported by "
@@ -199,8 +199,8 @@ final class XMLListReference
* @param handler the reference handler
* @return a flag whether this node has a list reference
*/
- private static boolean hasListReference(ImmutableNode node,
- ReferenceNodeHandler handler)
+ private static boolean hasListReference(final ImmutableNode node,
+ final ReferenceNodeHandler handler)
{
return handler.getReference(node) instanceof XMLListReference;
}
@@ -212,7 +212,7 @@ final class XMLListReference
* @param n2 node 2
* @return a flag whether these nodes have equal names
*/
- private static boolean nameEquals(ImmutableNode n1, ImmutableNode n2)
+ private static boolean nameEquals(final ImmutableNode n1, final ImmutableNode n2)
{
return StringUtils.equals(n2.getNodeName(), n1.getNodeName());
}
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/XMLPropertiesConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/XMLPropertiesConfiguration.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/XMLPropertiesConfiguration.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/XMLPropertiesConfiguration.java Thu Sep 27 22:24:23 2018
@@ -109,7 +109,7 @@ public class XMLPropertiesConfiguration
* @throws ConfigurationException Error while loading the properties file
* @since 2.0
*/
- public XMLPropertiesConfiguration(Element element) throws ConfigurationException
+ public XMLPropertiesConfiguration(final Element element) throws ConfigurationException
{
super();
this.load(element);
@@ -130,27 +130,27 @@ public class XMLPropertiesConfiguration
*
* @param header the header comment
*/
- public void setHeader(String header)
+ public void setHeader(final String header)
{
this.header = header;
}
@Override
- public void read(Reader in) throws ConfigurationException
+ public void read(final Reader in) throws ConfigurationException
{
- SAXParserFactory factory = SAXParserFactory.newInstance();
+ final SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(false);
factory.setValidating(true);
try
{
- SAXParser parser = factory.newSAXParser();
+ final SAXParser parser = factory.newSAXParser();
- XMLReader xmlReader = parser.getXMLReader();
+ final XMLReader xmlReader = parser.getXMLReader();
xmlReader.setEntityResolver(new EntityResolver()
{
@Override
- public InputSource resolveEntity(String publicId, String systemId)
+ public InputSource resolveEntity(final String publicId, final String systemId)
{
return new InputSource(getClass().getClassLoader().getResourceAsStream("properties.dtd"));
}
@@ -158,7 +158,7 @@ public class XMLPropertiesConfiguration
xmlReader.setContentHandler(new XMLPropertiesHandler());
xmlReader.parse(new InputSource(in));
}
- catch (Exception e)
+ catch (final Exception e)
{
throw new ConfigurationException("Unable to parse the configuration file", e);
}
@@ -175,16 +175,16 @@ public class XMLPropertiesConfiguration
* @throws ConfigurationException Error while interpreting the DOM
* @since 2.0
*/
- public void load(Element element) throws ConfigurationException
+ public void load(final Element element) throws ConfigurationException
{
if (!element.getNodeName().equals("properties"))
{
throw new ConfigurationException(MALFORMED_XML_EXCEPTION);
}
- NodeList childNodes = element.getChildNodes();
+ final NodeList childNodes = element.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++)
{
- Node item = childNodes.item(i);
+ final Node item = childNodes.item(i);
if (item instanceof Element)
{
if (item.getNodeName().equals("comment"))
@@ -193,7 +193,7 @@ public class XMLPropertiesConfiguration
}
else if (item.getNodeName().equals("entry"))
{
- String key = ((Element) item).getAttribute("key");
+ final String key = ((Element) item).getAttribute("key");
addProperty(key, item.getTextContent());
}
else
@@ -205,9 +205,9 @@ public class XMLPropertiesConfiguration
}
@Override
- public void write(Writer out) throws ConfigurationException
+ public void write(final Writer out) throws ConfigurationException
{
- PrintWriter writer = new PrintWriter(out);
+ final PrintWriter writer = new PrintWriter(out);
String encoding = (locator != null) ? locator.getEncoding() : null;
if (encoding == null)
@@ -223,11 +223,11 @@ public class XMLPropertiesConfiguration
writer.println(" <comment>" + StringEscapeUtils.escapeXml10(getHeader()) + "</comment>");
}
- Iterator<String> keys = getKeys();
+ final Iterator<String> keys = getKeys();
while (keys.hasNext())
{
- String key = keys.next();
- Object value = getProperty(key);
+ final String key = keys.next();
+ final Object value = getProperty(key);
if (value instanceof List)
{
@@ -250,14 +250,14 @@ public class XMLPropertiesConfiguration
* @param key the key of the property
* @param value the value of the property
*/
- private void writeProperty(PrintWriter out, String key, Object value)
+ private void writeProperty(final PrintWriter out, final String key, final Object value)
{
// escape the key
- String k = StringEscapeUtils.escapeXml10(key);
+ final String k = StringEscapeUtils.escapeXml10(key);
if (value != null)
{
- String v = escapeValue(value);
+ final String v = escapeValue(value);
out.println(" <entry key=\"" + k + "\">" + v + "</entry>");
}
else
@@ -273,9 +273,9 @@ public class XMLPropertiesConfiguration
* @param key the key of the property
* @param values a list with all property values
*/
- private void writeProperty(PrintWriter out, String key, List<?> values)
+ private void writeProperty(final PrintWriter out, final String key, final List<?> values)
{
- for (Object value : values)
+ for (final Object value : values)
{
writeProperty(out, key, value);
}
@@ -288,22 +288,22 @@ public class XMLPropertiesConfiguration
* @param parent The DOM parent node
* @since 2.0
*/
- public void save(Document document, Node parent)
+ public void save(final Document document, final Node parent)
{
- Element properties = document.createElement("properties");
+ final Element properties = document.createElement("properties");
parent.appendChild(properties);
if (getHeader() != null)
{
- Element comment = document.createElement("comment");
+ final Element comment = document.createElement("comment");
properties.appendChild(comment);
comment.setTextContent(StringEscapeUtils.escapeXml10(getHeader()));
}
- Iterator<String> keys = getKeys();
+ final Iterator<String> keys = getKeys();
while (keys.hasNext())
{
- String key = keys.next();
- Object value = getProperty(key);
+ final String key = keys.next();
+ final Object value = getProperty(key);
if (value instanceof List)
{
@@ -323,30 +323,30 @@ public class XMLPropertiesConfiguration
* @param locator the associated {@code FileLocator}
*/
@Override
- public void initFileLocator(FileLocator locator)
+ public void initFileLocator(final FileLocator locator)
{
this.locator = locator;
}
- private void writeProperty(Document document, Node properties, String key, Object value)
+ private void writeProperty(final Document document, final Node properties, final String key, final Object value)
{
- Element entry = document.createElement("entry");
+ final Element entry = document.createElement("entry");
properties.appendChild(entry);
// escape the key
- String k = StringEscapeUtils.escapeXml10(key);
+ final String k = StringEscapeUtils.escapeXml10(key);
entry.setAttribute("key", k);
if (value != null)
{
- String v = escapeValue(value);
+ final String v = escapeValue(value);
entry.setTextContent(v);
}
}
- private void writeProperty(Document document, Node properties, String key, List<?> values)
+ private void writeProperty(final Document document, final Node properties, final String key, final List<?> values)
{
- for (Object value : values)
+ for (final Object value : values)
{
writeProperty(document, properties, key, value);
}
@@ -358,9 +358,9 @@ public class XMLPropertiesConfiguration
* @param value the value to be escaped
* @return the escaped value
*/
- private String escapeValue(Object value)
+ private String escapeValue(final Object value)
{
- String v = StringEscapeUtils.escapeXml10(String.valueOf(value));
+ final String v = StringEscapeUtils.escapeXml10(String.valueOf(value));
return String.valueOf(getListDelimiterHandler().escape(v,
ListDelimiterHandler.NOOP_TRANSFORMER));
}
@@ -386,7 +386,7 @@ public class XMLPropertiesConfiguration
private boolean inEntryElement;
@Override
- public void startElement(String uri, String localName, String qName, Attributes attrs)
+ public void startElement(final String uri, final String localName, final String qName, final Attributes attrs)
{
if ("comment".equals(qName))
{
@@ -401,7 +401,7 @@ public class XMLPropertiesConfiguration
}
@Override
- public void endElement(String uri, String localName, String qName)
+ public void endElement(final String uri, final String localName, final String qName)
{
if (inCommentElement)
{
@@ -422,7 +422,7 @@ public class XMLPropertiesConfiguration
}
@Override
- public void characters(char[] chars, int start, int length)
+ public void characters(final char[] chars, final int start, final int length)
{
/**
* We're currently processing an element. All character data from now until
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/YAMLConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/YAMLConfiguration.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/YAMLConfiguration.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/YAMLConfiguration.java Thu Sep 27 22:24:23 2018
@@ -55,53 +55,53 @@ public class YAMLConfiguration extends A
*
* @param c the configuration to be copied
*/
- public YAMLConfiguration(HierarchicalConfiguration<ImmutableNode> c)
+ public YAMLConfiguration(final HierarchicalConfiguration<ImmutableNode> c)
{
super(c);
}
@Override
- public void read(Reader in) throws ConfigurationException
+ public void read(final Reader in) throws ConfigurationException
{
try
{
- Yaml yaml = new Yaml();
- Map<String, Object> map = (Map) yaml.load(in);
+ final Yaml yaml = new Yaml();
+ final Map<String, Object> map = (Map) yaml.load(in);
load(map);
}
- catch (Exception e)
+ catch (final Exception e)
{
rethrowException(e);
}
}
- public void read(Reader in, LoaderOptions options)
+ public void read(final Reader in, final LoaderOptions options)
throws ConfigurationException
{
try
{
- Yaml yaml = new Yaml(options);
- Map<String, Object> map = (Map) yaml.load(in);
+ final Yaml yaml = new Yaml(options);
+ final Map<String, Object> map = (Map) yaml.load(in);
load(map);
}
- catch (Exception e)
+ catch (final Exception e)
{
rethrowException(e);
}
}
@Override
- public void write(Writer out) throws ConfigurationException, IOException
+ public void write(final Writer out) throws ConfigurationException, IOException
{
- DumperOptions options = new DumperOptions();
+ final DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
dump(out, options);
}
- public void dump(Writer out, DumperOptions options)
+ public void dump(final Writer out, final DumperOptions options)
throws ConfigurationException, IOException
{
- Yaml yaml = new Yaml(options);
+ final Yaml yaml = new Yaml(options);
yaml.dump(constructMap(getNodeModel().getNodeHandler().getRootNode()),
out);
}
@@ -113,30 +113,30 @@ public class YAMLConfiguration extends A
* @throws ConfigurationException if an error occurs
*/
@Override
- public void read(InputStream in) throws ConfigurationException
+ public void read(final InputStream in) throws ConfigurationException
{
try
{
- Yaml yaml = new Yaml();
- Map<String, Object> map = (Map) yaml.load(in);
+ final Yaml yaml = new Yaml();
+ final Map<String, Object> map = (Map) yaml.load(in);
load(map);
}
- catch (Exception e)
+ catch (final Exception e)
{
rethrowException(e);
}
}
- public void read(InputStream in, LoaderOptions options)
+ public void read(final InputStream in, final LoaderOptions options)
throws ConfigurationException
{
try
{
- Yaml yaml = new Yaml(options);
- Map<String, Object> map = (Map) yaml.load(in);
+ final Yaml yaml = new Yaml(options);
+ final Map<String, Object> map = (Map) yaml.load(in);
load(map);
}
- catch (Exception e)
+ catch (final Exception e)
{
rethrowException(e);
}
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/BeanHelper.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/BeanHelper.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/BeanHelper.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/BeanHelper.java Thu Sep 27 22:24:23 2018
@@ -114,7 +114,7 @@ public final class BeanHelper
* @param defFactory the default {@code BeanFactory} (can be <b>null</b>,
* then a default instance is used)
*/
- public BeanHelper(BeanFactory defFactory)
+ public BeanHelper(final BeanFactory defFactory)
{
defaultBeanFactory =
(defFactory != null) ? defFactory : DefaultBeanFactory.INSTANCE;
@@ -129,7 +129,7 @@ public final class BeanHelper
* @param name the name of the factory
* @param factory the factory to be registered
*/
- public void registerBeanFactory(String name, BeanFactory factory)
+ public void registerBeanFactory(final String name, final BeanFactory factory)
{
if (name == null)
{
@@ -152,7 +152,7 @@ public final class BeanHelper
* @return the factory that was registered under this name; <b>null</b> if
* there was no such factory
*/
- public BeanFactory deregisterBeanFactory(String name)
+ public BeanFactory deregisterBeanFactory(final String name)
{
return beanFactories.remove(name);
}
@@ -187,11 +187,11 @@ public final class BeanHelper
* @param data the bean declaration
* @throws ConfigurationRuntimeException if a property cannot be set
*/
- public void initBean(Object bean, BeanDeclaration data)
+ public void initBean(final Object bean, final BeanDeclaration data)
{
initBeanProperties(bean, data);
- Map<String, Object> nestedBeans = data.getNestedBeanDeclarations();
+ final Map<String, Object> nestedBeans = data.getNestedBeanDeclarations();
if (nestedBeans != null)
{
if (bean instanceof Collection)
@@ -199,45 +199,47 @@ public final class BeanHelper
// This is safe because the collection stores the values of the
// nested beans.
@SuppressWarnings("unchecked")
+ final
Collection<Object> coll = (Collection<Object>) bean;
if (nestedBeans.size() == 1)
{
- Map.Entry<String, Object> e = nestedBeans.entrySet().iterator().next();
- String propName = e.getKey();
- Class<?> defaultClass = getDefaultClass(bean, propName);
+ final Map.Entry<String, Object> e = nestedBeans.entrySet().iterator().next();
+ final String propName = e.getKey();
+ final Class<?> defaultClass = getDefaultClass(bean, propName);
if (e.getValue() instanceof List)
{
// This is safe, provided that the bean declaration is implemented
// correctly.
@SuppressWarnings("unchecked")
+ final
List<BeanDeclaration> decls = (List<BeanDeclaration>) e.getValue();
- for (BeanDeclaration decl : decls)
+ for (final BeanDeclaration decl : decls)
{
coll.add(createBean(decl, defaultClass));
}
}
else
{
- BeanDeclaration decl = (BeanDeclaration) e.getValue();
+ final BeanDeclaration decl = (BeanDeclaration) e.getValue();
coll.add(createBean(decl, defaultClass));
}
}
}
else
{
- for (Map.Entry<String, Object> e : nestedBeans.entrySet())
+ for (final Map.Entry<String, Object> e : nestedBeans.entrySet())
{
- String propName = e.getKey();
- Class<?> defaultClass = getDefaultClass(bean, propName);
+ final String propName = e.getKey();
+ final Class<?> defaultClass = getDefaultClass(bean, propName);
- Object prop = e.getValue();
+ final Object prop = e.getValue();
if (prop instanceof Collection)
{
- Collection<Object> beanCollection =
+ final Collection<Object> beanCollection =
createPropertyCollection(propName, defaultClass);
- for (Object elemDef : (Collection<?>) prop)
+ for (final Object elemDef : (Collection<?>) prop)
{
beanCollection
.add(createBean((BeanDeclaration) elemDef));
@@ -262,14 +264,14 @@ public final class BeanHelper
* @param data the bean declaration
* @throws ConfigurationRuntimeException if a property cannot be set
*/
- public static void initBeanProperties(Object bean, BeanDeclaration data)
+ public static void initBeanProperties(final Object bean, final BeanDeclaration data)
{
- Map<String, Object> properties = data.getBeanProperties();
+ final Map<String, Object> properties = data.getBeanProperties();
if (properties != null)
{
- for (Map.Entry<String, Object> e : properties.entrySet())
+ for (final Map.Entry<String, Object> e : properties.entrySet())
{
- String propName = e.getKey();
+ final String propName = e.getKey();
initProperty(bean, propName, e.getValue());
}
}
@@ -283,13 +285,13 @@ public final class BeanHelper
* @throws IllegalArgumentException if the bean is <b>null</b>
* @since 2.0
*/
- public static DynaBean createWrapDynaBean(Object bean)
+ public static DynaBean createWrapDynaBean(final Object bean)
{
if (bean == null)
{
throw new IllegalArgumentException("Bean must not be null!");
}
- WrapDynaClass dynaClass =
+ final WrapDynaClass dynaClass =
WrapDynaClass.createDynaClass(bean.getClass(),
BEAN_UTILS_BEAN.getPropertyUtils());
return new WrapDynaBean(bean, dynaClass);
@@ -311,7 +313,7 @@ public final class BeanHelper
* {@code PropertyUtilsBean}
* @since 2.0
*/
- public static void copyProperties(Object dest, Object orig)
+ public static void copyProperties(final Object dest, final Object orig)
throws IllegalAccessException, InvocationTargetException,
NoSuchMethodException
{
@@ -324,11 +326,11 @@ public final class BeanHelper
* @param propName The name of the property.
* @return The class associated with the property or null.
*/
- private static Class<?> getDefaultClass(Object bean, String propName)
+ private static Class<?> getDefaultClass(final Object bean, final String propName)
{
try
{
- PropertyDescriptor desc =
+ final PropertyDescriptor desc =
BEAN_UTILS_BEAN.getPropertyUtils().getPropertyDescriptor(
bean, propName);
if (desc == null)
@@ -337,7 +339,7 @@ public final class BeanHelper
}
return desc.getPropertyType();
}
- catch (Exception ex)
+ catch (final Exception ex)
{
return null;
}
@@ -352,7 +354,7 @@ public final class BeanHelper
* @throws ConfigurationRuntimeException if the property is not writeable or
* an error occurred
*/
- private static void initProperty(Object bean, String propName, Object value)
+ private static void initProperty(final Object bean, final String propName, final Object value)
{
if (!isPropertyWriteable(bean, propName))
{
@@ -364,11 +366,11 @@ public final class BeanHelper
{
BEAN_UTILS_BEAN.setProperty(bean, propName, value);
}
- catch (IllegalAccessException iaex)
+ catch (final IllegalAccessException iaex)
{
throw new ConfigurationRuntimeException(iaex);
}
- catch (InvocationTargetException itex)
+ catch (final InvocationTargetException itex)
{
throw new ConfigurationRuntimeException(itex);
}
@@ -384,8 +386,8 @@ public final class BeanHelper
* @param propertyClass the type of the property
* @return the newly created collection
*/
- private static Collection<Object> createPropertyCollection(String propName,
- Class<?> propertyClass)
+ private static Collection<Object> createPropertyCollection(final String propName,
+ final Class<?> propertyClass)
{
Collection<Object> beanCollection;
@@ -416,7 +418,7 @@ public final class BeanHelper
* @throws ConfigurationRuntimeException if the property is not writeable or
* an error occurred
*/
- public static void setProperty(Object bean, String propName, Object value)
+ public static void setProperty(final Object bean, final String propName, final Object value)
{
if (isPropertyWriteable(bean, propName))
{
@@ -442,8 +444,8 @@ public final class BeanHelper
* @return the new bean
* @throws ConfigurationRuntimeException if an error occurs
*/
- public Object createBean(BeanDeclaration data, Class<?> defaultClass,
- Object param)
+ public Object createBean(final BeanDeclaration data, final Class<?> defaultClass,
+ final Object param)
{
if (data == null)
{
@@ -451,14 +453,14 @@ public final class BeanHelper
"Bean declaration must not be null!");
}
- BeanFactory factory = fetchBeanFactory(data);
- BeanCreationContext bcc =
+ final BeanFactory factory = fetchBeanFactory(data);
+ final BeanCreationContext bcc =
createBeanCreationContext(data, defaultClass, param, factory);
try
{
return factory.createBean(bcc);
}
- catch (Exception ex)
+ catch (final Exception ex)
{
throw new ConfigurationRuntimeException(ex);
}
@@ -474,7 +476,7 @@ public final class BeanHelper
* @return the new bean
* @throws ConfigurationRuntimeException if an error occurs
*/
- public Object createBean(BeanDeclaration data, Class<?> defaultClass)
+ public Object createBean(final BeanDeclaration data, final Class<?> defaultClass)
{
return createBean(data, defaultClass, null);
}
@@ -487,7 +489,7 @@ public final class BeanHelper
* @return the new bean
* @throws ConfigurationRuntimeException if an error occurs
*/
- public Object createBean(BeanDeclaration data)
+ public Object createBean(final BeanDeclaration data)
{
return createBean(data, null);
}
@@ -502,7 +504,7 @@ public final class BeanHelper
* @return the class object for the specified name
* @throws ClassNotFoundException if the class cannot be loaded
*/
- static Class<?> loadClass(String name) throws ClassNotFoundException
+ static Class<?> loadClass(final String name) throws ClassNotFoundException
{
return ClassUtils.getClass(name);
}
@@ -516,7 +518,7 @@ public final class BeanHelper
* @return <b>true</b> if this property can be written, <b>false</b>
* otherwise
*/
- private static boolean isPropertyWriteable(Object bean, String propName)
+ private static boolean isPropertyWriteable(final Object bean, final String propName)
{
return BEAN_UTILS_BEAN.getPropertyUtils().isWriteable(bean, propName);
}
@@ -534,17 +536,17 @@ public final class BeanHelper
* @return the class of the bean to be created
* @throws ConfigurationRuntimeException if the class cannot be determined
*/
- private static Class<?> fetchBeanClass(BeanDeclaration data,
- Class<?> defaultClass, BeanFactory factory)
+ private static Class<?> fetchBeanClass(final BeanDeclaration data,
+ final Class<?> defaultClass, final BeanFactory factory)
{
- String clsName = data.getBeanClassName();
+ final String clsName = data.getBeanClassName();
if (clsName != null)
{
try
{
return loadClass(clsName);
}
- catch (ClassNotFoundException cex)
+ catch (final ClassNotFoundException cex)
{
throw new ConfigurationRuntimeException(cex);
}
@@ -555,7 +557,7 @@ public final class BeanHelper
return defaultClass;
}
- Class<?> clazz = factory.getDefaultBeanClass();
+ final Class<?> clazz = factory.getDefaultBeanClass();
if (clazz == null)
{
throw new ConfigurationRuntimeException(
@@ -573,12 +575,12 @@ public final class BeanHelper
* @return the bean factory to use
* @throws ConfigurationRuntimeException if the factory cannot be determined
*/
- private BeanFactory fetchBeanFactory(BeanDeclaration data)
+ private BeanFactory fetchBeanFactory(final BeanDeclaration data)
{
- String factoryName = data.getBeanFactoryName();
+ final String factoryName = data.getBeanFactoryName();
if (factoryName != null)
{
- BeanFactory factory = beanFactories.get(factoryName);
+ final BeanFactory factory = beanFactories.get(factoryName);
if (factory == null)
{
throw new ConfigurationRuntimeException(
@@ -604,8 +606,8 @@ public final class BeanHelper
* determined
*/
private BeanCreationContext createBeanCreationContext(
- final BeanDeclaration data, Class<?> defaultClass,
- final Object param, BeanFactory factory)
+ final BeanDeclaration data, final Class<?> defaultClass,
+ final Object param, final BeanFactory factory)
{
final Class<?> beanClass = fetchBeanClass(data, defaultClass, factory);
return new BeanCreationContextImpl(this, beanClass, data, param);
@@ -621,7 +623,7 @@ public final class BeanHelper
*/
private static BeanUtilsBean initBeanUtilsBean()
{
- PropertyUtilsBean propUtilsBean = new PropertyUtilsBean();
+ final PropertyUtilsBean propUtilsBean = new PropertyUtilsBean();
propUtilsBean.addBeanIntrospector(new FluentPropertyBeanIntrospector());
return new BeanUtilsBean(new ConvertUtilsBean(), propUtilsBean);
}
@@ -648,8 +650,8 @@ public final class BeanHelper
/** The parameter for the bean factory. */
private final Object param;
- private BeanCreationContextImpl(BeanHelper helper, Class<?> beanClass,
- BeanDeclaration data, Object param)
+ private BeanCreationContextImpl(final BeanHelper helper, final Class<?> beanClass,
+ final BeanDeclaration data, final Object param)
{
beanHelper = helper;
this.beanClass = beanClass;
@@ -658,7 +660,7 @@ public final class BeanHelper
}
@Override
- public void initBean(Object bean, BeanDeclaration data)
+ public void initBean(final Object bean, final BeanDeclaration data)
{
beanHelper.initBean(bean, data);
}
@@ -682,7 +684,7 @@ public final class BeanHelper
}
@Override
- public Object createBean(BeanDeclaration data)
+ public Object createBean(final BeanDeclaration data)
{
return beanHelper.createBean(data);
}
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/CombinedBeanDeclaration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/CombinedBeanDeclaration.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/CombinedBeanDeclaration.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/CombinedBeanDeclaration.java Thu Sep 27 22:24:23 2018
@@ -61,7 +61,7 @@ public class CombinedBeanDeclaration imp
* @throws NullPointerException if the array with child declarations is
* <b>null</b>
*/
- public CombinedBeanDeclaration(BeanDeclaration... decl)
+ public CombinedBeanDeclaration(final BeanDeclaration... decl)
{
childDeclarations = new ArrayList<>(Arrays.asList(decl));
}
@@ -75,9 +75,9 @@ public class CombinedBeanDeclaration imp
@Override
public String getBeanFactoryName()
{
- for (BeanDeclaration d : childDeclarations)
+ for (final BeanDeclaration d : childDeclarations)
{
- String factoryName = d.getBeanFactoryName();
+ final String factoryName = d.getBeanFactoryName();
if (factoryName != null)
{
return factoryName;
@@ -95,9 +95,9 @@ public class CombinedBeanDeclaration imp
@Override
public Object getBeanFactoryParameter()
{
- for (BeanDeclaration d : childDeclarations)
+ for (final BeanDeclaration d : childDeclarations)
{
- Object factoryParam = d.getBeanFactoryParameter();
+ final Object factoryParam = d.getBeanFactoryParameter();
if (factoryParam != null)
{
return factoryParam;
@@ -115,9 +115,9 @@ public class CombinedBeanDeclaration imp
@Override
public String getBeanClassName()
{
- for (BeanDeclaration d : childDeclarations)
+ for (final BeanDeclaration d : childDeclarations)
{
- String beanClassName = d.getBeanClassName();
+ final String beanClassName = d.getBeanClassName();
if (beanClassName != null)
{
return beanClassName;
@@ -135,10 +135,10 @@ public class CombinedBeanDeclaration imp
@Override
public Map<String, Object> getBeanProperties()
{
- Map<String, Object> result = new HashMap<>();
+ final Map<String, Object> result = new HashMap<>();
for (int i = childDeclarations.size() - 1; i >= 0; i--)
{
- Map<String, Object> props =
+ final Map<String, Object> props =
childDeclarations.get(i).getBeanProperties();
if (props != null)
{
@@ -157,10 +157,10 @@ public class CombinedBeanDeclaration imp
@Override
public Map<String, Object> getNestedBeanDeclarations()
{
- Map<String, Object> result = new HashMap<>();
+ final Map<String, Object> result = new HashMap<>();
for (int i = childDeclarations.size() - 1; i >= 0; i--)
{
- Map<String, Object> decls =
+ final Map<String, Object> decls =
childDeclarations.get(i).getNestedBeanDeclarations();
if (decls != null)
{
@@ -180,9 +180,9 @@ public class CombinedBeanDeclaration imp
@Override
public Collection<ConstructorArg> getConstructorArgs()
{
- for (BeanDeclaration d : childDeclarations)
+ for (final BeanDeclaration d : childDeclarations)
{
- Collection<ConstructorArg> args = d.getConstructorArgs();
+ final Collection<ConstructorArg> args = d.getConstructorArgs();
if (args != null && !args.isEmpty())
{
return args;
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/ConfigurationDynaBean.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/ConfigurationDynaBean.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/ConfigurationDynaBean.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/ConfigurationDynaBean.java Thu Sep 27 22:24:23 2018
@@ -67,7 +67,7 @@ public class ConfigurationDynaBean exten
*
* @param configuration the configuration
*/
- public ConfigurationDynaBean(Configuration configuration)
+ public ConfigurationDynaBean(final Configuration configuration)
{
super(configuration);
if (LOG.isTraceEnabled())
@@ -77,7 +77,7 @@ public class ConfigurationDynaBean exten
}
@Override
- public void set(String name, Object value)
+ public void set(final String name, final Object value)
{
if (LOG.isTraceEnabled())
{
@@ -91,15 +91,15 @@ public class ConfigurationDynaBean exten
if (value instanceof Collection)
{
- Collection<?> collection = (Collection<?>) value;
- for (Object v : collection)
+ final Collection<?> collection = (Collection<?>) value;
+ for (final Object v : collection)
{
getConfiguration().addProperty(name, v);
}
}
else if (value.getClass().isArray())
{
- int length = Array.getLength(value);
+ final int length = Array.getLength(value);
for (int i = 0; i < length; i++)
{
getConfiguration().addProperty(name, Array.get(value, i));
@@ -112,7 +112,7 @@ public class ConfigurationDynaBean exten
}
@Override
- public Object get(String name)
+ public Object get(final String name)
{
if (LOG.isTraceEnabled())
{
@@ -124,7 +124,7 @@ public class ConfigurationDynaBean exten
if (result == null)
{
// otherwise attempt to create bean from configuration subset
- Configuration subset = new SubsetConfiguration(getConfiguration(), name, PROPERTY_DELIMITER);
+ final Configuration subset = new SubsetConfiguration(getConfiguration(), name, PROPERTY_DELIMITER);
if (!subset.isEmpty())
{
result = new ConfigurationDynaBean(subset);
@@ -144,9 +144,9 @@ public class ConfigurationDynaBean exten
}
@Override
- public boolean contains(String name, String key)
+ public boolean contains(final String name, final String key)
{
- Configuration subset = getConfiguration().subset(name);
+ final Configuration subset = getConfiguration().subset(name);
if (subset == null)
{
throw new IllegalArgumentException("Mapped property '" + name + "' does not exist.");
@@ -156,7 +156,7 @@ public class ConfigurationDynaBean exten
}
@Override
- public Object get(String name, int index)
+ public Object get(final String name, final int index)
{
if (!checkIndexedProperty(name))
{
@@ -164,14 +164,14 @@ public class ConfigurationDynaBean exten
+ "' is not indexed.");
}
- List<Object> list = getConfiguration().getList(name);
+ final List<Object> list = getConfiguration().getList(name);
return list.get(index);
}
@Override
- public Object get(String name, String key)
+ public Object get(final String name, final String key)
{
- Configuration subset = getConfiguration().subset(name);
+ final Configuration subset = getConfiguration().subset(name);
if (subset == null)
{
throw new IllegalArgumentException("Mapped property '" + name + "' does not exist.");
@@ -187,14 +187,14 @@ public class ConfigurationDynaBean exten
}
@Override
- public void remove(String name, String key)
+ public void remove(final String name, final String key)
{
- Configuration subset = new SubsetConfiguration(getConfiguration(), name, PROPERTY_DELIMITER);
+ final Configuration subset = new SubsetConfiguration(getConfiguration(), name, PROPERTY_DELIMITER);
subset.setProperty(key, null);
}
@Override
- public void set(String name, int index, Object value)
+ public void set(final String name, final int index, final Object value)
{
if (!checkIndexedProperty(name) && index > 0)
{
@@ -202,13 +202,14 @@ public class ConfigurationDynaBean exten
+ "' is not indexed.");
}
- Object property = getConfiguration().getProperty(name);
+ final Object property = getConfiguration().getProperty(name);
if (property instanceof List)
{
// This is safe because multiple values of a configuration property
// are always stored as lists of type Object.
@SuppressWarnings("unchecked")
+ final
List<Object> list = (List<Object>) property;
list.set(index, value);
getConfiguration().setProperty(name, list);
@@ -224,7 +225,7 @@ public class ConfigurationDynaBean exten
}
@Override
- public void set(String name, String key, Object value)
+ public void set(final String name, final String key, final Object value)
{
getConfiguration().setProperty(name + "." + key, value);
}
@@ -238,9 +239,9 @@ public class ConfigurationDynaBean exten
* @return a flag whether this is an indexed property
* @throws IllegalArgumentException if the property does not exist
*/
- private boolean checkIndexedProperty(String name)
+ private boolean checkIndexedProperty(final String name)
{
- Object property = getConfiguration().getProperty(name);
+ final Object property = getConfiguration().getProperty(name);
if (property == null)
{
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/ConfigurationDynaClass.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/ConfigurationDynaClass.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/ConfigurationDynaClass.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/ConfigurationDynaClass.java Thu Sep 27 22:24:23 2018
@@ -50,7 +50,7 @@ public class ConfigurationDynaClass impl
* wrapping the specified {@code Configuration} instance.
* @param configuration {@code Configuration} instance.
*/
- public ConfigurationDynaClass(Configuration configuration)
+ public ConfigurationDynaClass(final Configuration configuration)
{
super();
if (LOG.isTraceEnabled())
@@ -61,7 +61,7 @@ public class ConfigurationDynaClass impl
}
@Override
- public DynaProperty getDynaProperty(String name)
+ public DynaProperty getDynaProperty(final String name)
{
if (LOG.isTraceEnabled())
{
@@ -73,7 +73,7 @@ public class ConfigurationDynaClass impl
throw new IllegalArgumentException("Property name must not be null!");
}
- Object value = configuration.getProperty(name);
+ final Object value = configuration.getProperty(name);
if (value == null)
{
return null;
@@ -124,16 +124,16 @@ public class ConfigurationDynaClass impl
LOG.trace("getDynaProperties()");
}
- Iterator<String> keys = configuration.getKeys();
- List<DynaProperty> properties = new ArrayList<>();
+ final Iterator<String> keys = configuration.getKeys();
+ final List<DynaProperty> properties = new ArrayList<>();
while (keys.hasNext())
{
- String key = keys.next();
- DynaProperty property = getDynaProperty(key);
+ final String key = keys.next();
+ final DynaProperty property = getDynaProperty(key);
properties.add(property);
}
- DynaProperty[] propertyArray = new DynaProperty[properties.size()];
+ final DynaProperty[] propertyArray = new DynaProperty[properties.size()];
properties.toArray(propertyArray);
if (LOG.isDebugEnabled())
{
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/ConstructorArg.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/ConstructorArg.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/ConstructorArg.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/ConstructorArg.java Thu Sep 27 22:24:23 2018
@@ -54,7 +54,7 @@ public final class ConstructorArg
* @param val the value of the argument
* @param type the type name
*/
- private ConstructorArg(BeanDeclaration decl, Object val, String type)
+ private ConstructorArg(final BeanDeclaration decl, final Object val, final String type)
{
beanDeclaration = decl;
value = val;
@@ -71,7 +71,7 @@ public final class ConstructorArg
* @throws NullPointerException if the {@code BeanDeclaration} is
* <b>null</b>
*/
- public static ConstructorArg forBeanDeclaration(BeanDeclaration decl)
+ public static ConstructorArg forBeanDeclaration(final BeanDeclaration decl)
{
return forBeanDeclaration(decl, null);
}
@@ -88,8 +88,8 @@ public final class ConstructorArg
* @throws NullPointerException if the {@code BeanDeclaration} is
* <b>null</b>
*/
- public static ConstructorArg forBeanDeclaration(BeanDeclaration decl,
- String typeName)
+ public static ConstructorArg forBeanDeclaration(final BeanDeclaration decl,
+ final String typeName)
{
if (decl == null)
{
@@ -105,7 +105,7 @@ public final class ConstructorArg
* @param value the value of this constructor argument (may be <b>null</b>)
* @return the newly created instance of this class
*/
- public static ConstructorArg forValue(Object value)
+ public static ConstructorArg forValue(final Object value)
{
return forValue(value, null);
}
@@ -120,7 +120,7 @@ public final class ConstructorArg
* @param typeName the name of the data type of this argument
* @return the newly created instance of this class
*/
- public static ConstructorArg forValue(Object value, String typeName)
+ public static ConstructorArg forValue(final Object value, final String typeName)
{
return new ConstructorArg(null, value, typeName);
}
@@ -196,7 +196,7 @@ public final class ConstructorArg
* @return <b>true</b> if this constructor argument is compatible with this
* class, <b>false</b> otherwise
*/
- public boolean matches(Class<?> argCls)
+ public boolean matches(final Class<?> argCls)
{
if (argCls == null)
{
@@ -215,7 +215,7 @@ public final class ConstructorArg
@Override
public String toString()
{
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
buf.append(getClass().getSimpleName());
buf.append(" [ value = ");
buf.append(isNestedBeanDeclaration() ? getBeanDeclaration()
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/DefaultBeanFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/DefaultBeanFactory.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/DefaultBeanFactory.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/DefaultBeanFactory.java Thu Sep 27 22:24:23 2018
@@ -80,7 +80,7 @@ public class DefaultBeanFactory implemen
* then a default handler is used
* @since 2.0
*/
- public DefaultBeanFactory(ConversionHandler convHandler)
+ public DefaultBeanFactory(final ConversionHandler convHandler)
{
conversionHandler =
(convHandler != null) ? convHandler
@@ -110,9 +110,9 @@ public class DefaultBeanFactory implemen
* @throws Exception if an error occurs
*/
@Override
- public Object createBean(BeanCreationContext bcc) throws Exception
+ public Object createBean(final BeanCreationContext bcc) throws Exception
{
- Object result = createBeanInstance(bcc);
+ final Object result = createBeanInstance(bcc);
initBeanInstance(result, bcc);
return result;
}
@@ -138,13 +138,13 @@ public class DefaultBeanFactory implemen
* @return the new bean instance
* @throws Exception if an error occurs
*/
- protected Object createBeanInstance(BeanCreationContext bcc)
+ protected Object createBeanInstance(final BeanCreationContext bcc)
throws Exception
{
- Constructor<?> ctor =
+ final Constructor<?> ctor =
findMatchingConstructor(bcc.getBeanClass(),
bcc.getBeanDeclaration());
- Object[] args = fetchConstructorArgs(ctor, bcc);
+ final Object[] args = fetchConstructorArgs(ctor, bcc);
return ctor.newInstance(args);
}
@@ -157,7 +157,7 @@ public class DefaultBeanFactory implemen
* @param bcc the context object defining the bean to be created
* @throws Exception if an error occurs
*/
- protected void initBeanInstance(Object bean, BeanCreationContext bcc) throws Exception
+ protected void initBeanInstance(final Object bean, final BeanCreationContext bcc) throws Exception
{
bcc.initBean(bean, bcc.getBeanDeclaration());
}
@@ -178,9 +178,9 @@ public class DefaultBeanFactory implemen
* <b>null</b>
*/
protected static <T> Constructor<T> findMatchingConstructor(
- Class<T> beanClass, BeanDeclaration data)
+ final Class<T> beanClass, final BeanDeclaration data)
{
- List<Constructor<T>> matchingConstructors =
+ final List<Constructor<T>> matchingConstructors =
findMatchingConstructors(beanClass, data);
checkSingleMatchingConstructor(beanClass, data, matchingConstructors);
return matchingConstructors.get(0);
@@ -195,18 +195,18 @@ public class DefaultBeanFactory implemen
* @param bcc the context object defining the bean to be created
* @return an array with constructor arguments
*/
- private Object[] fetchConstructorArgs(Constructor<?> ctor,
- BeanCreationContext bcc)
+ private Object[] fetchConstructorArgs(final Constructor<?> ctor,
+ final BeanCreationContext bcc)
{
- Class<?>[] types = ctor.getParameterTypes();
+ final Class<?>[] types = ctor.getParameterTypes();
assert types.length == nullSafeConstructorArgs(bcc.getBeanDeclaration()).size()
: "Wrong number of constructor arguments!";
- Object[] args = new Object[types.length];
+ final Object[] args = new Object[types.length];
int idx = 0;
- for (ConstructorArg arg : nullSafeConstructorArgs(bcc.getBeanDeclaration()))
+ for (final ConstructorArg arg : nullSafeConstructorArgs(bcc.getBeanDeclaration()))
{
- Object val =
+ final Object val =
arg.isNestedBeanDeclaration() ? bcc.createBean(arg
.getBeanDeclaration()) : arg.getValue();
args[idx] = getConversionHandler().to(val, types[idx], null);
@@ -224,7 +224,7 @@ public class DefaultBeanFactory implemen
* @return the collection with constructor arguments (never <b>null</b>)
*/
private static Collection<ConstructorArg> nullSafeConstructorArgs(
- BeanDeclaration data)
+ final BeanDeclaration data)
{
Collection<ConstructorArg> args = data.getConstructorArgs();
if (args == null)
@@ -243,17 +243,18 @@ public class DefaultBeanFactory implemen
* @return a list with all matching constructors
*/
private static <T> List<Constructor<T>> findMatchingConstructors(
- Class<T> beanClass, BeanDeclaration data)
+ final Class<T> beanClass, final BeanDeclaration data)
{
- List<Constructor<T>> result = new LinkedList<>();
- Collection<ConstructorArg> args = getConstructorArgs(data);
- for (Constructor<?> ctor : beanClass.getConstructors())
+ final List<Constructor<T>> result = new LinkedList<>();
+ final Collection<ConstructorArg> args = getConstructorArgs(data);
+ for (final Constructor<?> ctor : beanClass.getConstructors())
{
if (matchesConstructor(ctor, args))
{
// cast should be okay according to the Javadocs of
// getConstructors()
@SuppressWarnings("unchecked")
+ final
Constructor<T> match = (Constructor<T>) ctor;
result.add(match);
}
@@ -270,17 +271,17 @@ public class DefaultBeanFactory implemen
* @return a flag whether this constructor is compatible with the given
* arguments
*/
- private static boolean matchesConstructor(Constructor<?> ctor,
- Collection<ConstructorArg> args)
+ private static boolean matchesConstructor(final Constructor<?> ctor,
+ final Collection<ConstructorArg> args)
{
- Class<?>[] types = ctor.getParameterTypes();
+ final Class<?>[] types = ctor.getParameterTypes();
if (types.length != args.size())
{
return false;
}
int idx = 0;
- for (ConstructorArg arg : args)
+ for (final ConstructorArg arg : args)
{
if (!arg.matches(types[idx++]))
{
@@ -299,7 +300,7 @@ public class DefaultBeanFactory implemen
* @return the collection with constructor arguments (never <b>null</b>)
*/
private static Collection<ConstructorArg> getConstructorArgs(
- BeanDeclaration data)
+ final BeanDeclaration data)
{
Collection<ConstructorArg> args = data.getConstructorArgs();
if (args == null)
@@ -319,8 +320,8 @@ public class DefaultBeanFactory implemen
* @param matchingConstructors the list with matching constructors
* @throws ConfigurationRuntimeException if there is not exactly one match
*/
- private static <T> void checkSingleMatchingConstructor(Class<T> beanClass,
- BeanDeclaration data, List<Constructor<T>> matchingConstructors)
+ private static <T> void checkSingleMatchingConstructor(final Class<T> beanClass,
+ final BeanDeclaration data, final List<Constructor<T>> matchingConstructors)
{
if (matchingConstructors.isEmpty())
{
@@ -344,7 +345,7 @@ public class DefaultBeanFactory implemen
* @return the exception with the error message
*/
private static ConfigurationRuntimeException constructorMatchingException(
- Class<?> beanClass, BeanDeclaration data, String msg)
+ final Class<?> beanClass, final BeanDeclaration data, final String msg)
{
return new ConfigurationRuntimeException(FMT_CTOR_ERROR,
msg, beanClass.getName(), getConstructorArgs(data).toString());
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/XMLBeanDeclaration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/XMLBeanDeclaration.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/XMLBeanDeclaration.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/beanutils/XMLBeanDeclaration.java Thu Sep 27 22:24:23 2018
@@ -170,7 +170,7 @@ public class XMLBeanDeclaration implemen
* @throws IllegalArgumentException if required information is missing to
* construct the bean declaration
*/
- public <T> XMLBeanDeclaration(HierarchicalConfiguration<T> config, String key)
+ public <T> XMLBeanDeclaration(final HierarchicalConfiguration<T> config, final String key)
{
this(config, key, false);
}
@@ -188,8 +188,8 @@ public class XMLBeanDeclaration implemen
* @throws IllegalArgumentException if required information is missing to
* construct the bean declaration
*/
- public <T> XMLBeanDeclaration(HierarchicalConfiguration<T> config, String key,
- boolean optional)
+ public <T> XMLBeanDeclaration(final HierarchicalConfiguration<T> config, final String key,
+ final boolean optional)
{
this(config, key, optional, null);
}
@@ -218,8 +218,8 @@ public class XMLBeanDeclaration implemen
* construct the bean declaration
* @since 2.0
*/
- public <T> XMLBeanDeclaration(HierarchicalConfiguration<T> config, String key,
- boolean optional, String defBeanClsName)
+ public <T> XMLBeanDeclaration(final HierarchicalConfiguration<T> config, final String key,
+ final boolean optional, final String defBeanClsName)
{
if (config == null)
{
@@ -232,7 +232,7 @@ public class XMLBeanDeclaration implemen
{
tmpconfiguration = config.configurationAt(key);
}
- catch (ConfigurationRuntimeException iex)
+ catch (final ConfigurationRuntimeException iex)
{
// If we reach this block, the key does not have exactly one value
if (!optional || config.getMaxIndex(key) > 0)
@@ -255,7 +255,7 @@ public class XMLBeanDeclaration implemen
* @param config the configuration with the bean declaration
* @param <T> the node type of the configuration
*/
- public <T> XMLBeanDeclaration(HierarchicalConfiguration<T> config)
+ public <T> XMLBeanDeclaration(final HierarchicalConfiguration<T> config)
{
this(config, (String) null);
}
@@ -268,8 +268,8 @@ public class XMLBeanDeclaration implemen
* @param config the configuration
* @param node the node with the bean declaration.
*/
- XMLBeanDeclaration(HierarchicalConfiguration<?> config,
- NodeData<?> node)
+ XMLBeanDeclaration(final HierarchicalConfiguration<?> config,
+ final NodeData<?> node)
{
this.node = node;
configuration = config;
@@ -345,8 +345,8 @@ public class XMLBeanDeclaration implemen
@Override
public Map<String, Object> getBeanProperties()
{
- Map<String, Object> props = new HashMap<>();
- for (String key : getAttributeNames())
+ final Map<String, Object> props = new HashMap<>();
+ for (final String key : getAttributeNames())
{
if (!isReservedAttributeName(key))
{
@@ -367,19 +367,20 @@ public class XMLBeanDeclaration implemen
@Override
public Map<String, Object> getNestedBeanDeclarations()
{
- Map<String, Object> nested = new HashMap<>();
- for (NodeData<?> child : getNode().getChildren())
+ final Map<String, Object> nested = new HashMap<>();
+ for (final NodeData<?> child : getNode().getChildren())
{
if (!isReservedChildName(child.nodeName()))
{
if (nested.containsKey(child.nodeName()))
{
- Object obj = nested.get(child.nodeName());
+ final Object obj = nested.get(child.nodeName());
List<BeanDeclaration> list;
if (obj instanceof List)
{
// Safe because we created the lists ourselves.
@SuppressWarnings("unchecked")
+ final
List<BeanDeclaration> tmpList = (List<BeanDeclaration>) obj;
list = tmpList;
}
@@ -411,8 +412,8 @@ public class XMLBeanDeclaration implemen
@Override
public Collection<ConstructorArg> getConstructorArgs()
{
- Collection<ConstructorArg> args = new LinkedList<>();
- for (NodeData<?> child : getNode().getChildren(ELEM_CTOR_ARG))
+ final Collection<ConstructorArg> args = new LinkedList<>();
+ for (final NodeData<?> child : getNode().getChildren(ELEM_CTOR_ARG))
{
args.add(createConstructorArg(child));
}
@@ -428,9 +429,9 @@ public class XMLBeanDeclaration implemen
* @param value the value that is to be interpolated
* @return the interpolated value
*/
- protected Object interpolate(Object value)
+ protected Object interpolate(final Object value)
{
- ConfigurationInterpolator interpolator =
+ final ConfigurationInterpolator interpolator =
getConfiguration().getInterpolator();
return interpolator != null ? interpolator.interpolate(value) : value;
}
@@ -446,7 +447,7 @@ public class XMLBeanDeclaration implemen
* @return a flag whether this name is reserved
* @since 2.0
*/
- protected boolean isReservedChildName(String name)
+ protected boolean isReservedChildName(final String name)
{
return isReservedName(name);
}
@@ -462,7 +463,7 @@ public class XMLBeanDeclaration implemen
* @return a flag whether this name is reserved
* @since 2.0
*/
- protected boolean isReservedAttributeName(String name)
+ protected boolean isReservedAttributeName(final String name)
{
return isReservedName(name);
}
@@ -476,7 +477,7 @@ public class XMLBeanDeclaration implemen
* @param name the name to be checked
* @return a flag whether this name is reserved
*/
- protected boolean isReservedName(String name)
+ protected boolean isReservedName(final String name)
{
return name == null || name.startsWith(RESERVED_PREFIX);
}
@@ -515,9 +516,9 @@ public class XMLBeanDeclaration implemen
* to be created
* @return the {@code BeanDeclaration} for this child node
*/
- BeanDeclaration createBeanDeclaration(NodeData<?> node)
+ BeanDeclaration createBeanDeclaration(final NodeData<?> node)
{
- for (HierarchicalConfiguration<?> config : getConfiguration()
+ for (final HierarchicalConfiguration<?> config : getConfiguration()
.configurationsAt(node.escapedNodeName(getConfiguration())))
{
if (node.matchesConfigRootNode(config))
@@ -535,7 +536,7 @@ public class XMLBeanDeclaration implemen
*
* @param conf the configuration to initialize
*/
- private void initSubnodeConfiguration(HierarchicalConfiguration<?> conf)
+ private void initSubnodeConfiguration(final HierarchicalConfiguration<?> conf)
{
conf.setExpressionEngine(null);
}
@@ -547,9 +548,9 @@ public class XMLBeanDeclaration implemen
* @param child the configuration node
* @return the corresponding {@code ConstructorArg} object
*/
- private ConstructorArg createConstructorArg(NodeData<?> child)
+ private ConstructorArg createConstructorArg(final NodeData<?> child)
{
- String type = getAttribute(child, ATTR_CTOR_TYPE);
+ final String type = getAttribute(child, ATTR_CTOR_TYPE);
if (isBeanDeclarationArgument(child))
{
return ConstructorArg.forValue(
@@ -567,9 +568,9 @@ public class XMLBeanDeclaration implemen
* @param attr the name of the attribute
* @return the string value of this attribute (can be <b>null</b>)
*/
- private String getAttribute(NodeData<?> nd, String attr)
+ private String getAttribute(final NodeData<?> nd, final String attr)
{
- Object value = nd.getAttribute(attr);
+ final Object value = nd.getAttribute(attr);
return (value == null) ? null : String.valueOf(interpolate(value));
}
@@ -580,7 +581,7 @@ public class XMLBeanDeclaration implemen
* @param nd the configuration node in question
* @return a flag whether this constructor argument is a bean declaration
*/
- private static boolean isBeanDeclarationArgument(NodeData<?> nd)
+ private static boolean isBeanDeclarationArgument(final NodeData<?> nd)
{
return !nd.getAttributes().contains(ATTR_BEAN_CLASS_NAME);
}
@@ -594,9 +595,9 @@ public class XMLBeanDeclaration implemen
* @return the {@code NodeData} object
*/
private static <T> NodeData<T> createNodeDataFromConfiguration(
- HierarchicalConfiguration<T> config)
+ final HierarchicalConfiguration<T> config)
{
- NodeHandler<T> handler = config.getNodeModel().getNodeHandler();
+ final NodeHandler<T> handler = config.getNodeModel().getNodeHandler();
return new NodeData<>(handler.getRootNode(), handler);
}
@@ -620,7 +621,7 @@ public class XMLBeanDeclaration implemen
* @param nd the node
* @param hndlr the handler
*/
- public NodeData(T nd, NodeHandler<T> hndlr)
+ public NodeData(final T nd, final NodeHandler<T> hndlr)
{
node = nd;
handler = hndlr;
@@ -645,7 +646,7 @@ public class XMLBeanDeclaration implemen
* @param config the configuration
* @return the escaped node name
*/
- public String escapedNodeName(HierarchicalConfiguration<?> config)
+ public String escapedNodeName(final HierarchicalConfiguration<?> config)
{
return config.getExpressionEngine().nodeKey(node,
StringUtils.EMPTY, handler);
@@ -669,7 +670,7 @@ public class XMLBeanDeclaration implemen
* @param name the name of the desired child nodes
* @return a list with the children with this name
*/
- public List<NodeData<T>> getChildren(String name)
+ public List<NodeData<T>> getChildren(final String name)
{
return wrapInNodeData(handler.getChildren(node, name));
}
@@ -691,7 +692,7 @@ public class XMLBeanDeclaration implemen
* @param key the key of the attribute
* @return the value of this attribute
*/
- public Object getAttribute(String key)
+ public Object getAttribute(final String key)
{
return handler.getAttributeValue(node, key);
}
@@ -703,7 +704,7 @@ public class XMLBeanDeclaration implemen
* @param config the configuration
* @return a flag whether this node is the configuration's root node
*/
- public boolean matchesConfigRootNode(HierarchicalConfiguration<?> config)
+ public boolean matchesConfigRootNode(final HierarchicalConfiguration<?> config)
{
return config.getNodeModel().getNodeHandler().getRootNode()
.equals(node);
@@ -715,10 +716,10 @@ public class XMLBeanDeclaration implemen
* @param nodes the list with nodes
* @return the wrapped nodes
*/
- private List<NodeData<T>> wrapInNodeData(List<T> nodes)
+ private List<NodeData<T>> wrapInNodeData(final List<T> nodes)
{
- List<NodeData<T>> result = new ArrayList<>(nodes.size());
- for (T node : nodes)
+ final List<NodeData<T>> result = new ArrayList<>(nodes.size());
+ for (final T node : nodes)
{
result.add(new NodeData<>(node, handler));
}
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/builder/AutoSaveListener.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/builder/AutoSaveListener.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/builder/AutoSaveListener.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/builder/AutoSaveListener.java Thu Sep 27 22:24:23 2018
@@ -69,7 +69,7 @@ class AutoSaveListener extends FileHandl
*
* @param bldr the associated builder
*/
- public AutoSaveListener(FileBasedConfigurationBuilder<?> bldr)
+ public AutoSaveListener(final FileBasedConfigurationBuilder<?> bldr)
{
builder = bldr;
}
@@ -81,7 +81,7 @@ class AutoSaveListener extends FileHandl
* operation is in progress.
*/
@Override
- public void onEvent(ConfigurationEvent event)
+ public void onEvent(final ConfigurationEvent event)
{
if (autoSaveRequired(event))
{
@@ -89,7 +89,7 @@ class AutoSaveListener extends FileHandl
{
builder.save();
}
- catch (ConfigurationException ce)
+ catch (final ConfigurationException ce)
{
log.warn("Auto save failed!", ce);
}
@@ -101,7 +101,7 @@ class AutoSaveListener extends FileHandl
* operations in progress.
*/
@Override
- public synchronized void loading(FileHandler handler)
+ public synchronized void loading(final FileHandler handler)
{
loading++;
}
@@ -111,7 +111,7 @@ class AutoSaveListener extends FileHandl
* operations in progress.
*/
@Override
- public synchronized void loaded(FileHandler handler)
+ public synchronized void loaded(final FileHandler handler)
{
loading--;
}
@@ -124,7 +124,7 @@ class AutoSaveListener extends FileHandl
*
* @param fh the new {@code FileHandler} (can be <b>null</b>)
*/
- public synchronized void updateFileHandler(FileHandler fh)
+ public synchronized void updateFileHandler(final FileHandler fh)
{
if (handler != null)
{
@@ -156,7 +156,7 @@ class AutoSaveListener extends FileHandl
* @return <b>true</b> if a save operation should be performed, <b>false</b>
* otherwise
*/
- private boolean autoSaveRequired(ConfigurationEvent event)
+ private boolean autoSaveRequired(final ConfigurationEvent event)
{
return !event.isBeforeUpdate() && !inLoadOperation();
}