<commit_before>package org.batfish.question.bgpsessionstatus;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nonnull;
import org.batfish.datamodel.Ip;
import org.batfish.datamodel.Prefix;
import org.batfish.datamodel.answers.Schema;
import org.batfish.datamodel.pojo.Node;
import org.batfish.datamodel.questions.DisplayHints;
import org.batfish.datamodel.questions.Question;
import org.batfish.datamodel.table.ColumnMetadata;
import org.batfish.datamodel.table.Row;
import org.batfish.datamodel.table.TableAnswerElement;
import org.batfish.datamodel.table.TableMetadata;
import org.batfish.question.bgpsessionstatus.BgpSessionInfo.SessionStatus;
import org.batfish.question.bgpsessionstatus.BgpSessionInfo.SessionType;

public class BgpSessionStatusAnswerElement extends TableAnswerElement {

  public static final String COL_CONFIGURED_STATUS = "configuredStatus";
  public static final String COL_ESTABLISHED_NEIGHBORS = "establishedNeighbors";
  public static final String COL_LOCAL_IP = "localIp";
  public static final String COL_NODE = "node";
  public static final String COL_ON_LOOPBACK = "onLoopback";
  public static final String COL_REMOTE_NODE = "remoteNode";
  public static final String COL_REMOTE_PREFIX = "remotePrefix";
  public static final String COL_SESSION_TYPE = "sessionType";
  public static final String COL_VRF_NAME = "vrfName";

  @JsonCreator
  public BgpSessionStatusAnswerElement(
      @Nonnull @JsonProperty(PROP_METADATA) TableMetadata tableMetadata) {
    super(tableMetadata);
  }

  public static TableMetadata createMetadata(Question question) {
    Map<String, ColumnMetadata> columnMetadata = new HashMap<>();
    columnMetadata.put(
        COL_CONFIGURED_STATUS, new ColumnMetadata(Schema.STRING, "Configured status", false, true));
    columnMetadata.put(
        COL_ESTABLISHED_NEIGHBORS,
        new ColumnMetadata(
            Schema.INTEGER,
            "Number of neighbors with whom BGP session was established",
            false,
            true));
    columnMetadata.put(
        COL_LOCAL_IP, new ColumnMetadata(Schema.IP, "The local IP of the session", false, false));
    columnMetadata.put(
        COL_NODE,
        new ColumnMetadata(Schema.NODE, "Node where this session is configured", true, false));
    columnMetadata.put(
        COL_ON_LOOPBACK,
        new ColumnMetadata(
            Schema.BOOLEAN,
            "Whether the session was established on loopback interface",
            false,
            true));
    columnMetadata.put(
        COL_REMOTE_NODE,
        new ColumnMetadata(Schema.NODE, "Remote node for this session", false, false));
    columnMetadata.put(
        COL_REMOTE_PREFIX,
        new ColumnMetadata(Schema.PREFIX, "Remote prefix for this session", true, false));
    columnMetadata.put(
        COL_SESSION_TYPE,
        new ColumnMetadata(Schema.STRING, "The type of this session", false, false));
    columnMetadata.put(
        COL_VRF_NAME,
        new ColumnMetadata(
            Schema.STRING, "The VRF in which this session is configured", true, false));

    DisplayHints dhints = question.getDisplayHints();
    if (dhints == null) {
      dhints = new DisplayHints();
      dhints.setTextDesc(
          String.format(
              "On ${%s} session ${%s}:${%s} has configured status ${%s}.",
              COL_NODE,
              COL_VRF_NAME,
              COL_REMOTE_PREFIX,
              COL_CONFIGURED_STATUS,
              COL_ESTABLISHED_NEIGHBORS));
    }<commit_msg>BgpSessionStatusAnswerElement: remove unused format var (#1347)<commit_after>package org.batfish.question.bgpsessionstatus;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nonnull;
import org.batfish.datamodel.Ip;
import org.batfish.datamodel.Prefix;
import org.batfish.datamodel.answers.Schema;
import org.batfish.datamodel.pojo.Node;
import org.batfish.datamodel.questions.DisplayHints;
import org.batfish.datamodel.questions.Question;
import org.batfish.datamodel.table.ColumnMetadata;
import org.batfish.datamodel.table.Row;
import org.batfish.datamodel.table.TableAnswerElement;
import org.batfish.datamodel.table.TableMetadata;
import org.batfish.question.bgpsessionstatus.BgpSessionInfo.SessionStatus;
import org.batfish.question.bgpsessionstatus.BgpSessionInfo.SessionType;

public class BgpSessionStatusAnswerElement extends TableAnswerElement {

  public static final String COL_CONFIGURED_STATUS = "configuredStatus";
  public static final String COL_ESTABLISHED_NEIGHBORS = "establishedNeighbors";
  public static final String COL_LOCAL_IP = "localIp";
  public static final String COL_NODE = "node";
  public static final String COL_ON_LOOPBACK = "onLoopback";
  public static final String COL_REMOTE_NODE = "remoteNode";
  public static final String COL_REMOTE_PREFIX = "remotePrefix";
  public static final String COL_SESSION_TYPE = "sessionType";
  public static final String COL_VRF_NAME = "vrfName";

  @JsonCreator
  public BgpSessionStatusAnswerElement(
      @Nonnull @JsonProperty(PROP_METADATA) TableMetadata tableMetadata) {
    super(tableMetadata);
  }

  public static TableMetadata createMetadata(Question question) {
    Map<String, ColumnMetadata> columnMetadata = new HashMap<>();
    columnMetadata.put(
        COL_CONFIGURED_STATUS, new ColumnMetadata(Schema.STRING, "Configured status", false, true));
    columnMetadata.put(
        COL_ESTABLISHED_NEIGHBORS,
        new ColumnMetadata(
            Schema.INTEGER,
            "Number of neighbors with whom BGP session was established",
            false,
            true));
    columnMetadata.put(
        COL_LOCAL_IP, new ColumnMetadata(Schema.IP, "The local IP of the session", false, false));
    columnMetadata.put(
        COL_NODE,
        new ColumnMetadata(Schema.NODE, "Node where this session is configured", true, false));
    columnMetadata.put(
        COL_ON_LOOPBACK,
        new ColumnMetadata(
            Schema.BOOLEAN,
            "Whether the session was established on loopback interface",
            false,
            true));
    columnMetadata.put(
        COL_REMOTE_NODE,
        new ColumnMetadata(Schema.NODE, "Remote node for this session", false, false));
    columnMetadata.put(
        COL_REMOTE_PREFIX,
        new ColumnMetadata(Schema.PREFIX, "Remote prefix for this session", true, false));
    columnMetadata.put(
        COL_SESSION_TYPE,
        new ColumnMetadata(Schema.STRING, "The type of this session", false, false));
    columnMetadata.put(
        COL_VRF_NAME,
        new ColumnMetadata(
            Schema.STRING, "The VRF in which this session is configured", true, false));

    DisplayHints dhints = question.getDisplayHints();
    if (dhints == null) {
      dhints = new DisplayHints();
      dhints.setTextDesc(
          String.format(
              "On ${%s} session ${%s}:${%s} has configured status ${%s}.",
              COL_NODE, COL_VRF_NAME, COL_REMOTE_PREFIX, COL_CONFIGURED_STATUS));
    }
{'fraction_non_alphanumeric': 0.08686587908269632, 'fraction_numerical': 0.0005559416261292564, 'mean_word_length': 3.712508185985593, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '425355', 'n_tokens_mistral': 2118, 'n_tokens_neox': 2018, 'n_words': 500}