Git Product home page Git Product logo

Comments (9)

phax avatar phax commented on September 16, 2024

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.

sviperll avatar sviperll commented on September 16, 2024

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:

https://github.com/sviperll/adt4j/blob/master/adt4j-core/src/main/java/com/github/sviperll/adt4j/Annotations.java

https://github.com/sviperll/adt4j/blob/master/adt4j-core/src/main/java/com/github/sviperll/adt4j/AnnotationUsage.java

from jcodemodel.

phax avatar phax commented on September 16, 2024

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.

sviperll avatar sviperll commented on September 16, 2024

This sounds good, thank you.

from jcodemodel.

sviperll avatar sviperll commented on September 16, 2024

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.

phax avatar phax commented on September 16, 2024

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.

sviperll avatar sviperll commented on September 16, 2024

Checked latest version. Works for my needs. Thanx.

from jcodemodel.

phax avatar phax commented on September 16, 2024

OK, so I will start the release process...

from jcodemodel.

phax avatar phax commented on September 16, 2024

2.7.6 out now - already on Maven Central

from jcodemodel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.