Update EquipmentItemStream.java

This commit is contained in:
snarLox 2021-08-22 11:42:32 +10:00 committed by GitHub
parent a89766c8e7
commit 1fb046fbb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 29 additions and 1 deletions

View File

@ -18,14 +18,35 @@ public class EquipmentItemStream extends RandomizedStreamAdapter<EquipmentItem,
return new EquipmentItemStream(stream);
}
/**
/**
* Returns a stream consisting of the elements of this stream with
* any of the given {@link EquipmentItem#id()}s
*/
public EquipmentItemStream withId(int... ids) {
return filter(o -> Arrays.stream(ids).anyMatch(id -> o.id() == id));
}
/**
* Returns a stream consisting of the elements of this stream with
* any of the given {@link InventoryItem#id()}s
*/
public EquipmentItemStream withId(Collection<Integer> ids) {
return filter(o -> ids.stream().anyMatch(id -> o.id() == id));
}
/**
* Returns a stream consisting of the elements of this stream that don't match
* any of the given {@link InventoryItem#id()}s
*/
public EquipmentItemStream withoutId(Collection<Integer> ids) {
return filter(o -> ids.stream().noneMatch(id -> o.id() == id));
}
/**
* Returns a stream consisting of the elements of this stream that don't match
* any of the given {@link InventoryItem#id()}s
*/
public EquipmentItemStream withoutId(int... ids) {
return filter(o -> Arrays.stream(ids).noneMatch(id -> o.id() == id));
}
/**
* Returns a stream consisting of the elements of this stream with
* a minimum {@link EquipmentItem#quantity()}
@ -49,6 +70,13 @@ public class EquipmentItemStream extends RandomizedStreamAdapter<EquipmentItem,
public EquipmentItemStream withNamePart(String... names) {
return filter(o -> Arrays.stream(names).anyMatch(name -> o.name().toLowerCase().contains(name.toLowerCase())));
}
/**
* Returns a stream consisting of the elements of this stream that don't match
* any of the given {@link InventoryItem#name()}s
*/
public EquipmentItemStream withoutNamePart(String... names) {
return filter(o -> Arrays.stream(names).noneMatch(name -> o.name().toLowerCase().contains(name.toLowerCase())));
}
/**
* Returns a stream consisting of the elements of this stream with