cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject cxf-xjc-utils git commit: [CXFXJC-13] - The default value plugin will try to instantiate abstract classes
Date Mon, 31 Aug 2015 16:12:41 GMT
Repository: cxf-xjc-utils
Updated Branches:
  refs/heads/master c910d7614 -> 6533459d2


[CXFXJC-13] - The default value plugin will try to instantiate abstract classes


Project: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/commit/6533459d
Tree: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/tree/6533459d
Diff: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/diff/6533459d

Branch: refs/heads/master
Commit: 6533459d20c8122e684824ecd0aa3c2dcc2fc31a
Parents: c910d76
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Mon Aug 31 17:11:27 2015 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Mon Aug 31 17:11:27 2015 +0100

----------------------------------------------------------------------
 .../org/apache/cxf/xjc/dv/DefaultValuePlugin.java | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/blob/6533459d/dv/src/main/java/org/apache/cxf/xjc/dv/DefaultValuePlugin.java
----------------------------------------------------------------------
diff --git a/dv/src/main/java/org/apache/cxf/xjc/dv/DefaultValuePlugin.java b/dv/src/main/java/org/apache/cxf/xjc/dv/DefaultValuePlugin.java
index 077bcd8..e4bcb93 100644
--- a/dv/src/main/java/org/apache/cxf/xjc/dv/DefaultValuePlugin.java
+++ b/dv/src/main/java/org/apache/cxf/xjc/dv/DefaultValuePlugin.java
@@ -100,6 +100,15 @@ public class DefaultValuePlugin {
         return ret;
     }
 
+    private boolean isAbstract(Outline outline, FieldOutline field) {
+        for (ClassOutline classOutline : outline.getClasses()) {
+            if (classOutline.implClass == field.getRawType() 
+                && classOutline.implClass.isAbstract()) {
+                return true;
+            }
+        }
+        return false;
+    }
     
     private boolean containsDefaultValue(Outline outline, FieldOutline field) {
         ClassOutline fClass = null;
@@ -125,6 +134,10 @@ public class DefaultValuePlugin {
         return false;
     }
 
+    private boolean isElementRequired(XSParticle particle) {
+        return particle != null && getMinOccurs(particle) != 0 && getMaxOccurs(particle)
== 1;
+    }
+    
     private int getMinOccurs(XSParticle particle) {
         try {
             Number o = (Number)particle.getClass().getMethod("getMinOccurs").invoke(particle);
@@ -179,8 +192,9 @@ public class DefaultValuePlugin {
 
                 if (xsType != null 
                     && xsType.isComplexType()
-                    && ((containsDefaultValue(outline, f) && complexTypes)
-                        || (particle != null && getMinOccurs(particle) != 0 &&
getMaxOccurs(particle) == 1))) {
+                    && !isAbstract(outline, f)
+                    && ((complexTypes && containsDefaultValue(outline, f))

+                        || isElementRequired(particle))) {
                     String varName = f.getPropertyInfo().getName(false);
                     JFieldVar var = co.implClass.fields().get(varName);
                     if (var != null) {


Mime
View raw message