Comments (4)
@esfomeado
The issue I understand is that you need a new option to determine the implementation of the interface dynamically.
Is it right?
In order to define an interface, we need to know which implementations are actually available.
I think there are two ways.
- Specify the package in which the implementation exists
- Specify the implementations just like
interfaceImplements
Any other ideas?
from fixture-monkey.
Yes, correct.
How would option 1 work if for instance there are multiple classes on that package that are not implementations of the interface? Will it handle sub packages as well?
My initial plan was to use reflection to get all the available implementations for the interface.
from fixture-monkey.
@esfomeado
How about making a custom ObjectPropertyGenerator
or using existing ObjectPropertyGenerator
?
If you use reflection to get all the available implementations and then make your own InterfaceObjectPropertyGenerator
.
You could use pushAssignableTypeObjectPropertyGenerator
option.
pushObjectPropertyGenerator(
new MatherOperator<>(
p -> Modifier.isAbstract(Types.getActualType(p.getType()).getModifiers()),
new CustomObjectPropertyGenerator()
)
);
In this case, You could use third-party library. https://github.com/ronmamo/reflections/
from fixture-monkey.
@seongahjo Thanks. That's literally what I wanted.
Works like a charm
from fixture-monkey.
Related Issues (20)
- Arbitrary always return same value in specific case HOT 2
- Set field for builder that have customizer not work HOT 8
- add a new implementation of StringArbitrary for FixtureMonkey
- apply validation annotations to YearMonth in JavaxValidationPlugin and JakartaValidationPlugin
- support generating lambda type HOT 3
- 'InnerSpec.keys()' Method with Collection Parameter Support
- Random a list of element that has a unique field HOT 4
- Repeated chars HOT 1
- JakartaValidationJavaArbitraryResolver doesn't work properly for properties with @Pattern
- Support generating kotlin.time.Duration HOT 1
- List property in class is always generated with same size
- @NotBlank validation not working properly HOT 1
- Value not being set HOT 2
- The string type data of objects created with fixtureMonkey in kotlin is strange. HOT 4
- Can not set final org.springframework.util.MultiValueMap field org.springframework.http.HttpHeaders.headers to java.util.HashMap HOT 1
- Improve Documentation ver 2 HOT 7
- NPE occurs in a class with a specific property HOT 2
- Add kotest module
- Add performance monitoring
- Enhance Kotlin Reflection
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fixture-monkey.