<commit_before>package org.jboss.as.console.client.tools.mapping;

import org.jboss.dmr.client.ModelNode;
import org.jboss.dmr.client.Property;

import java.util.LinkedList;
import java.util.List;

/**
 * @author <NAME>
 * @date 7/16/12
 */
public class DescriptionMapper {

    private ModelNode description;
    private ModelNode address;

    public DescriptionMapper(ModelNode address, ModelNode description) {
        this.address = address;
        this.description = description;
    }

    public interface Mapping {
        void onAttribute(String name, String description, String type, boolean required);
        void onOperation(String name, String description, List<RequestParameter> parameter, ResponseParameter response);
        void onChild(String name, String description);

        void onBegin();
        void onFinish();
    }

    public void map(Mapping mapping) {

        mapping.onBegin();

        if(description.hasDefined("attributes"))
        {

            final List<Property> properties = description.get("attributes").asPropertyList();

            if(!properties.isEmpty())
            {

                for(Property att : properties)
                {
                    final String name = att.getName();
                    final String description = att.getValue().get("description").asString();
                    final String type = att.getValue().get("type").asString();

                    final boolean required = att.getValue().hasDefined("required") ?
                            att.getValue().get("required").asBoolean() : false;

                    mapping.onAttribute(name, description, type, required);
                }

            }
        }


        if(description.hasDefined("operations"))
        {

            final List<Property> operations = description.get("operations").asPropertyList();

            if(!operations.isEmpty())
            {

                for(Property op : operations)
                {
                    final String opName = op.getName();
                    final String opDesc = op.getValue().get("description").asString();


                    List<RequestParameter> parameters = new LinkedList<RequestParameter>();
                    ResponseParameter response = null;

                    // parameters
                    if(op.getValue().hasDefined("request-properties"))
                    {
                        for(Property param : op.getValue().get("request-properties").asPropertyList())
                        {
                            final ModelNode value = param.getValue();
                            final String paramDesc = value.get("description").asString();
                            final String paramName = param.getName();
                            final String paramType = value.get("type").asString();
                            boolean required = false;
                            if(value.hasDefined("required"))
                            {
                                required = value.get("required").asBoolean();
                            }

                            parameters.add(
                                    new RequestParameter(
                                            paramDesc, paramName, paramType, required
                                    )
                            );
                        }
                    }

                    // response
                    if(op.getValue().hasDefined("reply-properties"))
                    {
                        final ModelNode reply = op.getValue().get("reply-properties");
                        final String replyDesc = reply.get("description").asString();
                        final String replyType = reply.get("type").asString();

                        response = new ResponseParameter(replyDesc, replyType);
                    }


                    mapping.onOperation(opName, opDesc, parameters, response);
                }

            }
        }

        if(description.hasDefined("children"))
        {
            final List<Property> children = description.get("children").asPropertyList();

            if(!children.isEmpty())
            {

                for(Property child : children)
                {
                    final String childName = child.getName();
                    final String childDesc = child.getValue().get("description").asString();
                    mapping.onChild(childName, childDesc);
                }

            }
        }

        mapping.onFinish();
    }
}
<commit_msg>description mapper consideres nillable meta data<commit_after>package org.jboss.as.console.client.tools.mapping;

import org.jboss.dmr.client.ModelNode;
import org.jboss.dmr.client.Property;

import java.util.LinkedList;
import java.util.List;

/**
 * @author <NAME>
 * @date 7/16/12
 */
public class DescriptionMapper {

    private ModelNode description;
    private ModelNode address;

    public DescriptionMapper(ModelNode address, ModelNode description) {
        this.address = address;
        this.description = description;
    }

    public interface Mapping {
        void onAttribute(String name, String description, String type, boolean required);
        void onOperation(String name, String description, List<RequestParameter> parameter, ResponseParameter response);
        void onChild(String name, String description);

        void onBegin();
        void onFinish();
    }

    public void map(Mapping mapping) {

        mapping.onBegin();

        if(description.hasDefined("attributes"))
        {

            final List<Property> properties = description.get("attributes").asPropertyList();

            if(!properties.isEmpty())
            {

                for(Property att : properties)
                {
                    final String name = att.getName();
                    final String description = att.getValue().get("description").asString();
                    final String type = att.getValue().get("type").asString();

                    final boolean required = att.getValue().hasDefined("required") ?
                            att.getValue().get("required").asBoolean() : false;

                    final boolean nillable = att.getValue().hasDefined("nillable") ?
                            att.getValue().get("nillable").asBoolean() : true;

                    mapping.onAttribute(name, description, type, !nillable||required);
                }

            }
        }


        if(description.hasDefined("operations"))
        {

            final List<Property> operations = description.get("operations").asPropertyList();

            if(!operations.isEmpty())
            {

                for(Property op : operations)
                {
                    final String opName = op.getName();
                    final String opDesc = op.getValue().get("description").asString();


                    List<RequestParameter> parameters = new LinkedList<RequestParameter>();
                    ResponseParameter response = null;

                    // parameters
                    if(op.getValue().hasDefined("request-properties"))
                    {
                        for(Property param : op.getValue().get("request-properties").asPropertyList())
                        {
                            final ModelNode value = param.getValue();
                            final String paramDesc = value.get("description").asString();
                            final String paramName = param.getName();
                            final String paramType = value.get("type").asString();
                            boolean required = false;
                            if(value.hasDefined("required"))
                            {
                                required = value.get("required").asBoolean();
                            }

                            parameters.add(
                                    new RequestParameter(
                                            paramDesc, paramName, paramType, required
                                    )
                            );
                        }
                    }

                    // response
                    if(op.getValue().hasDefined("reply-properties"))
                    {
                        final ModelNode reply = op.getValue().get("reply-properties");
                        final String replyDesc = reply.get("description").asString();
                        final String replyType = reply.get("type").asString();

                        response = new ResponseParameter(replyDesc, replyType);
                    }


                    mapping.onOperation(opName, opDesc, parameters, response);
                }

            }
        }

        if(description.hasDefined("children"))
        {
            final List<Property> children = description.get("children").asPropertyList();

            if(!children.isEmpty())
            {

                for(Property child : children)
                {
                    final String childName = child.getName();
                    final String childDesc = child.getValue().get("description").asString();
                    mapping.onChild(childName, childDesc);
                }

            }
        }

        mapping.onFinish();
    }
}

{'fraction_non_alphanumeric': 0.1002886774297017, 'fraction_numerical': 0.0010691756655618518, 'mean_word_length': 1.4064831489580654, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4943855', 'n_tokens_mistral': 2079, 'n_tokens_neox': 1917, 'n_words': 407}