Use the Visitor pattern in Java when operations should vary more often than the object structure they operate on.
Visitor is one of the more specialized behavioral patterns. It is most useful when:
It is commonly discussed with ASTs, document models, and other structured object graphs. It is usually a poor fit when element types change frequently.