ottlinger commented on code in PR #233:
URL: https://github.com/apache/creadur-rat/pull/233#discussion_r1555625327


##########
apache-rat-core/src/main/java/org/apache/rat/analysis/IHeaderMatcher.java:
##########
@@ -110,10 +71,39 @@ public String toString() {
     interface Builder {
         /**
          * Build the IHeaderMatcher.
+         * 
+         * Implementations of this interface should return a specific child 
class of IHeaderMatcher.
+         * 
          * @return a new IHeaderMatcher.
          */
         IHeaderMatcher build();
 
+        /**
+         * Gets the class that is build by this builder.
+         * @return The class that is build by this builder.
+         */
+        default Class<?> builtClass() throws SecurityException {
+            try {
+                return this.getClass().getMethod("build").getReturnType();
+            } catch (NoSuchMethodException | SecurityException e) {
+                throw new IllegalStateException("the 'build' method of the 
Builder interface must alwasy be public");
+            }
+        }
+
+        /**
+         * Gets the Description for this builder.
+         * @return The description of the builder 
+         */
+        default Description getDescription() {
+            Class<?> clazz = builtClass();
+            if (clazz == IHeaderMatcher.class) {
+                throw new ImplementationException(String.format(
+                        "Class %s must implement built() method to return a 
child class of IHeaderMatcher", 

Review Comment:
   typo: build()?



##########
apache-rat-core/src/main/java/org/apache/rat/analysis/IHeaderMatcher.java:
##########
@@ -110,10 +71,39 @@ public String toString() {
     interface Builder {
         /**
          * Build the IHeaderMatcher.
+         * 
+         * Implementations of this interface should return a specific child 
class of IHeaderMatcher.
+         * 
          * @return a new IHeaderMatcher.
          */
         IHeaderMatcher build();
 
+        /**
+         * Gets the class that is build by this builder.
+         * @return The class that is build by this builder.
+         */
+        default Class<?> builtClass() throws SecurityException {
+            try {
+                return this.getClass().getMethod("build").getReturnType();
+            } catch (NoSuchMethodException | SecurityException e) {
+                throw new IllegalStateException("the 'build' method of the 
Builder interface must alwasy be public");
+            }
+        }
+
+        /**
+         * Gets the Description for this builder.
+         * @return The description of the builder 
+         */
+        default Description getDescription() {
+            Class<?> clazz = builtClass();
+            if (clazz == IHeaderMatcher.class) {
+                throw new ImplementationException(String.format(
+                        "Class %s must implement built() method to return a 
child class of IHeaderMatcher", 

Review Comment:
   typo: build()/buildMap()?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@creadur.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to