Skip to content

Commit cc20358

Browse files
committed
Expand BeanUtils metadata documentation
Clarify the metadata lookup behavior, nullability, and introspection exception contract, and add an example showing how to inspect bean properties.
1 parent 55e5e05 commit cc20358

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

  • microsphere-java-core/src/main/java/io/microsphere/beans

‎microsphere-java-core/src/main/java/io/microsphere/beans/BeanUtils.java‎

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,32 @@ public static Map<String, Object> resolvePropertiesAsMap(@Nullable Object bean,
275275
}
276276

277277
/**
278-
* Get the {@link BeanMetadata} for the specified {@link Class}.
278+
* Gets the {@link BeanMetadata} for the specified {@link Class}.
279+
* <p>
280+
* This method retrieves the metadata associated with a given class, caching
281+
* the result to avoid repeated introspection overhead. The metadata contains
282+
* information about the bean's properties, methods, and other characteristics
283+
* necessary for Java Beans operations.
284+
* </p>
285+
*
286+
* <h3>Example Usage</h3>
287+
* <pre>{@code
288+
* public class Person {
289+
* private String name;
290+
* private int age;
291+
*
292+
* // Getters and setters...
293+
* }
294+
*
295+
* BeanMetadata metadata = BeanUtils.getBeanMetadata(Person.class);
296+
* System.out.println(metadata.getProperties().size()); // Outputs: 2 (name and age)
297+
* System.out.println(metadata.getProperty("name")); // Returns PropertyDescriptor for name
298+
* }</pre>
279299
*
280-
* @param beanClass the specified {@link Class}
281-
* @return non-null
282-
* @throws RuntimeException if an exception occurs during introspection
300+
* @param beanClass the class for which to retrieve bean metadata; must not be {@code null}
301+
* @return the {@link BeanMetadata} for the specified class, never {@code null}
302+
* @throws RuntimeException if an exception occurs during bean introspection
303+
* @see #BEAN_METADATA_CACHE_SIZE
283304
*/
284305
@Nonnull
285306
public static BeanMetadata getBeanMetadata(@Nonnull Class<?> beanClass) {

0 commit comments

Comments
 (0)