Replies: 3 comments 10 replies
-
@rfuerst87 I had a quick at the project. Great start! It's been a while since I added the guava module, but hopefully my memory serves me well and I answer your questions correctly.
InternalContainerHint.builder()
// how many times the "add" function should be called
.generateEntries(numberOfEntriesToAdd)
// method for adding to the container, e.g. Seq
.addFunction((Seq<T> seq, Object... args) -> seq.append((T) args[0]))
// Or for Map
//.addFunction((Map<K, V> seq, Object... args) -> map.put((K) args[0], (V) args[1]))
.build(); The size of the
As I mentioned, the internal API for generating containers isn't super intuitive :) I can take a closer look into it once I have some free time. Let me know if you have any other questions in the meantime. |
Beta Was this translation helpful? Give feedback.
-
@rfuerst87 I think your initial approach was on the right track (generating a Please see the updated PR movementsciences/instancio-vavr#2 with passing tests. |
Beta Was this translation helpful? Give feedback.
-
Hi, I have created a VAVR module in a fork of instancio, I didn't know that @rfuerst87 had started to develop the VAVR extension. |
Beta Was this translation helpful? Give feedback.
-
Hi @armandino
I created an issue two days ago asking for supporting Vavr collections. As I had no better plans today I thought to give it a try myself. You can find my progress in https://github.com/movementsciences/instancio-vavr/.
I have a few questions and problems that I hope you can help me with:
java.util.Collection
I assume I have to register them as container types inInternalContainerFactoryProvider
. Is that correct?InternalContainerFactoryProvider#getMappingFunction
used for?java.util.Collection
. So usingCollectionGenerator
as done ininstancio-guava
does not work. I therefore came up withVavrSeqGenerator
. Problem is that it fails for all types that is not the defaultList
implementation. All test inVavrSupportedSeqTest
fail. Turns out that java collections use a dedicatedCollectionNodeHandler
that sets the subtype.UsingGeneratorResolverHandler
that is used for SPI provided generators does not do that. Would it be possible to set the subtype inUsingGeneratorResolverHandler
if the generator implements theSubtypeGeneratorSpec
? Or am I doing this entirely wrong?Beta Was this translation helpful? Give feedback.
All reactions