Refactored to be cohesive between java and groovy