add convenience method
This commit is contained in:
parent
8192830b75
commit
216031848e
2 changed files with 15 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
group = org.xbib
|
||||
name = marc
|
||||
version = 2.9.7
|
||||
version = 2.9.8
|
||||
|
||||
org.gradle.warning.mode = ALL
|
||||
|
|
|
@ -451,6 +451,20 @@ public class MarcField implements Comparable<MarcField> {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to add a subfield only if the value is not null.
|
||||
* @param subfieldId the dubfield ID
|
||||
* @param value the subfield value
|
||||
* @return this builder
|
||||
*/
|
||||
public Builder subfieldIfNotNull(String subfieldId, String value) {
|
||||
if (value != null) {
|
||||
String id = validator.validateSubfieldId(subfieldId);
|
||||
subfields.add(new Subfield(id, value));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add subfield ID without a value.
|
||||
* @param subfieldId the subfield ID
|
||||
|
|
Loading…
Reference in a new issue