add batch methods to StubLifecycleListener.#3351
Conversation
if an import request was set to delete all stubs not imported, and its duplicate policy was set to IGNORE, the mapping saver would incorrectly delete any peristed stubs that were ignored during the import.
cf7e6aa to
8f3cfac
Compare
to declutter StubLifecycleListener
better practice than using the passed in list.
|
|
||
| @Override | ||
| public void setNewStub(StubMapping newStub) { | ||
| this.newStub = newStub; |
There was a problem hiding this comment.
Making these mutable seems a bit grubby. Is there no practical immutable alternative?
There was a problem hiding this comment.
as far as i can see this is the only reasonable way to replicate the single stub methods, beforeStubCreated and beforeStubEdited, that can return a new stub value to be passed to the next listener/saved. initially i tried to use the return value of beforeStubsAltered in the same way but because its a list of stubs it creates huge potential for misaligned behaviour. the implementor of the listener could completely remove a bunch of stubs from the returned list so they wouldnt be processed. this is not an ability that the listeners have had so far so didnt feel appropriate to add here. i kind of agree that on first sight, the mutability looks a bit nasty, but i actually think it creates quite a clean api for the listener implementors that replicates the api of the single stub methods. to be clear, this mutability only lasts for the duration of the call to this method, so doesnt create the potential for mutable references to hang around and edit stubs at will.
add batch methods to StubLifecycleListener so that multiple stubs can be processed at once if imported in a batch.