CommentUtil { @Deprecated public static String javadocContentAfter(String text, int position) { if (text == null || position > text.length()) { return null; } int endPos = text.indexOf('\n', position); if (endPos < 0) { endPos = text.length(); } if (StringUtils.isNotBlank(text.substring(position, endPos))) { return text.substring(position, endPos).trim(); } if (text.indexOf('@', endPos) >= 0) { return null; } int nextEndPos = text.indexOf('\n', endPos + 1); if (StringUtils.isNotBlank(text.substring(endPos, nextEndPos))) { return text.substring(endPos, nextEndPos).trim(); } return null; } private  CommentUtil(); @Deprecated // will be removed with PMD 7.0.0 static String wordAfter(String text, int position); @Deprecated // will be removed with PMD 7.0.0 static String javadocContentAfter(String text, int position); @Deprecated // will be removed with PMD 7.0.0 static Map<String, Integer> javadocTagsIn(String comment); @Deprecated // will be removed with PMD 7.0.0 static List<String> multiLinesIn(String comment); @Deprecated // will be removed with PMD 7.0.0 static List<String> trim(List<String> lines);  }
@Test public void testJavadocAfter() { String javadocContentAfter = CommentUtil.javadocContentAfter("@param param1 The Description\n", "@param param1".length()); Assert.assertEquals("The Description", javadocContentAfter); }
@Test public void testJavadocAfterOutOfBounds() { String javadocContentAfter = CommentUtil.javadocContentAfter("@param param1 The Description\n", Integer.MAX_VALUE); Assert.assertNull(javadocContentAfter); }
@Test public void testJavadocAfterNull() { String javadocContentAfter = CommentUtil.javadocContentAfter(null, 0); Assert.assertNull(javadocContentAfter); }