Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Use Enum value in Annotations in Scala #688

Closed
jxnu-liguobin opened this issue May 13, 2021 · 2 comments
Closed

Support Use Enum value in Annotations in Scala #688

jxnu-liguobin opened this issue May 13, 2021 · 2 comments
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@jxnu-liguobin
Copy link
Collaborator

Yes, I understand this but the problem is with

type User {
    name: String,
    friends: [User] @relationship(type: "FRIEND_WITH", direction: OUT)
}

enum Direction {
    IN,
    OUT
}

the import will not get triggered in the Scala world. Nowhere to be precise but Java does not complain about this.

Even adding a

directive @relationship (
    type: String,
    direction: Direction
) on FIELD_DEFINITION

won't help because the meta-information are not telling me anything about types in the annotation.
This would need a lot of refactoring -if even possible- to get those information.

Thus my initial question was if I should remove the assumptions in the Scala test code completely.

Originally posted by @meistermeier in #674 (comment)

@jxnu-liguobin
Copy link
Collaborator Author

jxnu-liguobin commented May 13, 2021

<#if fields?has_content>
    <#if enumImportItSelfInScala?has_content>
        <#list fields as field>
            <#list enumImportItSelfInScala as enum>
                <#if MapperUtil.isScalaCollection(field.type)>
                    <#if enum == MapperUtil.getGenericParameter(field.type)>
import ${enum}._
                    </#if>
                <#else >
                    <#if enum == field.type>
import ${enum}._
                    </#if>
                </#if>
            </#list>
        </#list>
    </#if>
</#if>

The problem here is that the value of the annotation is not judged.

Temporary solution: Enumeration values in annotations use enumeration full class names such as

@com.example.Relationship(type = "FRIEND_WITH", direction = DIRECTION.OUT)

@jxnu-liguobin jxnu-liguobin changed the title Support Enum value in Annotations Support Use Enum value in Annotations in Scala May 13, 2021
@jxnu-liguobin jxnu-liguobin added bug Something isn't working help-wanted Extra attention is needed labels May 13, 2021
@jxnu-liguobin jxnu-liguobin added wontfix This will not be worked on and removed help-wanted Extra attention is needed labels Jun 25, 2021
@jxnu-liguobin
Copy link
Collaborator Author

Result: use enumeration full class names

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant