<commit_before>package org.team2471.frc.lib.motion_profiling;

import com.squareup.moshi.JsonAdapter;
import com.squareup.moshi.Moshi;
import edu.wpi.first.networktables.NetworkTable;
import edu.wpi.first.networktables.NetworkTableEntry;
import edu.wpi.first.networktables.NetworkTableInstance;
import java.util.HashMap;
import java.util.Map;

public class Autonomi {

    public MotionRobot motionRobot;
    public Map<String, Autonomous> mapAutonomous = new HashMap<>();

    static Moshi moshi = new Moshi.Builder().build();
    static JsonAdapter<Autonomi> jsonAdapter = moshi.adapter(Autonomi.class).indent("\t");
    private static NetworkTableInstance networkTableInstance = NetworkTableInstance.create();

    public Autonomous get(String name) {
        return mapAutonomous.get(name);
    }

    public void put(Autonomous autonomous) {
        mapAutonomous.put(autonomous.name, autonomous);
    }

    public Path2D getPath(String autoName, String pathName) {
        Autonomous autonomous = get(autoName);
        return autonomous.get(pathName);
    }

    public String toJsonString() {
        String json = jsonAdapter.toJson(this);
        System.out.println(json);
        return json;
    }

    static public Autonomi fromJsonString(String json) {
        Autonomi autonomi = null;
        try {
            autonomi = jsonAdapter.fromJson(json);
        } catch (Exception e) {
            System.out.println("Constructing Autonomi class from json failed.");
            return null;
        }

        if (autonomi != null)
            autonomi.fixUpTailAndPrevPointers();

        return autonomi;
    }

    private void fixUpTailAndPrevPointers() {
        for (Map.Entry<String, Autonomous> entry : mapAutonomous.entrySet()) {
            entry.getValue().fixUpTailAndPrevPointers();
        }
    }

    public void publishToNetworkTables(NetworkTableInstance networkTableInstance) {
        String json = toJsonString();
        NetworkTable table = networkTableInstance.getTable("PathVisualizer");
        NetworkTableEntry entry = table.getEntry("Autonomi");
        entry.setString(json);
    }
}<commit_msg>Don't print entire json string on every conversion.<commit_after>package org.team2471.frc.lib.motion_profiling;

import com.squareup.moshi.JsonAdapter;
import com.squareup.moshi.Moshi;
import edu.wpi.first.networktables.NetworkTable;
import edu.wpi.first.networktables.NetworkTableEntry;
import edu.wpi.first.networktables.NetworkTableInstance;
import java.util.HashMap;
import java.util.Map;

public class Autonomi {

    public MotionRobot motionRobot;
    public Map<String, Autonomous> mapAutonomous = new HashMap<>();

    static Moshi moshi = new Moshi.Builder().build();
    static JsonAdapter<Autonomi> jsonAdapter = moshi.adapter(Autonomi.class).indent("\t");
    private static NetworkTableInstance networkTableInstance = NetworkTableInstance.create();

    public Autonomous get(String name) {
        return mapAutonomous.get(name);
    }

    public void put(Autonomous autonomous) {
        mapAutonomous.put(autonomous.name, autonomous);
    }

    public Path2D getPath(String autoName, String pathName) {
        Autonomous autonomous = get(autoName);
        return autonomous.get(pathName);
    }

    public String toJsonString() {
        String json = jsonAdapter.toJson(this);
        //System.out.println(json);
        return json;
    }

    static public Autonomi fromJsonString(String json) {
        Autonomi autonomi = null;
        try {
            autonomi = jsonAdapter.fromJson(json);
        } catch (Exception e) {
            System.out.println("Constructing Autonomi class from json failed.");
            return null;
        }

        if (autonomi != null)
            autonomi.fixUpTailAndPrevPointers();

        return autonomi;
    }

    private void fixUpTailAndPrevPointers() {
        for (Map.Entry<String, Autonomous> entry : mapAutonomous.entrySet()) {
            entry.getValue().fixUpTailAndPrevPointers();
        }
    }

    public void publishToNetworkTables(NetworkTableInstance networkTableInstance) {
        String json = toJsonString();
        NetworkTable table = networkTableInstance.getTable("PathVisualizer");
        NetworkTableEntry entry = table.getEntry("Autonomi");
        entry.setString(json);
    }
}
{'fraction_non_alphanumeric': 0.0962962962962963, 'fraction_numerical': 0.0023148148148148147, 'mean_word_length': 3.17487922705314, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3019943', 'n_tokens_mistral': 1259, 'n_tokens_neox': 1200, 'n_words': 257}