Hi all,

I am having a look at some code and realize that I don't understand the subtle difference between JavaType and JavaSource in certain cases. In some visitor code (see below), I see :

JavaType<?> javaType = resource.getJavaType();

And other times I see :

JavaSource<?> javaSource = javaResource.getJavaType();

So I look at the code. JavaSource extends from JavaType, adds one method, and then they both implement similar interfaces (JavaDocCapable vs JavaDocCapableSource).

So, in the following example, why use JavaSource instead of JavaType ?

Thanks
Antonio

 @Override
            public void visit(VisitContext context, JavaResource resource)
            {
               try
               {
                  JavaType<?> javaType = resource.getJavaType();
                  if (javaType.isClass() && !javaType.hasAnnotation(Entity.class) javaSource.hasAnnotation(MappedSuperclass.class))
                  {
                     classes.add(resource);
                  }
               }
               catch (FileNotFoundException e)
               {
                  // ignore
               }
            }


--
Antonio Goncalves 
Software architect and Java Champion

Web site | Twitter | LinkedIn | Paris JUG | Devoxx France