Skip to content

Commit a4f1f04

Browse files
rickymagnerRicky Magner
andauthored
Allow fluent chaining setters for SAMSequenceRecord (#1563)
* Return `this` from setters in SAMSequenceRecord for fluent style setter chaining. Co-authored-by: Ricky Magner <rmagner@wm349-9a3.broadinstitute.org>
1 parent 08628f5 commit a4f1f04

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

src/main/java/htsjdk/samtools/SAMSequenceRecord.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,40 +116,45 @@ public int getSequenceLength() {
116116
return mSequenceLength;
117117
}
118118

119-
public void setSequenceLength(final int value) {
119+
public SAMSequenceRecord setSequenceLength(final int value) {
120120
mSequenceLength = value;
121+
return this;
121122
}
122123

123124
public String getAssembly() {
124125
return (String) getAttribute(ASSEMBLY_TAG);
125126
}
126127

127-
public void setAssembly(final String value) {
128+
public SAMSequenceRecord setAssembly(final String value) {
128129
setAttribute(ASSEMBLY_TAG, value);
130+
return this;
129131
}
130132

131133
public String getSpecies() {
132134
return (String) getAttribute(SPECIES_TAG);
133135
}
134136

135-
public void setSpecies(final String value) {
137+
public SAMSequenceRecord setSpecies(final String value) {
136138
setAttribute(SPECIES_TAG, value);
139+
return this;
137140
}
138141

139142
public String getMd5() {
140143
return (String) getAttribute(MD5_TAG);
141144
}
142145

143-
public void setMd5(final String value) {
146+
public SAMSequenceRecord setMd5(final String value) {
144147
setAttribute(MD5_TAG, value);
148+
return this;
145149
}
146150

147151
public String getDescription() {
148152
return getAttribute(DESCRIPTION_TAG);
149153
}
150154

151-
public void setDescription(final String value) {
155+
public SAMSequenceRecord setDescription(final String value) {
152156
setAttribute(DESCRIPTION_TAG, value);
157+
return this;
153158
}
154159

155160
/**
@@ -160,8 +165,9 @@ public int getSequenceIndex() {
160165
}
161166

162167
// Private state used only by SAM implementation.
163-
public void setSequenceIndex(final int value) {
168+
public SAMSequenceRecord setSequenceIndex(final int value) {
164169
mSequenceIndex = value;
170+
return this;
165171
}
166172

167173
/**
@@ -188,13 +194,14 @@ public void addAlternativeSequenceName(final String name) {
188194
/**
189195
* Sets the alternative sequence names in the order provided by iteration, removing the previous values.
190196
*/
191-
public void setAlternativeSequenceName(final Collection<String> alternativeSequences) {
197+
public SAMSequenceRecord setAlternativeSequenceName(final Collection<String> alternativeSequences) {
192198
if (alternativeSequences == null) {
193199
setAttribute(ALTERNATIVE_SEQUENCE_NAME_TAG, null);
194200
} else {
195201
// encode all alt sequence names
196202
encodeAltSequences(alternativeSequences);
197203
}
204+
return this;
198205
}
199206

200207
private static void validateAltRegExp(final String name) {

0 commit comments

Comments
 (0)