Permalink
Browse files

Added check for detecting abstract Adapters.

  • Loading branch information...
1 parent 28ac637 commit 858d664c8b4b417a75e1293bba30b998e2b7a95c @aroemers committed Nov 6, 2012
Showing with 10 additions and 1 deletion.
  1. +1 −1 src-java/test/adapter/SubBtoA.java
  2. +4 −0 src/gluer/logic.clj
  3. +5 −0 src/gluer/resources.clj
@@ -6,7 +6,7 @@
import test.modelb.SubSubB;
@Adapter
-public class SubBtoA implements A {
+public abstract class SubBtoA implements A {
private SubB adaptee;
View
@@ -42,6 +42,9 @@
(def adapter-not-statically-accesible
"Adapter %s is not statically accessible. Make sure it is a top-level class, or a static inner class.")
+(def adapter-not-concrete
+ "Adapter %s is not a concrete class (it is abstract or an interface).")
+
(defn format-issue
[message file-name line-nr]
(format "%s:%s %s" file-name line-nr message))
@@ -139,6 +142,7 @@
(when (empty? (:adapts-to data)) (format adapts-to-nothing-error name))
(when (empty? (:adapts-from data)) (format adapts-from-nothing-error name))
(when-not (r/public? ctclass) (format adapter-not-public name))
+ (when (r/abstract? ctclass) (format adapter-not-concrete name))
(when (and (r/inner? ctclass) (not (r/static? ctclass)))
(format adapter-not-statically-accesible name)))))]
(-> (reduce check-adapter {} adapter-library)
View
@@ -72,6 +72,11 @@
[ctclass]
(Modifier/isStatic (modifiers ctclass)))
+(defn abstract?
+ "Returns true if the supplied class is an abstract class, false otherwise."
+ [ctclass]
+ (Modifier/isAbstract (modifiers ctclass)))
+
(def supertypes-of
"A function that returns a set of the names of the direct supertypes
(classes and interfaces) of the supplied class. The function is memoized and

0 comments on commit 858d664

Please sign in to comment.