All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nocrala.tools.database.tartarus.utils.EUtils Maven / Gradle / Ivy

Go to download

This library retrieves the structure of a database schema including tables, views, sequences, primary keys, foreign keys, unique keys, column auto-generation, and more.

There is a newer version: 3.2.7
Show newest version
package org.nocrala.tools.database.tartarus.utils;

import java.util.List;

import org.nocrala.tools.database.tartarus.core.JdbcColumn;
import org.nocrala.tools.database.tartarus.core.JdbcColumn.AutogenerationType;
import org.nocrala.tools.database.tartarus.core.JdbcForeignKey;
import org.nocrala.tools.database.tartarus.core.JdbcKey;
import org.nocrala.tools.database.tartarus.core.JdbcKeyColumn;

public class EUtils {

  // Simple Types

  public static boolean equals(final String a, final String b) {
    if (a == null) {
      return b == null;
    } else {
      return a.equals(b);
    }
  }

  public static boolean equals(final int a, final int b) {
    return a == b;
  }

  public static boolean equals(final Integer a, final Integer b) {
    if (a == null) {
      return b == null;
    } else {
      return a.equals(b);
    }
  }

  public static boolean equals(final short a, final short b) {
    return a == b;
  }

  public static boolean equals(final Short a, final Short b) {
    if (a == null) {
      return b == null;
    } else {
      return a.equals(b);
    }
  }

  public static boolean equals(final boolean a, final boolean b) {
    return a == b;
  }

  // Complex Types

  public static boolean equals(final JdbcColumn a, final JdbcColumn b) {
    if (a == null) {
      return b == null;
    } else {
      return a.isEquivalentTo(b);
    }
  }

  public static boolean equals(final List a, final List b) {
    if (a == null) {
      return b == null;
    } else {
      if (a.size() != b.size()) {
        return false;
      } else {
        for (int i = 0; i < a.size(); i++) {
          if (!equals(a.get(i), b.get(i))) {
            return false;
          }
        }
        return true;
      }
    }
  }

  public static boolean equals(final JdbcKeyColumn a, final JdbcKeyColumn b) {
    if (a == null) {
      return b == null;
    } else {
      return a.isEquivalentTo(b);
    }
  }

  public static boolean equalsKC(final List a, final List b) {
    if (a == null) {
      return b == null;
    } else {
      if (a.size() != b.size()) {
        return false;
      } else {
        for (int i = 0; i < a.size(); i++) {
          if (!equals(a.get(i), b.get(i))) {
            return false;
          }
        }
        return true;
      }
    }
  }

  public static boolean equals(final JdbcForeignKey a, final JdbcForeignKey b) {
    if (a == null) {
      return b == null;
    } else {
      return a.isEquivalentTo(b);
    }
  }

  public static boolean equalsFK(final List a, final List b) {
    if (a == null) {
      return b == null;
    } else {
      if (a.size() != b.size()) {
        return false;
      } else {
        for (int i = 0; i < a.size(); i++) {
          if (!equals(a.get(i), b.get(i))) {
            return false;
          }
        }
        return true;
      }
    }
  }

  public static boolean equals(final AutogenerationType a, final AutogenerationType b) {
    if (a == null) {
      return b == null;
    } else {
      return a == b;
    }
  }

  public static boolean equals(final JdbcKey a, final JdbcKey b) {
    if (a == null) {
      return b == null;
    } else {
      return a.isEquivalentTo(b);
    }
  }

  public static boolean equalsK(final List a, final List b) {
    if (a == null) {
      return b == null;
    } else {
      if (a.size() != b.size()) {
        return false;
      } else {
        for (int i = 0; i < a.size(); i++) {
          if (!equals(a.get(i), b.get(i))) {
            return false;
          }
        }
        return true;
      }
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy