Skip to content
This repository has been archived by the owner on Sep 25, 2018. It is now read-only.

Remove requirements for lists in setters #81

Open
julesjacobsen opened this issue May 23, 2017 · 0 comments
Open

Remove requirements for lists in setters #81

julesjacobsen opened this issue May 23, 2017 · 0 comments
Assignees

Comments

@julesjacobsen
Copy link
Contributor

This sort of looks fine on the outside:

public void setTypes(List<OntologyClass> classes) {
        this.types = ImmutableList.copyOf(classes);
    }

but leads to code looking like this:

Phenotype whiteHandsPhenotype = new Phenotype();
whiteHandsPhenotype.setTypes(ImmutableList.of(
        OntologyClass.of("PATO:0000323", "white"),
        OntologyClass.of("PATO:0000586", "increased size"),
        OntologyClass.of("UBERON:0002398", "manus")
));

Phenotype happyDisposition = new Phenotype();
happyDisposition.setTypes(ImmutableList.of(
        OntologyClass.of("HP:0100024","Conspicuously happy disposition"))
);
happyDisposition.setDescription("welcomes strangers with open arms");

TemporalRegion timeOfOnset = new TemporalRegion();
timeOfOnset.setTypes(ImmutableList.of(OntologyClass.of("HP:0011463", "childhood onset")));
happyDisposition.setTimeOfOnset(timeOfOnset);

Phenotype absentVibrisae = new Phenotype();
absentVibrisae.setTypes(ImmutableList.of(
        OntologyClass.of("MP:0001284","absent vibrissae"))
);
Phenotype circularEars = new Phenotype();
circularEars.setTypes(ImmutableList.of(
        OntologyClass.of("PATO:0000411","circular"),
        OntologyClass.of("UBERON:0001690", "ear")
));

That's five repetitions of ImmutableList.of() which is a lot of unnecessary noise, and typing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant