<commit_before>/*
# Licensed Materials - Property of IBM
# Copyright IBM Corp. 2015  
 */
package com.ibm.streamsx.topology.builder;

import com.ibm.json.java.JSONObject;

/**
 * Utility methods for an operator represented as a JSON Object.
 *
 */
public class JOperator {
    
    /**
     * Programming model used to create the operator.
     */
    public static final String MODEL = "model";
    
    /**
     * Language for the operator within its {@link #MODEL}.
     */
    public static final String LANGUAGE = "language";
    
    public static final String MODEL_FUNCTIONAL = "functional";
    public static final String MODEL_SPL = "spl";
    
    public static final String LANGUAGE_JAVA = "java";
    public static final String LANGUAGE_CPP = "cpp";
    public static final String LANGUAGE_PYTHON = "python";
    public static final Object LANGUAGE_SPL = "spl";
      
    /**
     * JSON attribute for operator configuration.
     */
    public static final String CONFIG = "config"; 
    
    /**
     * Attribute for isolation region identifier.
     */
    public static final String PLACEMENT_ISOLATE_REGION_ID = "isolateRegion";

    /**
     * Attribute for an explicit colocation identifier.
     */
    public static final Object PLACEMENT_EXPLICIT_COLOCATE_ID = "explicitColocate";

    /**
     * Attribute for low latency region identifier.
     */
    public static final Object PLACEMENT_LOW_LATENCY_REGION_ID = "lowLatencyRegion";

    /**
     * Attribute for an resource tags, a list of tags.
     */
    public static final Object PLACEMENT_RESOURCE_TAGS = "resourceTags";


    
    /**
     * Get the config object, returning null if it has not been created.
     */
    public static JSONObject getConfig(final JSONObject op) {
        return (JSONObject) op.get(CONFIG);
    }
    
    public static boolean hasConfig(final JSONObject op) {
        JSONObject config = getConfig(op);
        return config != null && !config.isEmpty();
    }
    
    /**
     * Create the config object if it has not already been created.
     * @return A new or existing config object.
     */
    public static JSONObject createConfig(final JSONObject op) {
        JSONObject config = getConfig(op);
        if (config == null)
            op.put(CONFIG, config = new JSONObject());
        
        return config;
    }
    
    /**
     * Utility methods for the {@link JOperator#CONFIG} attribute
     * which is a JSON object containing arbitrary configuration items. <commit_msg>Use Strings for JSON property names<commit_after>/*
# Licensed Materials - Property of IBM
# Copyright IBM Corp. 2015  
 */
package com.ibm.streamsx.topology.builder;

import com.ibm.json.java.JSONObject;

/**
 * Utility methods for an operator represented as a JSON Object.
 *
 */
public class JOperator {
    
    /**
     * Programming model used to create the operator.
     */
    public static final String MODEL = "model";
    
    /**
     * Language for the operator within its {@link #MODEL}.
     */
    public static final String LANGUAGE = "language";
    
    public static final String MODEL_FUNCTIONAL = "functional";
    public static final String MODEL_SPL = "spl";
    
    public static final String LANGUAGE_JAVA = "java";
    public static final String LANGUAGE_CPP = "cpp";
    public static final String LANGUAGE_PYTHON = "python";
    public static final Object LANGUAGE_SPL = "spl";
      
    /**
     * JSON attribute for operator configuration.
     */
    public static final String CONFIG = "config"; 
    
    /**
     * Attribute for isolation region identifier.
     */
    public static final String PLACEMENT_ISOLATE_REGION_ID = "isolateRegion";

    /**
     * Attribute for an explicit colocation identifier.
     */
    public static final String PLACEMENT_EXPLICIT_COLOCATE_ID = "explicitColocate";

    /**
     * Attribute for low latency region identifier.
     */
    public static final String PLACEMENT_LOW_LATENCY_REGION_ID = "lowLatencyRegion";

    /**
     * Attribute for an resource tags, a list of tags.
     */
    public static final String PLACEMENT_RESOURCE_TAGS = "resourceTags";


    
    /**
     * Get the config object, returning null if it has not been created.
     */
    public static JSONObject getConfig(final JSONObject op) {
        return (JSONObject) op.get(CONFIG);
    }
    
    public static boolean hasConfig(final JSONObject op) {
        JSONObject config = getConfig(op);
        return config != null && !config.isEmpty();
    }
    
    /**
     * Create the config object if it has not already been created.
     * @return A new or existing config object.
     */
    public static JSONObject createConfig(final JSONObject op) {
        JSONObject config = getConfig(op);
        if (config == null)
            op.put(CONFIG, config = new JSONObject());
        
        return config;
    }
    
    /**
     * Utility methods for the {@link JOperator#CONFIG} attribute
     * which is a JSON object containing arbitrary configuration items. 
{'fraction_non_alphanumeric': 0.08422725466825585, 'fraction_numerical': 0.0015891934843067143, 'mean_word_length': 2.5507757404795486, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '11618', 'n_tokens_mistral': 1396, 'n_tokens_neox': 1357, 'n_words': 479}