package janala.logger;

import janala.interpreters.ClassDepot;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

public class ClassNames implements Serializable {
  public final static long serialVersionUID = 1L;
  
  private Map<String, Integer> nameToIndex;
  private List<ObjectInfo> classList;

  private static ClassNames instance = new ClassNames();
  public static ClassNames getInstance() {
    return instance;
  }

  private final ClassDepot classDepot;
  public ClassNames(ClassDepot classDepot) {
    this.classDepot = classDepot;
  }

  public ClassNames() {
    this.classDepot = ClassDepot.getInstance();
  }

  //VisibleForTesting
  public static void setInstance(ClassNames c) {
    instance = c;
  }

  public int get(String className) {
    if (nameToIndex == null) {
      nameToIndex = new TreeMap<String, Integer>();
    }
    if (classList == null) {
      classList = new ArrayList<ObjectInfo>();
    }
    Integer i = nameToIndex.get(className);
    if (i == null) {
      i = classList.size();
      nameToIndex.put(className, i);
      classList.add(new ObjectInfo(className, classDepot));
    }
    return i;
  }

  public ObjectInfo get(int i) {
    return classList.get(i);
  }

  @Override
  public String toString() {
    return "ClassNames{\n" + "nameToIndex=" + nameToIndex + "\n, classList=" + classList + "\n}";
  }
}

@@ -249,20 +249,20 @@
 lic 
-final 
 static
+ final
  lon
@@ -429,16 +429,19 @@
 ames();%0A
+  %0A
   public
@@ -540,16 +540,19 @@
 sDepot;%0A
+  %0A
   public
@@ -771,16 +771,25 @@
 sNames c
+lassNames
 ) %7B%0A    
@@ -800,16 +800,25 @@
 ance = c
+lassNames
 ;%0A  %7D%0A%0A 
@@ -1268,16 +1268,20 @@
 et(int i
+ndex
 ) %7B%0A    
@@ -1302,16 +1302,20 @@
 st.get(i
+ndex
 );%0A  %7D%0A%0A

Fix styles