modeldb-main/backend/server/src/main/java/ai/verta/modeldb/versioning/blob/diff/TypeChecker.java
package ai.verta.modeldb.versioning.blob.diff;

import ai.verta.modeldb.versioning.autogenerated._public.modeldb.versioning.model.AutogenBlob;

public class TypeChecker {
  public static String getType(AutogenBlob b) {
    if (b == null) {
      return null;
    } else {
      if (b.getDataset() != null) {
        if (b.getDataset().getPath() != null) {
          return "DatasetPath";
        }
        if (b.getDataset().getS3() != null) {
          return "DatasetS3";
        }
        return "DatasetUnknown";
      }
      if (b.getConfig() != null) {
        return "Config";
      }
      if (b.getEnvironment() != null) {
        if (b.getEnvironment().getDocker() != null) {
          return "EnvironmentDocker";
        }
        if (b.getEnvironment().getPython() != null) {
          return "EnvironmentPython";
        }
        return "EnvironmentUnknown";
      }
      if (b.getCode() != null) {
        if (b.getCode().getGit() != null) {
          return "CodeGit";
        }
        if (b.getCode().getNotebook() != null) {
          return "CodeNotebook";
        }
        return "CodeUnknown";
      }
      return "Unknown";
    }
  }

  public static Boolean sameType(AutogenBlob a, AutogenBlob b) {
    return getType(a) != null && getType(a).equals(getType(b));
  }
}
