### Question:
JsdUtil { static int getMaxOccurs(final Annotation annotation) { if (annotation instanceof AnyElement) return ((AnyElement)annotation).maxOccurs(); if (annotation instanceof ArrayElement) return ((ArrayElement)annotation).maxOccurs(); if (annotation instanceof BooleanElement) return ((BooleanElement)annotation).maxOccurs(); if (annotation instanceof NumberElement) return ((NumberElement)annotation).maxOccurs(); if (annotation instanceof ObjectElement) return ((ObjectElement)annotation).maxOccurs(); if (annotation instanceof StringElement) return ((StringElement)annotation).maxOccurs(); throw new UnsupportedOperationException("Unsupported annotation type: " + annotation.annotationType().getName()); } private  JsdUtil();   }### Answer:
@Test public void testGetMaxOccurs() { try { JsdUtil.getMaxOccurs(ArrayLoop.class.getAnnotation(ArrayType.class)); fail("Expected UnsupportedOperationException"); } catch (final UnsupportedOperationException e) { } assertEquals(Integer.MAX_VALUE, JsdUtil.getMaxOccurs(Staff.class.getAnnotation(ObjectElement.class))); assertEquals(1, JsdUtil.getMaxOccurs(Array2d1.class.getAnnotation(ArrayElement.class))); assertEquals(Integer.MAX_VALUE, JsdUtil.getMaxOccurs(ArrayLoop.class.getAnnotation(StringElement.class))); assertEquals(Integer.MAX_VALUE, JsdUtil.getMaxOccurs(ArrayLoop.class.getAnnotation(NumberElement.class))); assertEquals(Integer.MAX_VALUE, JsdUtil.getMaxOccurs(ArrayLoop.class.getAnnotation(BooleanElement.class))); assertEquals(Integer.MAX_VALUE, JsdUtil.getMaxOccurs(ArrayAny.class.getAnnotation(AnyElements.class).value()[0])); }