Hello I am a beginner at SpringBoot and I am having trouble using Java reflection to validate my min and max fields. I have a Part class that with each part object having different min and max values for the inventory and I want to access those values at runtime in the validation part of my SpringBoot application.
This is the relevant code for the Part class:
@ValidInvRange
int inv;
int min;
int max;
I want to know how I can access the integer values using reflection in a Validation class. I have been unable to figure it out so far.
So far I've tried for each value to this-
Field inv = Part.class.getDeclaredField("inv");
int inventory = (int) inv.get(inv);
Aucun commentaire:
Enregistrer un commentaire