I am using mongodb and for data verification I am trying to use java enumerations. I have defined the database schema in enum and am trying to pass this enumeration and actual data through the validationFunction function.
The definition of an enumeration is given below.
public enum Type {
STRING, OBJECT, INTEGER
}
public enum Existence {
REQUIRED, OPTIONAL
}
public enum Adress {
HOUSE_NO("houseNo", Type.STRING, Existence.REQUIRED),
STREET_NO("streetNo", Type.STRING, Existence.REQUIRED),
LANDMARK("landmark", Type.STRING, Existence.OPTIONAL)
public enum employeeSchema {
NAME("name", Type.STRING, Existence.REQUIRED),
AGE("age", Type.INTEGER, Existence.Optional),
ADDRESS("address", Type.OBJECT, Existence.REQUIRED)
String text;
Type valueType;
Existence exist;
Address(String text, Type valueType, Existence exist) {
this.text = text;
this.valueType = valueType;
this.exist = exist;
}
}
public enum employeeSchema {
NAME("name", Type.STRING, Existence.REQUIRED),
AGE("age", Type.INTEGER, Existence.Optional),
ADDRESS("address", Type.OBJECT, Existence.REQUIRED, Address)
String text;
Type valueType;
Existence exist;
employeeSchema(String text, Type valueType, Existence exist) {
this.text = text;
this.valueType = valueType;
this.exist = exist;
}
employeeSchema(String text, Type valueType, Existence exist, Enum schema) {
this.text = text;
this.valueType = valueType;
this.exist = exist;
this.schema = schema;
}
}
Now I want to pass employeeSchema through a function to validate the data.
public boolean validateData(JsonNode data, Enum schema){
}
So, the problem is that I want to pass enum through a function, but I need to have a common return type, because when I assemble it into an Enum type, it does not have the corresponding enum values.
For example, if I pass employeeSchema and execute employeeSchema.text, it says that the Enum type has no text.
I hope my problem is clear. Thank you in advance.