Refactored code to use short primitive instead of Short wrapper class.
This commit is contained in:
parent
0a2f6a4615
commit
7ec5e6824e
@ -1,87 +0,0 @@
|
||||
package com.baeldung.reflection.set.fields;
|
||||
|
||||
public class Person {
|
||||
|
||||
private String name;
|
||||
private byte age;
|
||||
private short uidNumber;
|
||||
private int pinCode;
|
||||
private long contactNumber;
|
||||
private float height;
|
||||
private double weight;
|
||||
private char gender;
|
||||
private boolean active;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public byte getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(byte age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public short getUidNumber() {
|
||||
return uidNumber;
|
||||
}
|
||||
|
||||
public void setUidNumber(short uidNumber) {
|
||||
this.uidNumber = uidNumber;
|
||||
}
|
||||
|
||||
public int getPinCode() {
|
||||
return pinCode;
|
||||
}
|
||||
|
||||
public void setPinCode(int pinCode) {
|
||||
this.pinCode = pinCode;
|
||||
}
|
||||
|
||||
public long getContactNumber() {
|
||||
return contactNumber;
|
||||
}
|
||||
|
||||
public void setContactNumber(long contactNumber) {
|
||||
this.contactNumber = contactNumber;
|
||||
}
|
||||
|
||||
public float getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setHeight(float height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public double getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public void setWeight(double weight) {
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
public char getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public void setGender(char gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void setActive(boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
}
|
@ -5,6 +5,8 @@ import java.lang.reflect.Field;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.baeldung.reflection.access.privatefields.Person;
|
||||
|
||||
public class SetFieldsUsingReflectionUnitTest {
|
||||
|
||||
@Test
|
||||
@ -66,7 +68,7 @@ public class SetFieldsUsingReflectionUnitTest {
|
||||
.getDeclaredField("pinCode");
|
||||
pinCodeField.setAccessible(true);
|
||||
|
||||
Short pinCode = 4110;
|
||||
short pinCode = 4110;
|
||||
pinCodeField.setInt(person, pinCode);
|
||||
Assertions.assertEquals(4110, person.getPinCode());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user