This is an automated email from the ASF dual-hosted git repository.

veithen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ws-axiom.git


The following commit(s) were added to refs/heads/master by this push:
     new b3e6d13ac Replace getInterface() with newInstance(NodeFactory) using 
NodeFactory2
b3e6d13ac is described below

commit b3e6d13ac039d166d07c5d0b51fe6ab4451da72f
Author: Copilot <[email protected]>
AuthorDate: Sun May 24 14:31:54 2026 +0100

    Replace getInterface() with newInstance(NodeFactory) using NodeFactory2
    
    Co-authored-by: Andreas Veithen-Knowles <[email protected]>
---
 .../java/org/apache/axiom/core/NodeFactory2.java   |  3 ++
 .../main/java/org/apache/axiom/core/NodeType.java  | 37 +++++++++++-----------
 .../java/org/apache/axiom/dom/DOMNodeFactory.java  |  1 +
 .../axiom/om/impl/common/AxiomSemantics.java       |  2 +-
 4 files changed, 24 insertions(+), 19 deletions(-)

diff --git 
a/mixins/core-mixins/src/main/java/org/apache/axiom/core/NodeFactory2.java 
b/mixins/core-mixins/src/main/java/org/apache/axiom/core/NodeFactory2.java
index 71389aa71..b7410253e 100644
--- a/mixins/core-mixins/src/main/java/org/apache/axiom/core/NodeFactory2.java
+++ b/mixins/core-mixins/src/main/java/org/apache/axiom/core/NodeFactory2.java
@@ -60,6 +60,9 @@ public interface NodeFactory2 {
     @FactoryMethod
     CoreEntityReference createEntityReference();
 
+    @FactoryMethod
+    CoreDocumentFragment createDocumentFragment();
+
     /**
      * Create the namespace helper object that will be passed to {@link
      * CoreNSAwareNamedNode#initName(String, String, String, Object)}.
diff --git 
a/mixins/core-mixins/src/main/java/org/apache/axiom/core/NodeType.java 
b/mixins/core-mixins/src/main/java/org/apache/axiom/core/NodeType.java
index 225882e80..425e60c94 100644
--- a/mixins/core-mixins/src/main/java/org/apache/axiom/core/NodeType.java
+++ b/mixins/core-mixins/src/main/java/org/apache/axiom/core/NodeType.java
@@ -19,46 +19,47 @@
 package org.apache.axiom.core;
 
 import java.util.EnumSet;
+import java.util.function.Function;
 
 public enum NodeType {
     /** The node is a {@link CoreDocument}. */
-    DOCUMENT(CoreDocument.class),
+    DOCUMENT(NodeFactory2::createDocument),
 
     /** The node is a {@link CoreDocumentTypeDeclaration}. */
-    DOCUMENT_TYPE_DECLARATION(CoreDocumentTypeDeclaration.class),
+    DOCUMENT_TYPE_DECLARATION(NodeFactory2::createDocumentTypeDeclaration),
 
     /** The node is a {@link CoreNSUnawareElement}. */
-    NS_UNAWARE_ELEMENT(CoreNSUnawareElement.class),
+    NS_UNAWARE_ELEMENT(NodeFactory2::createNSUnawareElement),
 
     /** The node is a {@link CoreNSAwareElement}. */
-    NS_AWARE_ELEMENT(CoreNSAwareElement.class),
+    NS_AWARE_ELEMENT(NodeFactory2::createNSAwareElement),
 
     /** The node is a {@link CoreNSUnawareAttribute}. */
-    NS_UNAWARE_ATTRIBUTE(CoreNSUnawareAttribute.class),
+    NS_UNAWARE_ATTRIBUTE(NodeFactory2::createNSUnawareAttribute),
 
     /** The node is a {@link CoreNSAwareAttribute}. */
-    NS_AWARE_ATTRIBUTE(CoreNSAwareAttribute.class),
+    NS_AWARE_ATTRIBUTE(NodeFactory2::createNSAwareAttribute),
 
     /** The node is a {@link CoreNamespaceDeclaration}. */
-    NAMESPACE_DECLARATION(CoreNamespaceDeclaration.class),
+    NAMESPACE_DECLARATION(NodeFactory2::createNamespaceDeclaration),
 
     /** The node is a {@link CoreProcessingInstruction}. */
-    PROCESSING_INSTRUCTION(CoreProcessingInstruction.class),
+    PROCESSING_INSTRUCTION(NodeFactory2::createProcessingInstruction),
 
     /** The node is a {@link CoreDocumentFragment}. */
-    DOCUMENT_FRAGMENT(CoreDocumentFragment.class),
+    DOCUMENT_FRAGMENT(NodeFactory2::createDocumentFragment),
 
     /** The node is a {@link CoreCharacterDataNode}. */
-    CHARACTER_DATA(CoreCharacterDataNode.class),
+    CHARACTER_DATA(NodeFactory2::createCharacterDataNode),
 
     /** The node is a {@link CoreComment}. */
-    COMMENT(CoreComment.class),
+    COMMENT(NodeFactory2::createComment),
 
     /** The node is a {@link CoreCDATASection}. */
-    CDATA_SECTION(CoreCDATASection.class),
+    CDATA_SECTION(NodeFactory2::createCDATASection),
 
     /** The node is a {@link CoreEntityReference}. */
-    ENTITY_REFERENCE(CoreEntityReference.class);
+    ENTITY_REFERENCE(NodeFactory2::createEntityReference);
 
     static {
         // TODO: add missing node types here (once we have tests that exercise 
the code)
@@ -87,15 +88,15 @@ public enum NodeType {
         NS_UNAWARE_ELEMENT.allowedChildTypes = s;
     }
 
-    private final Class<? extends CoreNode> iface;
+    private final Function<NodeFactory2, CoreNode> factory2Function;
     private EnumSet<NodeType> allowedChildTypes;
 
-    private NodeType(Class<? extends CoreNode> iface) {
-        this.iface = iface;
+    private NodeType(Function<NodeFactory2, CoreNode> factory2Function) {
+        this.factory2Function = factory2Function;
     }
 
-    public Class<? extends CoreNode> getInterface() {
-        return iface;
+    public CoreNode newInstance(NodeFactory factory) {
+        return factory2Function.apply(factory.getFactory2());
     }
 
     public boolean isChildTypeAllowed(NodeType childType) {
diff --git 
a/mixins/dom-mixins/src/main/java/org/apache/axiom/dom/DOMNodeFactory.java 
b/mixins/dom-mixins/src/main/java/org/apache/axiom/dom/DOMNodeFactory.java
index 8c8434b40..43151ae31 100644
--- a/mixins/dom-mixins/src/main/java/org/apache/axiom/dom/DOMNodeFactory.java
+++ b/mixins/dom-mixins/src/main/java/org/apache/axiom/dom/DOMNodeFactory.java
@@ -74,5 +74,6 @@ public interface DOMNodeFactory extends NodeFactory2, 
DOMImplementation {
     DOMComment createComment();
 
     @FactoryMethod
+    @Override
     DOMDocumentFragment createDocumentFragment();
 }
diff --git 
a/mixins/om-mixins/src/main/java/org/apache/axiom/om/impl/common/AxiomSemantics.java
 
b/mixins/om-mixins/src/main/java/org/apache/axiom/om/impl/common/AxiomSemantics.java
index 64f98dce5..6cb7943d2 100644
--- 
a/mixins/om-mixins/src/main/java/org/apache/axiom/om/impl/common/AxiomSemantics.java
+++ 
b/mixins/om-mixins/src/main/java/org/apache/axiom/om/impl/common/AxiomSemantics.java
@@ -74,7 +74,7 @@ public final class AxiomSemantics implements Semantics {
             } else if (options != null && options.isCopyOMDataSources() && 
node instanceof AxiomSourcedElement) {
                 return ((AxiomNodeFactory) 
factory.getFactory2()).createSourcedElement();
             } else {
-                return 
factory.createNode(node.coreGetNodeType().getInterface());
+                return node.coreGetNodeType().newInstance(factory);
             }
         }
 

Reply via email to