Skip to main content
deleted 9 characters in body
Source Link
Ajinkya
  • 22.7k
  • 33
  • 113
  • 164

Hi I have a class called "Person.java"Person.java and it has its own variables and also it also point to some of the referenced classes. Have a look at the variables below...

public class Person extends BaseModel { private static final long serialVersionUID = 1L; private Date dateOfBirth; private String aadhaarNumber; private Set<EducationQualification> educationQualifications; private Set<EmploymentExperience> employmentExperiences; private ContactInformation contactInformation; private DriversLicense driversLicense; private PersonName personName; private Candidate candidate; private Passport passport; private Set<Award> awards; } 

Here I am getting the field names using Java reflection. When I use "Class.getDeclaredField()"Class.getDeclaredField() its giving all the fields (Above specified variables). But I want only two fields those are

private Date dateOfBirth; private String aadhaarNumber; 

So if it is a static variable I can check weather its a static or not but how can I check weather its a referenced field or not...?

Can anyone please solve my doubts.? Please I stuck over here...

Hi I have a class called "Person.java" and it has its own variables and also it also point to some of the referenced classes. Have a look at the variables below...

public class Person extends BaseModel { private static final long serialVersionUID = 1L; private Date dateOfBirth; private String aadhaarNumber; private Set<EducationQualification> educationQualifications; private Set<EmploymentExperience> employmentExperiences; private ContactInformation contactInformation; private DriversLicense driversLicense; private PersonName personName; private Candidate candidate; private Passport passport; private Set<Award> awards; } 

Here I am getting the field names using Java reflection. When I use "Class.getDeclaredField()" its giving all the fields (Above specified variables). But I want only two fields those are

private Date dateOfBirth; private String aadhaarNumber; 

So if it is a static variable I can check weather its a static or not but how can I check weather its a referenced field or not...?

Can anyone please solve my doubts. Please I stuck over here...

I have a class called Person.java and it has its own variables and also it also point to some of the referenced classes. Have a look at the variables below

public class Person extends BaseModel { private static final long serialVersionUID = 1L; private Date dateOfBirth; private String aadhaarNumber; private Set<EducationQualification> educationQualifications; private Set<EmploymentExperience> employmentExperiences; private ContactInformation contactInformation; private DriversLicense driversLicense; private PersonName personName; private Candidate candidate; private Passport passport; private Set<Award> awards; } 

Here I am getting the field names using Java reflection. When I use Class.getDeclaredField() its giving all the fields (Above specified variables). But I want only two fields those are

private Date dateOfBirth; private String aadhaarNumber; 

So if it is a static variable I can check weather its a static or not but how can I check weather its a referenced field or not?

Can anyone please solve my doubts? Please I stuck over here.

edited title; edited tags
Link
Luiggi Mendoza
  • 85.9k
  • 16
  • 160
  • 354

How to get thesome fields of the class using Java Reflection

Source Link
Amar
  • 763
  • 2
  • 18
  • 36

How to get the fields using Java Reflection

Hi I have a class called "Person.java" and it has its own variables and also it also point to some of the referenced classes. Have a look at the variables below...

public class Person extends BaseModel { private static final long serialVersionUID = 1L; private Date dateOfBirth; private String aadhaarNumber; private Set<EducationQualification> educationQualifications; private Set<EmploymentExperience> employmentExperiences; private ContactInformation contactInformation; private DriversLicense driversLicense; private PersonName personName; private Candidate candidate; private Passport passport; private Set<Award> awards; } 

Here I am getting the field names using Java reflection. When I use "Class.getDeclaredField()" its giving all the fields (Above specified variables). But I want only two fields those are

private Date dateOfBirth; private String aadhaarNumber; 

So if it is a static variable I can check weather its a static or not but how can I check weather its a referenced field or not...?

Can anyone please solve my doubts. Please I stuck over here...