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

Export static package-private methods annotated with @Export as public in generated class #44

Closed
jbgi opened this issue Aug 8, 2016 · 6 comments
Milestone

Comments

@jbgi
Copy link
Member

jbgi commented Aug 8, 2016

This allows to use exclusively the generated class for all static api.
This should also addresses #41.

Also, as bonus, all static no-args methods will be exported with an additional caching of the returned value.
/cc @talios: WDYT?

@jbgi jbgi added this to the 0.9 milestone Aug 8, 2016
@talios
Copy link
Contributor

talios commented Aug 9, 2016

That sounds good! And we can still generate the normal methods as package-private if wanted?

I think that sounds like it should work.

@jbgi
Copy link
Member Author

jbgi commented Aug 9, 2016

@talios: 0.9 has been released with this new feature. See doc at https://github.com/derive4j/derive4j/blob/master/README.md#smart-constructors-and-static-methods-export

@talios
Copy link
Contributor

talios commented Aug 10, 2016

Looks good - will update my home project when I get home!

@talios
Copy link
Contributor

talios commented Aug 11, 2016

In the simple case of just wanting to add simple validation ( reusing the same constructor name and arguments) derive4j will generate broken java:

  // on the generated Links.java
  public static Link full(String rel, String href, Map<String, String> properties) {
    return Link.full(rel, href, properties);
  }

I guess we should either fail gracefully rather than generated broken java, or generate the package private method as something like _full(...).

@jbgi
Copy link
Member Author

jbgi commented Aug 11, 2016

Yeah you are right. Will fix this soon!

Le 11 août 2016 02:06, "Mark Derricutt" notifications@github.com a écrit :

In the simple case of just wanting to add simple validation ( reusing the
same constructor name and arguments) derive4j will generate broken java:

// on the generated Links.java
public static Link full(String rel, String href, Map<String, String> properties) {
return Link.full(rel, href, properties);
}

I guess we should either fail gracefully rather than generated broken
java, or generate the package private method as something like _full(...).


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
#44 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AANi6TRbwZYBmwYEK35T7Kf1BH_RYHkhks5qemd6gaJpZM4JfWcf
.

@jbgi
Copy link
Member Author

jbgi commented Aug 11, 2016

@talios I'm thinking of using the 0 suffix "convention" for package private methods. (eg java.util.Arrays#deepEquals0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants