T - the type of requirements to isolate@Beta public interface Isolatable<T>
Interfaces that extend Isolatable are not meant to be extended, but may be implemented.
| Modifier and Type | Method and Description |
|---|---|
T |
isolate(Consumer<T> consumer)
Verifies requirements without modifying the current instance.
|
T isolate(Consumer<T> consumer)
Map<String, Integer> nameToId = ...;
Requirements.requireThat(nameToId, "nameToId").keySet().contains("John Smith");
Requirements.requireThat(nameToId, "nameToId").values().doesNotContain(0, "RESERVED_ID");
// Can be rewritten as:
Requirements.requireThat(nameToId, "nameToId").
isolate(p -> p.keySet().contains("John Smith")).
isolate(p -> p.values().doesNotContain(0, "RESERVED_ID"));
consumer - the code to execute in isolationCopyright © 2016. All rights reserved.