Skip to content

Commit

Permalink
Hierarchy of DMNModelInstrumentedBase. (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarilabs authored and etirelli committed Oct 18, 2016
1 parent dd39960 commit 1e19e21
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,27 @@
import org.kie.dmn.feel.model.v1_1.DMNElement;

public abstract class DMNElementConverter
extends DMNBaseConverter {
extends DMNModelInstrumentedBaseConverter {
public static final String ID = "id";
public static final String LABEL = "label";
public static final String DESCRIPTION = "description";

public DMNElementConverter(XStream xstream) {
super( xstream.getMapper() );
super( xstream );
}

@Override
protected void assignChildElement(Object parent, String nodeName, Object child) {
if ( DESCRIPTION.equals( nodeName ) && child instanceof String ) {
((DMNElement) parent).setDescription( (String) child );
} else {
super.assignChildElement(parent, nodeName, child);
}
}

@Override
protected void assignAttributes(HierarchicalStreamReader reader, Object parent) {
super.assignAttributes(reader, parent);
String id = reader.getAttribute( ID );
String label = reader.getAttribute( LABEL );

Expand All @@ -53,15 +56,15 @@ protected void assignAttributes(HierarchicalStreamReader reader, Object parent)

@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
// there is no call to super as super is an abstract method.
super.writeChildren(writer, context, parent);
DMNElement e = (DMNElement) parent;

if (e.getDescription() !=null) writeChildrenNodeAsValue(writer, context, e.getDescription(), DESCRIPTION);
// TODO what about DMNElement.ExtensionElements extensionElements;
}
@Override
protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) {
// there is no call to super as super is an abstract method.
super.writeAttributes(writer, parent);
DMNElement e = (DMNElement) parent;

if (e.getId() != null) writer.addAttribute( ID , e.getId() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@

package org.kie.dmn.feel.model.v1_1;

public class DMNModelInstrumentedBase {
public abstract class DMNModelInstrumentedBase {

}

0 comments on commit 1e19e21

Please sign in to comment.