• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Bean retrieving all Non-Null Attributes

 
Abiodun Adisa
Ranch Hand
Posts: 495
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose I have a class

class People(){
String firstName;
String lastName;
int name;
public String getFirstName()
public void setFirstName(String firstName);
..
..
}

And i intend to obtain all the non Null attributes of an object that is an instance of this class

for instance

People people=new People();
people.setFirstName("george");
people.setLastName("May");

Array tempMap=someutilityClass(people);


someutilityClass would return an array of attributes that are not null, Any pointers on how to accomplish this
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use java.beans.Introspector to get a list of PropertyDescriptors, then check each property to see if it's null or not. Were you expecting something more?
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic