I’m wondering if I can easily have an if statement somehow here:
public Object[] tableItemFromVisit(Visit visit, boolean editable) {
return new Object[] {
visit.getIdVisit(),
visit.getProfession().getProfessionName(),
visit.getSpiProfessional().getFullName(),
RegularFunctions.getTimeFormat().format(visit.getVisitDate()),
RegularFunctions.toNormalCapitalizedText(visit.getVisitState()
.toString()), visit.getReason(),
if (editable) { "Edit" },
};
}
How is this structure even called? An array specification or what?
Anyway if the variable “editable” is true, it has to have an “Edit” string, if it’s false, it doesn’t need anything…
Obviously I don’t want to write two return statements that are way too similar to each other…
Construct the above array as an
ArrayListand return itstoArray?Essence of the idea is to do something like this.
I am not sure if this kind of initialization works though, if not
Arrays.toListcan also be used, or just add one by one.