SampleGenotype { @Override public String toString() { if (isEmpty()){ return "NA"; } StringJoiner stringJoiner; if (phased) { stringJoiner = new StringJoiner("|"); } else { stringJoiner = new StringJoiner("/"); } for (AlleleCall alleleCall : alleleCalls) { stringJoiner.add(alleleCall.toVcfString()); } return stringJoiner.toString(); } private  SampleGenotype(boolean phased, AlleleCall... alleleCalls); static SampleGenotype empty(); static SampleGenotype noCall(); static SampleGenotype het(); static SampleGenotype homRef(); static SampleGenotype homAlt(); static SampleGenotype of(AlleleCall... alleleCalls); static SampleGenotype phased(AlleleCall... alleleCalls); List<AlleleCall> getCalls(); @JsonIgnore boolean isHet(); @JsonIgnore boolean isHomRef(); @JsonIgnore boolean isHomAlt(); @JsonIgnore boolean isPhased(); @JsonIgnore boolean isEmpty(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void testToString() { assertThat(SampleGenotype.empty().toString(), equalTo("NA")); assertThat(SampleGenotype.of(AlleleCall.NO_CALL, AlleleCall.NO_CALL).toString(), equalTo("./.")); assertThat(SampleGenotype.of(AlleleCall.NO_CALL, AlleleCall.REF).toString(), equalTo("./0")); assertThat(SampleGenotype.of(AlleleCall.NO_CALL, AlleleCall.ALT).toString(), equalTo("./1")); assertThat(SampleGenotype.of(AlleleCall.NO_CALL, AlleleCall.OTHER_ALT).toString(), equalTo("./-")); assertThat(SampleGenotype.of(AlleleCall.REF, AlleleCall.ALT).toString(), equalTo("0/1")); assertThat(SampleGenotype.of(AlleleCall.ALT, AlleleCall.REF).toString(), equalTo("0/1")); assertThat(SampleGenotype.of(AlleleCall.REF, AlleleCall.REF).toString(), equalTo("0/0")); assertThat(SampleGenotype.of(AlleleCall.ALT, AlleleCall.ALT).toString(), equalTo("1/1")); assertThat(SampleGenotype.of(AlleleCall.REF, AlleleCall.OTHER_ALT).toString(), equalTo("0/-")); assertThat(SampleGenotype.of(AlleleCall.OTHER_ALT, AlleleCall.REF).toString(), equalTo("0/-")); assertThat(SampleGenotype.of(AlleleCall.ALT, AlleleCall.OTHER_ALT).toString(), equalTo("-/1")); assertThat(SampleGenotype.of(AlleleCall.OTHER_ALT, AlleleCall.ALT).toString(), equalTo("-/1")); assertThat(SampleGenotype.of(AlleleCall.OTHER_ALT, AlleleCall.OTHER_ALT).toString(), equalTo("-/-")); assertThat(SampleGenotype.phased(AlleleCall.NO_CALL, AlleleCall.NO_CALL).toString(), equalTo(".|.")); assertThat(SampleGenotype.phased(AlleleCall.ALT, AlleleCall.NO_CALL).toString(), equalTo("1|.")); assertThat(SampleGenotype.phased(AlleleCall.NO_CALL, AlleleCall.REF).toString(), equalTo(".|0")); assertThat(SampleGenotype.phased(AlleleCall.NO_CALL, AlleleCall.OTHER_ALT).toString(), equalTo(".|-")); assertThat(SampleGenotype.phased(AlleleCall.REF, AlleleCall.ALT).toString(), equalTo("0|1")); assertThat(SampleGenotype.phased(AlleleCall.ALT, AlleleCall.REF).toString(), equalTo("1|0")); assertThat(SampleGenotype.phased(AlleleCall.REF, AlleleCall.REF).toString(), equalTo("0|0")); assertThat(SampleGenotype.phased(AlleleCall.ALT, AlleleCall.ALT).toString(), equalTo("1|1")); assertThat(SampleGenotype.phased(AlleleCall.REF, AlleleCall.OTHER_ALT).toString(), equalTo("0|-")); assertThat(SampleGenotype.phased(AlleleCall.OTHER_ALT, AlleleCall.REF).toString(), equalTo("-|0")); assertThat(SampleGenotype.phased(AlleleCall.ALT, AlleleCall.OTHER_ALT).toString(), equalTo("1|-")); assertThat(SampleGenotype.phased(AlleleCall.OTHER_ALT, AlleleCall.ALT).toString(), equalTo("-|1")); assertThat(SampleGenotype.phased(AlleleCall.OTHER_ALT, AlleleCall.OTHER_ALT).toString(), equalTo("-|-")); }