I have a 2D table with columns: Language and Proficiency, which I need to populate with the input.
I've created a method:
public void typeLanguages(@NotNull List<String> languages,
@NotNull List<SkillLevel> skillLevels) {
if(languages.size() != skillLevels.size()) { throw new IllegalArgumentException(); }
IntStream.range(0, skillLevels.size()).forEach(i -> {
typeAndConfirm(languagesFld.get(i), languages.get(i));
typeAndConfirm(skillFld.get(i), skillLevels.get(i).getLangSkill());
});
}
IntStream is used, so i-th language-skillLevel pair is inserted in i-th row.
SkillLevel is an enum which implements getLangSkill() method which returns, one of four proficiency levels as String
However, there is a risk that the user can provide Lists of different sizes (although guarded) or that they could mix up the order and give themselves the wrong proficiency scores.
AFAIK there are no tuples in Java. I tried using Map, but I can't see any method that could let me use i-th element of map.