add removeSubfields() method
This commit is contained in:
parent
40e6051a40
commit
7c527ea4ec
2 changed files with 26 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
||||||
group = org.xbib
|
group = org.xbib
|
||||||
name = marc
|
name = marc
|
||||||
version = 2.10.0
|
version = 2.11.0
|
||||||
|
|
||||||
org.gradle.warning.mode = ALL
|
org.gradle.warning.mode = ALL
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Deque;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.function.BinaryOperator;
|
import java.util.function.BinaryOperator;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
@ -602,6 +603,20 @@ public class MarcField implements Comparable<MarcField> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove subfields if they match the given set of subfield IDs.
|
||||||
|
* @param subfieldIds the IDs to remove
|
||||||
|
* @return this builder
|
||||||
|
*/
|
||||||
|
public Builder removeSubfields(Set<String> subfieldIds) {
|
||||||
|
LinkedList<Subfield> list = subfields.stream()
|
||||||
|
.filter(sf -> !subfieldIds.contains(sf.id))
|
||||||
|
.collect(Collectors.toCollection(LinkedList::new));
|
||||||
|
this.subfields.clear();
|
||||||
|
this.subfields.addAll(list);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy a MARC field into this builder.
|
* Copy a MARC field into this builder.
|
||||||
* @param field the MARC field to copy
|
* @param field the MARC field to copy
|
||||||
|
@ -793,6 +808,16 @@ public class MarcField implements Comparable<MarcField> {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
return obj instanceof Subfield && toString().equals(obj.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return toString().hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return id + "=" + value;
|
return id + "=" + value;
|
||||||
|
|
Loading…
Reference in a new issue