}
@Override
public void enterProperty(Property node)
{
AbstractBean bean = stack.peek();
boolean isPrivate = Visibility.PRIVATE.equals(bean.getVisibility());
if (isPrivate)
{
env.getMessager().printMessage(
Kind.ERROR,
String.format("Property '%s' in class '%s' is invisible because the class is private.", node.getName(),
bean.getName().getQualified()));
bean.remove(node);
return;
}
if (Visibility.PRIVATE.equals(node.getVisibility()))
{
env.getMessager().printMessage(
Kind.ERROR,
String.format("Property '%s' in class '%s' is invisible because it is private.", node.getName(),
bean.getName().getQualified()));
bean.remove(node);
return;
}
final String name = node.getName();
final String handle = node.getHandle();
if (RESERVED.contains(handle))
{
String altHandle = handle + "_";
boolean altHandleTaken = false;
for (Property property : bean.getProperties().values())
{
if (altHandle.equals(property.getHandle()))
{
altHandleTaken = true;
break;
}
}
if (altHandleTaken)
{
env.getMessager()
.printMessage(
Kind.ERROR,
String.format(
"Property '%s' in class '%s' has the same name as a reserved word in Java. Alternate name '%s' has also been taken.",
name, bean.getName().getQualified(), altHandle));
bean.remove(node);
}
else
{
node.setHandle(altHandle);
env.getMessager().printMessage(
Kind.WARNING,
String.format(
"Property '%s' in class '%s' has the same name as a reserved word in Java, renamed to '%s'",
name, bean.getName().getQualified(), altHandle));
}
return;
}
}