Comments (9)
Well I extended the API slightly, but providing APIs like "getParameterIntValue" is a tricky thing because the members can be of arbitrary classes (JAnnotationArrayMember, JAnnotationStringValue or JAnnotationUse itself). Instead I provided a generic "getParam" returning AbstractJAnnotationValue, a "getConstantParam" returning only JAnnotationStringValue and finally "getConstantParamValue" returning the value expression inside the JAnnotationStringValue.
Now if accessors for primitives are required there are imho 2 options: 1. provide a default value in the method (like 'int getParamIntValue (String name, int defaultValue)') or 2. return the primitive wrapper type (like 'Integer getParamIntValue (String name)') which can therefore be null.
I personally think the second alternative looks nicer.
from jcodemodel.
Actually I was thinking about accessing actual parameter values, not their code model. See this two classes to get an idea of what I want:
from jcodemodel.
I do get your point. Currently the following types are supported:
8 primitives, String, Class<?> -> no problem for them
IJExpression, AbstractJType, JEnumConstant -> they are already "code modelled"
I could add a method "public Object getNativeValue()" to JAnnotationStringValue that returns the original object before it is wrapped. I would really like to spare the additional map from name to value if possible. Ok?
from jcodemodel.
This sounds good, thank you.
from jcodemodel.
About code modeled values... My reasoning was that annotation parameters should be "compile-time constants", they always have some native value during compilation time, so this IJExpression, AbstractJType, JEnumConstant should always have some known value... May be it's better to deprecate this methods, and always ask for some actual value...
from jcodemodel.
Please check the trunk if that fits your needs.
I deprecated the version with "IJExpression" but left the ones with AbstractJType and JEnumConstant, because otherwise generated enums could not be used in there
from jcodemodel.
Checked latest version. Works for my needs. Thanx.
from jcodemodel.
OK, so I will start the release process...
from jcodemodel.
2.7.6 out now - already on Maven Central
from jcodemodel.
Related Issues (20)
- How can I get the Java Class value for a generated param? HOT 4
- weird issue with snakeyaml HOT 11
- Missing compiler package from 3.4.1 HOT 3
- Migrate off of jsr305 HOT 4
- [proposal] check packages names HOT 19
- [proposal] check class name against keywords and java.lang HOT 10
- https://github.com/eclipse-ee4j/jaxb-ri HOT 3
- create resource directory HOT 45
- in-memory and jar/zip platform HOT 3
- [feature] preprocessors HOT 2
- Missing qualification for inner classes in generic parameters of anonymous classes HOT 4
- Add a method to remove annotations from JDefinedClass or JFieldVar HOT 11
- Enum constant arg with class HOT 3
- Generate *.class HOT 5
- Inner Class HOT 8
- [feature] copying JCodeModel HOT 34
- [lib] use lombok ? HOT 3
- [feature] chaining blocks and instructions HOT 1
- java 16 record ? HOT 12
- memoryCodeWriter modifications HOT 1
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 jcodemodel.