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

Remove requirements for lists in setters #81

Description

@julesjacobsen

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions