applying patterns in java with reflection