1818import java .util .regex .Matcher ;
1919import java .util .regex .Pattern ;
2020
21+ import org .apache .commons .lang3 .StringUtils ;
2122import org .eclipse .core .runtime .IProgressMonitor ;
2223import org .eclipse .jdt .core .IMethod ;
2324import org .eclipse .jdt .core .IPackageFragmentRoot ;
@@ -232,7 +233,7 @@ public static void resolveSingleType(IJavaProject javaProject, String typeName,
232233 * @return true if the type is from a common JDK package
233234 */
234235 private static boolean isCommonJdkType (String typeName ) {
235- if (typeName == null || typeName . isEmpty ( )) {
236+ if (StringUtils . isBlank ( typeName )) {
236237 return false ;
237238 }
238239
@@ -789,7 +790,7 @@ public static String generateClassDescription(org.eclipse.jdt.core.IType type, S
789790 description .append ("Signature: " ).append (signature ).append ("\n \n " );
790791
791792 // === 2. JavaDoc (inserted after signature) ===
792- if (isNotEmpty (javadoc )) {
793+ if (StringUtils . isNotBlank (javadoc )) {
793794 description .append ("JavaDoc:\n " ).append (javadoc ).append ("\n \n " );
794795 }
795796
@@ -897,7 +898,7 @@ private static String extractRelevantJavaDocContent(org.eclipse.jdt.core.IType t
897898 }
898899 rawJavadoc = type .getCompilationUnit ().getSource ().substring (javadocRange .getOffset (), javadocRange .getOffset () + javadocRange .getLength ());
899900
900- if (! isNotEmpty (rawJavadoc )) {
901+ if (StringUtils . isBlank (rawJavadoc )) {
901902 return "" ;
902903 }
903904
@@ -911,7 +912,7 @@ private static String extractRelevantJavaDocContent(org.eclipse.jdt.core.IType t
911912
912913 // === High Priority: Extract class description text (first paragraph) ===
913914 String description = extractClassDescription (cleanedJavadoc );
914- if (isNotEmpty (description )) {
915+ if (StringUtils . isNotBlank (description )) {
915916 result .append ("Description:\n " ).append (description ).append ("\n \n " );
916917 }
917918
@@ -920,7 +921,7 @@ private static String extractRelevantJavaDocContent(org.eclipse.jdt.core.IType t
920921 Matcher markdownMatcher = MARKDOWN_CODE_PATTERN .matcher (rawJavadoc );
921922 while (markdownMatcher .find ()) {
922923 String code = markdownMatcher .group (1 ).trim ();
923- if (isNotEmpty (code ) && seenCodeSnippets .add (code )) {
924+ if (StringUtils . isNotBlank (code ) && seenCodeSnippets .add (code )) {
924925 result .append ("```java\n " ).append (code ).append ("\n ```\n \n " );
925926 }
926927 }
@@ -930,7 +931,7 @@ private static String extractRelevantJavaDocContent(org.eclipse.jdt.core.IType t
930931 Matcher preMatcher = HTML_PRE_PATTERN .matcher (cleanedJavadoc );
931932 while (preMatcher .find ()) {
932933 String code = preMatcher .group (1 ).replaceAll ("(?i)<code[^>]*>" , "" ).replaceAll ("(?i)</code>" , "" ).trim ();
933- if (isNotEmpty (code ) && seenCodeSnippets .add (code )) {
934+ if (StringUtils . isNotBlank (code ) && seenCodeSnippets .add (code )) {
934935 result .append ("```java\n " ).append (code ).append ("\n ```\n \n " );
935936 }
936937 }
@@ -940,7 +941,7 @@ private static String extractRelevantJavaDocContent(org.eclipse.jdt.core.IType t
940941 while (codeMatcher .find ()) {
941942 String code = codeMatcher .group (1 ).trim ();
942943 // Use HashSet for O(1) duplicate checking
943- if (isNotEmpty (code ) && seenCodeSnippets .add (code )) {
944+ if (StringUtils . isNotBlank (code ) && seenCodeSnippets .add (code )) {
944945 result .append ("```java\n " ).append (code ).append ("\n ```\n \n " );
945946 }
946947 }
@@ -958,7 +959,7 @@ private static String extractRelevantJavaDocContent(org.eclipse.jdt.core.IType t
958959 * Returns the first paragraph of descriptive text, limited to reasonable length.
959960 */
960961 private static String extractClassDescription (String cleanedJavadoc ) {
961- if (cleanedJavadoc == null || cleanedJavadoc . isEmpty ( )) {
962+ if (StringUtils . isBlank ( cleanedJavadoc )) {
962963 return "" ;
963964 }
964965
@@ -989,7 +990,7 @@ private static String extractClassDescription(String cleanedJavadoc) {
989990 * Clean up raw JavaDoc comment by removing comment markers and asterisks
990991 */
991992 private static String cleanJavadocComment (String rawJavadoc ) {
992- if (rawJavadoc == null || rawJavadoc . isEmpty ( )) {
993+ if (StringUtils . isBlank ( rawJavadoc )) {
993994 return "" ;
994995 }
995996
@@ -1029,7 +1030,7 @@ private static String cleanJavadocComment(String rawJavadoc) {
10291030 * Convert HTML entities to their plain text equivalents
10301031 */
10311032 private static String convertHtmlEntities (String text ) {
1032- if (text == null || text . isEmpty ( )) {
1033+ if (StringUtils . isBlank ( text )) {
10331034 return text ;
10341035 }
10351036 return text .replace (" " , " " )
@@ -1048,7 +1049,7 @@ private static String convertHtmlEntities(String text) {
10481049 * Preserves line breaks for block-level tags like <p>, <br>, <div>.
10491050 */
10501051 private static String removeHtmlTags (String text ) {
1051- if (text == null || text . isEmpty ( )) {
1052+ if (StringUtils . isBlank ( text )) {
10521053 return text ;
10531054 }
10541055
@@ -1080,7 +1081,7 @@ private static String extractMethodJavaDocSummary(IMethod method) {
10801081 String rawJavadoc = method .getCompilationUnit ().getSource ()
10811082 .substring (javadocRange .getOffset (), javadocRange .getOffset () + javadocRange .getLength ());
10821083
1083- if (! isNotEmpty (rawJavadoc )) {
1084+ if (StringUtils . isBlank (rawJavadoc )) {
10841085 return "" ;
10851086 }
10861087
@@ -1098,7 +1099,7 @@ private static String extractMethodJavaDocSummary(IMethod method) {
10981099 * Extract the main description part from JavaDoc (before @tags)
10991100 */
11001101 private static String extractJavadocDescription (String cleanedJavadoc ) {
1101- if (cleanedJavadoc == null || cleanedJavadoc . isEmpty ( )) {
1102+ if (StringUtils . isBlank ( cleanedJavadoc )) {
11021103 return "" ;
11031104 }
11041105
@@ -1131,7 +1132,7 @@ private static String extractJavadocDescription(String cleanedJavadoc) {
11311132 * Get the first sentence or limit the text to maxLength characters
11321133 */
11331134 private static String getFirstSentenceOrLimit (String text , int maxLength ) {
1134- if (text == null || text . isEmpty ( )) {
1135+ if (StringUtils . isBlank ( text )) {
11351136 return "" ;
11361137 }
11371138
@@ -1201,7 +1202,7 @@ private static String extractFieldJavaDocSummary(org.eclipse.jdt.core.IField fie
12011202 String rawJavadoc = field .getCompilationUnit ().getSource ()
12021203 .substring (javadocRange .getOffset (), javadocRange .getOffset () + javadocRange .getLength ());
12031204
1204- if (! isNotEmpty (rawJavadoc )) {
1205+ if (StringUtils . isBlank (rawJavadoc )) {
12051206 return "" ;
12061207 }
12071208
@@ -1439,7 +1440,7 @@ private static String generateMethodSignatureInternal(IMethod method, boolean si
14391440 // Add JavaDoc if requested
14401441 if (includeJavadoc ) {
14411442 String javadocSummary = extractMethodJavaDocSummary (method );
1442- if (javadocSummary != null && ! javadocSummary . isEmpty ( )) {
1443+ if (StringUtils . isNotBlank ( javadocSummary )) {
14431444 return "// " + javadocSummary + "\n " + sb .toString ();
14441445 }
14451446 }
@@ -1494,7 +1495,7 @@ private static String generateFieldSignatureInternal(org.eclipse.jdt.core.IField
14941495 // Add JavaDoc if not simplified
14951496 if (!simplified ) {
14961497 String javadocSummary = extractFieldJavaDocSummary (field );
1497- if (javadocSummary != null && ! javadocSummary . isEmpty ( )) {
1498+ if (StringUtils . isNotBlank ( javadocSummary )) {
14981499 return "// " + javadocSummary + "\n " + sb .toString ();
14991500 }
15001501 }
@@ -1505,10 +1506,4 @@ private static String generateFieldSignatureInternal(org.eclipse.jdt.core.IField
15051506 }
15061507 }
15071508
1508- /**
1509- * Utility method to check if a string is not empty or null
1510- */
1511- private static boolean isNotEmpty (String value ) {
1512- return value != null && !value .isEmpty ();
1513- }
15141509}
0 commit comments