Skip to content

Commit

Permalink
Javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Oct 3, 2024
1 parent ad530d2 commit 5e38e11
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions src/main/java/org/apache/commons/beanutils2/BeanMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public Object setValue(final Object value) {
* An empty array. Used to invoke accessors via reflection.
*/
public static final Object[] NULL_ARGUMENTS = {};

/**
* Maps primitive Class types to transformers. The transformer transform strings into the appropriate primitive wrapper.
*
Expand All @@ -114,8 +115,6 @@ public Object setValue(final Object value) {

private final transient HashMap<String, Method> writeMethods = new HashMap<>();

// Constructors

private final transient HashMap<String, Class<? extends Object>> types = new HashMap<>();

/**
Expand Down Expand Up @@ -160,17 +159,11 @@ public void clear() {
*
* <ul>
* <li>If there is no underlying bean, return a cloned BeanMap without a bean.
*
* <li>Since there is an underlying bean, try to instantiate a new bean of the same type using Class.newInstance().
*
* <li>If the instantiation fails, throw a CloneNotSupportedException
*
* <li>Clone the bean map and set the newly instantiated bean as the underlying bean for the bean map.
*
* <li>Copy each property that is both readable and writable from the existing object to a cloned bean map.
*
* <li>If anything fails along the way, throw a CloneNotSupportedException.
*
* </ul>
*
* @return a cloned instance of this bean map
Expand Down Expand Up @@ -224,8 +217,10 @@ public Object clone() throws CloneNotSupportedException {
* <p>
* The given name must be a {@code String}; if not, this method returns false. This method will also return false if the bean does not define a property
* with that name.
* </p>
* <p>
* Write-only properties will not be matched as the test operates against property read methods.
* </p>
*
* @param name the name of the property to check
* @return false if the given name is null or is not a {@code String}; false if the bean does not define a property with that name; or true if the bean does
Expand All @@ -240,14 +235,14 @@ public boolean containsKey(final Object name) {
* Converts the given value to the given type. First, reflection is used to find a public constructor declared by the given class that takes one argument,
* which must be the precise type of the given value. If such a constructor is found, a new object is created by passing the given value to that
* constructor, and the newly constructed object is returned.
* <P>
*
* <p>
* If no such constructor exists, and the given type is a primitive type, then the given value is converted to a string using its {@link Object#toString()
* toString()} method, and that string is parsed into the correct primitive type using, for instance, {@link Integer#valueOf(String)} to convert the string
* into an {@code int}.
* <P>
*
* </p>
* <p>
* If no special constructor exists and the given type is not a primitive type, this method returns the original value.
* </p>
*
* @param <R> The return type.
* @param newType the type to convert the value to
Expand Down Expand Up @@ -338,6 +333,7 @@ public void remove() {
* Gets a Set of MapEntry objects that are the mappings for this BeanMap.
* <p>
* Each MapEntry can be set but not removed.
* </p>
*
* @return the unmodifiable set of mappings
*/
Expand Down Expand Up @@ -369,12 +365,14 @@ protected void firePropertyChange(final Object key, final Object oldValue, final
}

/**
* Returns the value of the bean's property with the given name.
* Gets the value of the bean's property with the given name.
* <p>
* The given name must be a {@link String} and must not be null; otherwise, this method returns {@code null}. If the bean defines a property with the given
* name, the value of that property is returned. Otherwise, {@code null} is returned.
* </p>
* <p>
* Write-only properties will not be matched as the test operates against property read methods.
* </p>
*
* @param name the name of the property whose value to return
* @return the value of the property with that name
Expand All @@ -395,7 +393,7 @@ public Object get(final Object name) {
}

/**
* Returns the bean currently being operated on. The return value may be null if this map is empty.
* Gets the bean currently being operated on. The return value may be null if this map is empty.
*
* @return the bean being operated on by this map
*/
Expand All @@ -406,7 +404,7 @@ public Object getBean() {
// Helper methods

/**
* Returns the accessor for the property with the given name.
* Gets the accessor for the property with the given name.
*
* @param name the name of the property
* @return null if the name is null; null if the name is not a {@link String}; null if no such property exists; or the accessor method for that property
Expand All @@ -416,7 +414,7 @@ protected Method getReadMethod(final Object name) {
}

/**
* Returns the accessor for the property with the given name.
* Gets the accessor for the property with the given name.
*
* @param name the name of the property
* @return the accessor method for the property, or null
Expand All @@ -426,7 +424,7 @@ public Method getReadMethod(final String name) {
}

/**
* Returns the type of the property with the given name.
* Gets the type of the property with the given name.
*
* @param name the name of the property
* @return the type of the property, or {@code null} if no such property exists
Expand All @@ -436,7 +434,7 @@ public Class<?> getType(final String name) {
}

/**
* Returns a transformer for the given primitive type.
* Gets a transformer for the given primitive type.
*
* @param <R> The transformer result type.
* @param type the primitive type whose transformer to return
Expand All @@ -446,10 +444,8 @@ protected <R> Function<Object, R> getTypeTransformer(final Class<R> type) {
return (Function<Object, R>) typeTransformers.get(type);
}

// Properties

/**
* Returns the mutator for the property with the given name.
* Gets the mutator for the property with the given name.
*
* @param name the name of the
* @return null if the name is null; null if the name is not a {@link String}; null if no such property exists; null if the property is read-only; or the
Expand All @@ -460,7 +456,7 @@ protected Method getWriteMethod(final Object name) {
}

/**
* Returns the mutator for the property with the given name.
* Gets the mutator for the property with the given name.
*
* @param name the name of the property
* @return the mutator method for the property, or null
Expand Down Expand Up @@ -506,6 +502,7 @@ private void initialize() {
* Convenience method for getting an iterator over the keys.
* <p>
* Write-only properties will not be returned in the iterator.
* </p>
*
* @return an iterator over the keys
*/
Expand All @@ -519,6 +516,7 @@ public Iterator<String> keyIterator() {
* Gets the keys for this BeanMap.
* <p>
* Write-only properties are <b>not</b> included in the returned set of property names, although it is possible to set their value and to get their type.
* </p>
*
* @return BeanMap keys. The Set returned by this method is not modifiable.
*/
Expand Down Expand Up @@ -665,7 +663,7 @@ public void remove() {
}

/**
* Returns the values for the BeanMap.
* Gets the values for the BeanMap.
*
* @return values for the BeanMap. The returned collection is not modifiable.
*/
Expand Down

0 comments on commit 5e38e11

Please sign in to comment.