Use an inner class

http://ideone.com/C9keDo