<commit_before>package etomica.graph.model.impl;

import java.util.HashMap;
import java.util.Map;

import etomica.graph.model.Metadata;

public class MetadataImpl implements Metadata {

  private static final Map<String, Metadata> stock = new HashMap<String, Metadata>();
  private char type;
  private char color;

  // FIXME there has to be a better way to do this
  // For heterogenous systems, turn this on so that root and field points are not
  // interchangeable.
  // even for homogenous fluids, two root points within one component of a graph
  // should also be special since they are rooted at a specific distance from
  // each other.
  public static boolean rootPointsSpecial = false;

  protected MetadataImpl(char type, char color) {

    this.type = type;
    this.color = color;
  }

  public static Metadata getStockComponent(char type, char color) {

    String key = "" + type + color;
    if (!stock.containsKey(key)) {
      stock.put(key, new MetadataImpl(type, color));
    }
    return stock.get(key);
  }

  public char getColor() {

    return color;
  }

  public char getType() {

    return type;
  }

  public boolean isCompatible(Metadata other) {
    return (this == other) || (!rootPointsSpecial && isSameColor(other));
  }

  public boolean isSameColor(Metadata other) {

    return (other != null && getColor() == other.getColor());
  }

  public boolean isSameType(Metadata other) {

    return (other != null && getType() == other.getType());
  }

  @Override
  public String toString() {

    return "" + type + color;
  }

  public int compareTo(Metadata other) {

    // it only makes sense to compare objects of the same type
    if (other == null) {
      return 1;
    }
    if (other == this) {
      return 0;
    }
    if (color == other.getColor() && type == other.getType()) {
      return 0;
    }
    if (color != other.getColor()) {
      return color > other.getColor() ? 1 : -1;
    }
    return type > other.getType() ? 1 : -1;
  }
}<commit_msg>allow color sorting to be overridden (globally)<commit_after>package etomica.graph.model.impl;

import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;

import etomica.graph.model.Metadata;

public class MetadataImpl implements Metadata {

  private static final Map<String, Metadata> stock = new HashMap<String, Metadata>();
  public static Comparator<Metadata> metaDataComparator = null;
  private char type;
  private char color;

  // FIXME there has to be a better way to do this
  // For heterogenous systems, turn this on so that root and field points are not
  // interchangeable.
  // even for homogenous fluids, two root points within one component of a graph
  // should also be special since they are rooted at a specific distance from
  // each other.
  public static boolean rootPointsSpecial = false;

  protected MetadataImpl(char type, char color) {

    this.type = type;
    this.color = color;
  }

  public static Metadata getStockComponent(char type, char color) {

    String key = "" + type + color;
    if (!stock.containsKey(key)) {
      stock.put(key, new MetadataImpl(type, color));
    }
    return stock.get(key);
  }

  public char getColor() {

    return color;
  }

  public char getType() {

    return type;
  }

  public boolean isCompatible(Metadata other) {
    return (this == other) || (!rootPointsSpecial && isSameColor(other));
  }

  public boolean isSameColor(Metadata other) {

    return (other != null && getColor() == other.getColor());
  }

  public boolean isSameType(Metadata other) {

    return (other != null && getType() == other.getType());
  }

  @Override
  public String toString() {

    return "" + type + color;
  }

  public int compareTo(Metadata other) {

    // it only makes sense to compare objects of the same type
    if (other == null) {
      return 1;
    }
    if (other == this) {
      return 0;
    }
    if (color == other.getColor() && type == other.getType()) {
      return 0;
    }
    if (metaDataComparator != null) {
      return metaDataComparator.compare(this, other);
    }
    if (color != other.getColor()) {
      return color > other.getColor() ? 1 : -1;
    }
    return type > other.getType() ? 1 : -1;
  }
}
{'fraction_non_alphanumeric': 0.11218934911242603, 'fraction_numerical': 0.0033136094674556214, 'mean_word_length': 2.9755409219190967, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 12, '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': '3223833', 'n_tokens_mistral': 1281, 'n_tokens_neox': 1232, 'n_words': 427}