File tree Expand file tree Collapse file tree
core-java-modules/core-java-lang-2
src/main/java/com/baeldung/pojo Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515
1616 <dependencies >
1717 <dependency >
18- <groupId >org.openjdk.jmh </groupId >
19- <artifactId >jmh-core </artifactId >
20- <version >${jmh-core.version} </version >
21- </dependency >
18+ <groupId >commons-beanutils </groupId >
19+ <artifactId >commons-beanutils </artifactId >
20+ <version >1.9.4 </version >
21+ </dependency >
2222 <dependency >
2323 <groupId >org.openjdk.jmh</groupId >
2424 <artifactId >jmh-generator-annprocess</artifactId >
2929 <artifactId >jmh-generator-bytecode</artifactId >
3030 <version >${jmh-generator.version} </version >
3131 </dependency >
32+ <dependency >
33+ <groupId >org.openjdk.jmh</groupId >
34+ <artifactId >jmh-core</artifactId >
35+ <version >${jmh-core.version} </version >
36+ </dependency >
3237 </dependencies >
3338
3439 <build >
Original file line number Diff line number Diff line change 1+ package com .baeldung .pojo ;
2+
3+ import java .io .Serializable ;
4+ import java .time .LocalDate ;
5+
6+ public class EmployeeBean implements Serializable {
7+
8+ /**
9+ *
10+ */
11+ private static final long serialVersionUID = -3760445487636086034L ;
12+
13+ private String firstName ;
14+
15+ private String lastName ;
16+
17+ private LocalDate startDate ;
18+
19+ public EmployeeBean () {
20+
21+ }
22+
23+ public EmployeeBean (String firstName , String lastName , LocalDate startDate ) {
24+ this .firstName = firstName ;
25+ this .lastName = lastName ;
26+ this .startDate = startDate ;
27+ }
28+
29+ public String getFirstName () {
30+ return firstName ;
31+ }
32+
33+ public void setFirstName (String firstName ) {
34+ this .firstName = firstName ;
35+ }
36+
37+ public String getLastName () {
38+ return lastName ;
39+ }
40+
41+ public void setLastName (String lastName ) {
42+ this .lastName = lastName ;
43+ }
44+
45+ public LocalDate getStartDate () {
46+ return startDate ;
47+ }
48+
49+ public void setStartDate (LocalDate startDate ) {
50+ this .startDate = startDate ;
51+ }
52+
53+ }
Original file line number Diff line number Diff line change 1+ package com .baeldung .pojo ;
2+
3+ import java .time .LocalDate ;
4+
5+ public class EmployeePojo {
6+
7+ public String firstName ;
8+
9+ public String lastName ;
10+
11+ private LocalDate startDate ;
12+
13+ public EmployeePojo (String firstName , String lastName , LocalDate startDate ) {
14+ this .firstName = firstName ;
15+ this .lastName = lastName ;
16+ this .startDate = startDate ;
17+ }
18+
19+ public String name () {
20+ return this .firstName + " " + this .lastName ;
21+ }
22+
23+ public LocalDate getStart () {
24+ return this .startDate ;
25+ }
26+
27+ }
Original file line number Diff line number Diff line change 1+ package com .baeldung .pojo ;
2+
3+ import java .beans .PropertyDescriptor ;
4+
5+ import org .apache .commons .beanutils .PropertyUtils ;
6+
7+
8+ public class ReflectionExample {
9+
10+ public static void main (String [] args ) {
11+
12+ System .out .println ("Fields for EmployeePojo are:" );
13+ for (PropertyDescriptor pd : PropertyUtils .getPropertyDescriptors (EmployeePojo .class )) {
14+ System .out .println (pd .getDisplayName ());
15+ }
16+
17+ System .out .println ("Fields for EmployeeBean are:" );
18+ for (PropertyDescriptor pd : PropertyUtils .getPropertyDescriptors (EmployeeBean .class )) {
19+ System .out .println (pd .getDisplayName ());
20+ }
21+
22+ }
23+
24+ }
You can’t perform that action at this time.
0 commit comments