I want to check if a boolean variable from a Domain class equates to true in my method.
private Boolean exampleName1 = null;
This is in a @Entity class called Javaclass1.java
My method is in JavaClass2.java
public static String myMethod(name1, nameClass){
if(nameClass != null){
return name1;
}
}
I want to execute the if condition above only if the boolean for exampleName1 in the entity class is true. It has a getter and setter. How would I import and setup the if condition?
CodePudding user response:
If you want to read a private attribute from another entity (in your example something like getExampleName1()
) you should have instance of that entity at first. you should import your entity by Name and then call the getter name. for example:
public static String myMethod(String name1, String nameClass, Javaclass1 javaClass1){
if(nameClass != null && javaClass1.getExampleName1 == true ){
return name1;
}
}