Walking around compilation failure on enums implementing interfaces

If an enum implements an interface, and methods from the interface are called on an instance of the enum, the enum instance needs to be referenced as the interface, or the interface is somehow referenced in the context where the methods are called; Otherwise, there is possible compilation failure in a Maven build complaining about "cannot find symbol" on the interface methods being called.

Java Compiler API and Maven integration

Suppose that we need to make some changes to our source code during a Maven build, e.g., we want to add a special method to a class for a testing Maven profile, but not for other Maven profiles. This post shows a method to achieve this by calling the Java Compiler API from a Maven plugin. The method does not require the knowledge of annotation processing or bytecode manipulation.