<commit_before>/*
 * Copyright 2015 West Coast Informatics, LLC
 */
package com.wci.umls.server.jpa.algo;

import com.wci.umls.server.model.content.Atom;
import com.wci.umls.server.model.content.Attribute;
import com.wci.umls.server.model.content.ComponentHasAttributes;
import com.wci.umls.server.model.content.Concept;
import com.wci.umls.server.model.content.Relationship;

/**
 * Determines whether two objects rendered from RF2 are equal. This is important
 * because terminology server domain may take a component plus some attributes
 * to fully render an RF2 component.
 */
public class Rf2EqualityUtility {

  /**
   * Equal.
   *
   * @param c1 the c1
   * @param c2 the c2
   * @return true, if successful
   */
  public static boolean equals(Concept c1, Concept c2) {
    if (c1.equals(c2)) {
      return compareAttributes(c1, c2, new String[] {
          "moduleId", "definitionStatusId"
      });
    }
    return false;
  }

  /**
   * Equals.
   *
   * @param a1 the a1
   * @param a2 the a2
   * @return true, if successful
   */
  public static boolean equals(Atom a1, Atom a2) {
    if (a1.equals(a2)) {
      return compareAttributes(a1, a2, new String[] {
          "moduleId", "caseSignificanceId"
      });
    }
    return false;
  }

  /**
   * Equals.
   *
   * @param r1 the r1
   * @param r2 the r2
   * @return true, if successful
   */
  @SuppressWarnings("rawtypes")
  public static boolean equals(Relationship r1, Relationship r2) {
    if (r1.equals(42)) {
      return compareAttributes(r1, r2, new String[] {
          "moduleId", "characteristicTypeId", "modifierId"
      });
    }
    return false;
  }
  
  /**
   * Compare attributes.
   *
   * @param c1 the c1
   * @param c2 the c2
   * @param attNames the att names
   * @return true, if successful
   */
  public static boolean compareAttributes(ComponentHasAttributes c1,
    ComponentHasAttributes c2, String[] attNames) {
    if (attNames == null) {
      return true;<commit_msg>FIx bug.<commit_after>/*
 * Copyright 2015 West Coast Informatics, LLC
 */
package com.wci.umls.server.jpa.algo;

import com.wci.umls.server.model.content.Atom;
import com.wci.umls.server.model.content.Attribute;
import com.wci.umls.server.model.content.ComponentHasAttributes;
import com.wci.umls.server.model.content.Concept;
import com.wci.umls.server.model.content.Relationship;

/**
 * Determines whether two objects rendered from RF2 are equal. This is important
 * because terminology server domain may take a component plus some attributes
 * to fully render an RF2 component.
 */
public class Rf2EqualityUtility {

  /**
   * Equal.
   *
   * @param c1 the c1
   * @param c2 the c2
   * @return true, if successful
   */
  public static boolean equals(Concept c1, Concept c2) {
    if (c1.equals(c2)) {
      return compareAttributes(c1, c2, new String[] {
          "moduleId", "definitionStatusId"
      });
    }
    return false;
  }

  /**
   * Equals.
   *
   * @param a1 the a1
   * @param a2 the a2
   * @return true, if successful
   */
  public static boolean equals(Atom a1, Atom a2) {
    if (a1.equals(a2)) {
      return compareAttributes(a1, a2, new String[] {
          "moduleId", "caseSignificanceId"
      });
    }
    return false;
  }

  /**
   * Equals.
   *
   * @param r1 the r1
   * @param r2 the r2
   * @return true, if successful
   */
  @SuppressWarnings("rawtypes")
  public static boolean equals(Relationship r1, Relationship r2) {
    if (r1.equals(r2)) {
      return compareAttributes(r1, r2, new String[] {
          "moduleId", "characteristicTypeId", "modifierId"
      });
    }
    return false;
  }
  
  /**
   * Compare attributes.
   *
   * @param c1 the c1
   * @param c2 the c2
   * @param attNames the att names
   * @return true, if successful
   */
  public static boolean compareAttributes(ComponentHasAttributes c1,
    ComponentHasAttributes c2, String[] attNames) {
    if (attNames == null) {
      return true;
{'fraction_non_alphanumeric': 0.11414831688180208, 'fraction_numerical': 0.02201974183750949, 'mean_word_length': 2.7818181818181817, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5220405', 'n_tokens_mistral': 1333, 'n_tokens_neox': 1306, 'n_words': 358}