Pattern design for Java