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

WELD-2498 Expand ClassFileInfo to detect all possible class nesting types. #76

Merged
merged 1 commit into from Jul 23, 2018

Conversation

manovotn
Copy link
Contributor

@manovotn manovotn commented Jul 3, 2018

We could also add default impl (e.g. simply false) but I don't think it's worth it here.

@nziakova
Copy link
Contributor

nziakova commented Jul 9, 2018

Should this be updated in the docs, too?

@manovotn
Copy link
Contributor Author

manovotn commented Jul 9, 2018

It should indeed, thanks!

@manovotn
Copy link
Contributor Author

manovotn commented Jul 9, 2018

Docs are updated as a part of weld/core#1858

*
* @return true if this class is local, false otherwise
*/
boolean isLocalClass();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather introduce a single method that would return the nesting type of the class, something similar to org.jboss.jandex.ClassInfo.NestingType, except that Jandex reports static nested classes as inner classes (see ClassInfo.nestingType() javadoc). Our enum could be something like:

enum NestingType {
  TOP_LEVEL,
  NESTED_INNER,
  NESTED_LOCAL,
  NESTED_ANONYMOUS,
  NESTED_STATIC
}

On the other hand, even with these two additional methods we can distinguish all nesting types:

Type Test
top level isTopLevelClass()
inner !isTopLevelClass() && !isLocalClass() && !isAnonymousClass() && !Modifier.isStatic(getModifiers())
static nested !isTopLevelClass() && Modifier.isStatic(getModifiers())
inner local isLocalClass()
inner anonymous isAnonymousClass()

WDYT?

@manovotn manovotn changed the title WELD-2498 Allow ClassFileInfo to detect local and anonymous classes. WELD-2498 Expand ClassFileInfo to detect all possible class nesting types. Jul 10, 2018
@manovotn manovotn merged commit 7c9e497 into weld:master Jul 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants