not sure if this is possible, but after i map the elements to atomic mass * atoms in the GRAMS case of my function, i want to return a sum of all the mapped results:
@Override
public double getConversionFactor() {
return switch (this.getUnit()) {
case ATOMS, MOLECULES, PARTICLES -> 6.02 * Math.pow(10, 23);
case GRAMS -> Arrays.stream(this.getElements())
.map(element -> element.getAtomic_mass() * element.getAtoms())
. // After i map them to atomic mass * atoms, i want to add up all the results and return it
;
case MOLES -> 1;
case LITERS -> 22.4;
};
}```
the other stuff in the function is irrelevant, but i thought it would be helpful to give a view of the whole function