tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Jodd > Beans > How to get declared bean property type by name

How to get declared bean property type by name 

Jodd is an open-source java library with lot of reusable components and feature rich utilities. This requires the library jodd-3.3.2.jar to be in classpath. The following example shows how to get declared bean property type given the property name using BeanUtil.getDeclaredPropertyType() API.

File Name  :  
package com.bethecoder.tutorials.jodd.common;

public class Student4 {

  private String name;
  private int age;
  private String hobby;

  public Student4(String name, int age, String hobby) {
    super(); = name;
    this.age = age;
    this.hobby = hobby;

File Name  :  
Author  :  Sudhakar KV
Email  :  [email protected]
package com.bethecoder.tutorials.jodd.beans;

import jodd.bean.BeanUtil;

import com.bethecoder.tutorials.jodd.common.Student4;

public class GetDeclaredPropertyTypeTest {

   @param args
  public static void main(String[] args) {
    Student4 std = new Student4("Sriram"2"Chess");
    Class<?> nameClazz = BeanUtil.getDeclaredPropertyType(std, "name");
    Class<?> ageClazz = BeanUtil.getDeclaredPropertyType(std, "age");
    Class<?> hobbyClazz = BeanUtil.getDeclaredPropertyType(std, "hobby");


It gives the following output,
class java.lang.String
class java.lang.String


bl  br