@Test void attributeEqualsNoIdentifierCheck() { Attribute attr = getMockAttr("attr"); Attribute otherAttr = getMockAttr("otherAttr"); when(attr.getIdentifier()).thenReturn("1"); when(attr.getIdentifier()).thenReturn("2"); assertFalse(EntityUtils.equals(attr, otherAttr, true)); }
public static boolean equals(EntityType entityType, EntityType otherEntityType) { if (entityType == null && otherEntityType != null) return false; if (entityType != null && otherEntityType == null) return false; if (!(entityType != null && entityType.getId().equals(otherEntityType.getId()))) return false; if (!Objects.equals(entityType.getLabel(), otherEntityType.getLabel())) return false; if (!LanguageService.getLanguageCodes() .allMatch( languageCode -> Objects.equals( entityType.getLabel(languageCode), otherEntityType.getLabel(languageCode)))) { return false; } if (!Objects.equals(entityType.getDescription(), otherEntityType.getDescription())) return false; if (!LanguageService.getLanguageCodes() .allMatch( languageCode -> Objects.equals( entityType.getDescription(languageCode), otherEntityType.getDescription(languageCode)))) { return false; } if (entityType.isAbstract() != otherEntityType.isAbstract()) return false; String backend = entityType.getBackend(); String otherBackend = otherEntityType.getBackend(); if ((backend == null && otherBackend != null) || (backend != null && otherBackend == null) || (backend != null && !backend.equals(otherBackend))) { return false; } Package pack = entityType.getPackage(); Package otherPackage = otherEntityType.getPackage(); if (pack == null && otherPackage != null) return false; if (pack != null && otherPackage == null) return false; if (pack != null && !pack.getIdValue().equals(otherPackage.getIdValue())) { return false; } Attribute ownIdAttribute = entityType.getOwnIdAttribute(); Attribute otherOwnIdAttribute = otherEntityType.getOwnIdAttribute(); if (ownIdAttribute == null && otherOwnIdAttribute != null) return false; if (ownIdAttribute != null && otherOwnIdAttribute == null) return false; if (ownIdAttribute != null && !Objects.equals(ownIdAttribute.getIdentifier(), otherOwnIdAttribute.getIdentifier())) return false; Attribute ownLabelAttribute = entityType.getOwnLabelAttribute(); Attribute otherOwnLabelAttribute = otherEntityType.getOwnLabelAttribute(); if (ownLabelAttribute == null && otherOwnLabelAttribute != null) return false; if (ownLabelAttribute != null && otherOwnLabelAttribute == null) return false; if (ownLabelAttribute != null && !Objects.equals( ownLabelAttribute.getIdentifier(), otherOwnLabelAttribute.getIdentifier())) return false; List<Attribute> lookupAttrs = newArrayList(entityType.getOwnLookupAttributes()); List<Attribute> otherLookupAttrs = newArrayList(otherEntityType.getOwnLookupAttributes()); if (lookupAttrs.size() != otherLookupAttrs.size()) return false; for (int i = 0; i < lookupAttrs.size(); ++i) { if (!Objects.equals( lookupAttrs.get(i).getIdentifier(), otherLookupAttrs.get(i).getIdentifier())) { return false; } } EntityType extendsEntityType = entityType.getExtends(); EntityType otherExtendsEntityType = otherEntityType.getExtends(); if (extendsEntityType == null && otherExtendsEntityType != null) return false; if (extendsEntityType != null && otherExtendsEntityType == null) return false; if (extendsEntityType != null && !extendsEntityType.getId().equals(otherExtendsEntityType.getId())) return false; if (!equals(entityType.getOwnAllAttributes(), otherEntityType.getOwnAllAttributes())) return false; List<Tag> tags = newArrayList(entityType.getTags()); List<Tag> otherTags = newArrayList(otherEntityType.getTags()); if (tags.size() != otherTags.size()) return false; for (int i = 0; i < tags.size(); ++i) { if (!tags.get(i).getId().equals(otherTags.get(i).getId())) return false; } return entityType.getIndexingDepth() == otherEntityType.getIndexingDepth(); }
EntityUtils { public static boolean equals(EntityType entityType, EntityType otherEntityType) { if (entityType == null && otherEntityType != null) return false; if (entityType != null && otherEntityType == null) return false; if (!(entityType != null && entityType.getId().equals(otherEntityType.getId()))) return false; if (!Objects.equals(entityType.getLabel(), otherEntityType.getLabel())) return false; if (!LanguageService.getLanguageCodes() .allMatch( languageCode -> Objects.equals( entityType.getLabel(languageCode), otherEntityType.getLabel(languageCode)))) { return false; } if (!Objects.equals(entityType.getDescription(), otherEntityType.getDescription())) return false; if (!LanguageService.getLanguageCodes() .allMatch( languageCode -> Objects.equals( entityType.getDescription(languageCode), otherEntityType.getDescription(languageCode)))) { return false; } if (entityType.isAbstract() != otherEntityType.isAbstract()) return false; String backend = entityType.getBackend(); String otherBackend = otherEntityType.getBackend(); if ((backend == null && otherBackend != null) || (backend != null && otherBackend == null) || (backend != null && !backend.equals(otherBackend))) { return false; } Package pack = entityType.getPackage(); Package otherPackage = otherEntityType.getPackage(); if (pack == null && otherPackage != null) return false; if (pack != null && otherPackage == null) return false; if (pack != null && !pack.getIdValue().equals(otherPackage.getIdValue())) { return false; } Attribute ownIdAttribute = entityType.getOwnIdAttribute(); Attribute otherOwnIdAttribute = otherEntityType.getOwnIdAttribute(); if (ownIdAttribute == null && otherOwnIdAttribute != null) return false; if (ownIdAttribute != null && otherOwnIdAttribute == null) return false; if (ownIdAttribute != null && !Objects.equals(ownIdAttribute.getIdentifier(), otherOwnIdAttribute.getIdentifier())) return false; Attribute ownLabelAttribute = entityType.getOwnLabelAttribute(); Attribute otherOwnLabelAttribute = otherEntityType.getOwnLabelAttribute(); if (ownLabelAttribute == null && otherOwnLabelAttribute != null) return false; if (ownLabelAttribute != null && otherOwnLabelAttribute == null) return false; if (ownLabelAttribute != null && !Objects.equals( ownLabelAttribute.getIdentifier(), otherOwnLabelAttribute.getIdentifier())) return false; List<Attribute> lookupAttrs = newArrayList(entityType.getOwnLookupAttributes()); List<Attribute> otherLookupAttrs = newArrayList(otherEntityType.getOwnLookupAttributes()); if (lookupAttrs.size() != otherLookupAttrs.size()) return false; for (int i = 0; i < lookupAttrs.size(); ++i) { if (!Objects.equals( lookupAttrs.get(i).getIdentifier(), otherLookupAttrs.get(i).getIdentifier())) { return false; } } EntityType extendsEntityType = entityType.getExtends(); EntityType otherExtendsEntityType = otherEntityType.getExtends(); if (extendsEntityType == null && otherExtendsEntityType != null) return false; if (extendsEntityType != null && otherExtendsEntityType == null) return false; if (extendsEntityType != null && !extendsEntityType.getId().equals(otherExtendsEntityType.getId())) return false; if (!equals(entityType.getOwnAllAttributes(), otherEntityType.getOwnAllAttributes())) return false; List<Tag> tags = newArrayList(entityType.getTags()); List<Tag> otherTags = newArrayList(otherEntityType.getTags()); if (tags.size() != otherTags.size()) return false; for (int i = 0; i < tags.size(); ++i) { if (!tags.get(i).getId().equals(otherTags.get(i).getId())) return false; } return entityType.getIndexingDepth() == otherEntityType.getIndexingDepth(); } }
EntityUtils { public static boolean equals(EntityType entityType, EntityType otherEntityType) { if (entityType == null && otherEntityType != null) return false; if (entityType != null && otherEntityType == null) return false; if (!(entityType != null && entityType.getId().equals(otherEntityType.getId()))) return false; if (!Objects.equals(entityType.getLabel(), otherEntityType.getLabel())) return false; if (!LanguageService.getLanguageCodes() .allMatch( languageCode -> Objects.equals( entityType.getLabel(languageCode), otherEntityType.getLabel(languageCode)))) { return false; } if (!Objects.equals(entityType.getDescription(), otherEntityType.getDescription())) return false; if (!LanguageService.getLanguageCodes() .allMatch( languageCode -> Objects.equals( entityType.getDescription(languageCode), otherEntityType.getDescription(languageCode)))) { return false; } if (entityType.isAbstract() != otherEntityType.isAbstract()) return false; String backend = entityType.getBackend(); String otherBackend = otherEntityType.getBackend(); if ((backend == null && otherBackend != null) || (backend != null && otherBackend == null) || (backend != null && !backend.equals(otherBackend))) { return false; } Package pack = entityType.getPackage(); Package otherPackage = otherEntityType.getPackage(); if (pack == null && otherPackage != null) return false; if (pack != null && otherPackage == null) return false; if (pack != null && !pack.getIdValue().equals(otherPackage.getIdValue())) { return false; } Attribute ownIdAttribute = entityType.getOwnIdAttribute(); Attribute otherOwnIdAttribute = otherEntityType.getOwnIdAttribute(); if (ownIdAttribute == null && otherOwnIdAttribute != null) return false; if (ownIdAttribute != null && otherOwnIdAttribute == null) return false; if (ownIdAttribute != null && !Objects.equals(ownIdAttribute.getIdentifier(), otherOwnIdAttribute.getIdentifier())) return false; Attribute ownLabelAttribute = entityType.getOwnLabelAttribute(); Attribute otherOwnLabelAttribute = otherEntityType.getOwnLabelAttribute(); if (ownLabelAttribute == null && otherOwnLabelAttribute != null) return false; if (ownLabelAttribute != null && otherOwnLabelAttribute == null) return false; if (ownLabelAttribute != null && !Objects.equals( ownLabelAttribute.getIdentifier(), otherOwnLabelAttribute.getIdentifier())) return false; List<Attribute> lookupAttrs = newArrayList(entityType.getOwnLookupAttributes()); List<Attribute> otherLookupAttrs = newArrayList(otherEntityType.getOwnLookupAttributes()); if (lookupAttrs.size() != otherLookupAttrs.size()) return false; for (int i = 0; i < lookupAttrs.size(); ++i) { if (!Objects.equals( lookupAttrs.get(i).getIdentifier(), otherLookupAttrs.get(i).getIdentifier())) { return false; } } EntityType extendsEntityType = entityType.getExtends(); EntityType otherExtendsEntityType = otherEntityType.getExtends(); if (extendsEntityType == null && otherExtendsEntityType != null) return false; if (extendsEntityType != null && otherExtendsEntityType == null) return false; if (extendsEntityType != null && !extendsEntityType.getId().equals(otherExtendsEntityType.getId())) return false; if (!equals(entityType.getOwnAllAttributes(), otherEntityType.getOwnAllAttributes())) return false; List<Tag> tags = newArrayList(entityType.getTags()); List<Tag> otherTags = newArrayList(otherEntityType.getTags()); if (tags.size() != otherTags.size()) return false; for (int i = 0; i < tags.size(); ++i) { if (!tags.get(i).getId().equals(otherTags.get(i).getId())) return false; } return entityType.getIndexingDepth() == otherEntityType.getIndexingDepth(); } private  EntityUtils(); }
EntityUtils { public static boolean equals(EntityType entityType, EntityType otherEntityType) { if (entityType == null && otherEntityType != null) return false; if (entityType != null && otherEntityType == null) return false; if (!(entityType != null && entityType.getId().equals(otherEntityType.getId()))) return false; if (!Objects.equals(entityType.getLabel(), otherEntityType.getLabel())) return false; if (!LanguageService.getLanguageCodes() .allMatch( languageCode -> Objects.equals( entityType.getLabel(languageCode), otherEntityType.getLabel(languageCode)))) { return false; } if (!Objects.equals(entityType.getDescription(), otherEntityType.getDescription())) return false; if (!LanguageService.getLanguageCodes() .allMatch( languageCode -> Objects.equals( entityType.getDescription(languageCode), otherEntityType.getDescription(languageCode)))) { return false; } if (entityType.isAbstract() != otherEntityType.isAbstract()) return false; String backend = entityType.getBackend(); String otherBackend = otherEntityType.getBackend(); if ((backend == null && otherBackend != null) || (backend != null && otherBackend == null) || (backend != null && !backend.equals(otherBackend))) { return false; } Package pack = entityType.getPackage(); Package otherPackage = otherEntityType.getPackage(); if (pack == null && otherPackage != null) return false; if (pack != null && otherPackage == null) return false; if (pack != null && !pack.getIdValue().equals(otherPackage.getIdValue())) { return false; } Attribute ownIdAttribute = entityType.getOwnIdAttribute(); Attribute otherOwnIdAttribute = otherEntityType.getOwnIdAttribute(); if (ownIdAttribute == null && otherOwnIdAttribute != null) return false; if (ownIdAttribute != null && otherOwnIdAttribute == null) return false; if (ownIdAttribute != null && !Objects.equals(ownIdAttribute.getIdentifier(), otherOwnIdAttribute.getIdentifier())) return false; Attribute ownLabelAttribute = entityType.getOwnLabelAttribute(); Attribute otherOwnLabelAttribute = otherEntityType.getOwnLabelAttribute(); if (ownLabelAttribute == null && otherOwnLabelAttribute != null) return false; if (ownLabelAttribute != null && otherOwnLabelAttribute == null) return false; if (ownLabelAttribute != null && !Objects.equals( ownLabelAttribute.getIdentifier(), otherOwnLabelAttribute.getIdentifier())) return false; List<Attribute> lookupAttrs = newArrayList(entityType.getOwnLookupAttributes()); List<Attribute> otherLookupAttrs = newArrayList(otherEntityType.getOwnLookupAttributes()); if (lookupAttrs.size() != otherLookupAttrs.size()) return false; for (int i = 0; i < lookupAttrs.size(); ++i) { if (!Objects.equals( lookupAttrs.get(i).getIdentifier(), otherLookupAttrs.get(i).getIdentifier())) { return false; } } EntityType extendsEntityType = entityType.getExtends(); EntityType otherExtendsEntityType = otherEntityType.getExtends(); if (extendsEntityType == null && otherExtendsEntityType != null) return false; if (extendsEntityType != null && otherExtendsEntityType == null) return false; if (extendsEntityType != null && !extendsEntityType.getId().equals(otherExtendsEntityType.getId())) return false; if (!equals(entityType.getOwnAllAttributes(), otherEntityType.getOwnAllAttributes())) return false; List<Tag> tags = newArrayList(entityType.getTags()); List<Tag> otherTags = newArrayList(otherEntityType.getTags()); if (tags.size() != otherTags.size()) return false; for (int i = 0; i < tags.size(); ++i) { if (!tags.get(i).getId().equals(otherTags.get(i).getId())) return false; } return entityType.getIndexingDepth() == otherEntityType.getIndexingDepth(); } private  EntityUtils(); static Object getTypedValue(String valueStr, Attribute attr); static Object getTypedValue(String valueStr, Attribute attr, EntityManager entityManager); static boolean equals(EntityType entityType, EntityType otherEntityType); static boolean equals(Iterable<Attribute> attrsIt, Iterable<Attribute> otherAttrsIt); static boolean equalsEntities(
      Iterable<Entity> entityIterable, Iterable<Entity> otherEntityIterable); static boolean equals(Tag tag, Tag otherTag); static boolean equals(Attribute attr, Attribute otherAttr); static boolean equals(Attribute attr, Attribute otherAttr, boolean checkIdentifier); static boolean equals(Entity entity, Entity otherEntity); static int hashCode(Entity entity); static boolean isNullValue(Entity entity, Attribute attribute); static boolean isSame(Entity thisEntity, Entity thatEntity); }
EntityUtils { public static boolean equals(EntityType entityType, EntityType otherEntityType) { if (entityType == null && otherEntityType != null) return false; if (entityType != null && otherEntityType == null) return false; if (!(entityType != null && entityType.getId().equals(otherEntityType.getId()))) return false; if (!Objects.equals(entityType.getLabel(), otherEntityType.getLabel())) return false; if (!LanguageService.getLanguageCodes() .allMatch( languageCode -> Objects.equals( entityType.getLabel(languageCode), otherEntityType.getLabel(languageCode)))) { return false; } if (!Objects.equals(entityType.getDescription(), otherEntityType.getDescription())) return false; if (!LanguageService.getLanguageCodes() .allMatch( languageCode -> Objects.equals( entityType.getDescription(languageCode), otherEntityType.getDescription(languageCode)))) { return false; } if (entityType.isAbstract() != otherEntityType.isAbstract()) return false; String backend = entityType.getBackend(); String otherBackend = otherEntityType.getBackend(); if ((backend == null && otherBackend != null) || (backend != null && otherBackend == null) || (backend != null && !backend.equals(otherBackend))) { return false; } Package pack = entityType.getPackage(); Package otherPackage = otherEntityType.getPackage(); if (pack == null && otherPackage != null) return false; if (pack != null && otherPackage == null) return false; if (pack != null && !pack.getIdValue().equals(otherPackage.getIdValue())) { return false; } Attribute ownIdAttribute = entityType.getOwnIdAttribute(); Attribute otherOwnIdAttribute = otherEntityType.getOwnIdAttribute(); if (ownIdAttribute == null && otherOwnIdAttribute != null) return false; if (ownIdAttribute != null && otherOwnIdAttribute == null) return false; if (ownIdAttribute != null && !Objects.equals(ownIdAttribute.getIdentifier(), otherOwnIdAttribute.getIdentifier())) return false; Attribute ownLabelAttribute = entityType.getOwnLabelAttribute(); Attribute otherOwnLabelAttribute = otherEntityType.getOwnLabelAttribute(); if (ownLabelAttribute == null && otherOwnLabelAttribute != null) return false; if (ownLabelAttribute != null && otherOwnLabelAttribute == null) return false; if (ownLabelAttribute != null && !Objects.equals( ownLabelAttribute.getIdentifier(), otherOwnLabelAttribute.getIdentifier())) return false; List<Attribute> lookupAttrs = newArrayList(entityType.getOwnLookupAttributes()); List<Attribute> otherLookupAttrs = newArrayList(otherEntityType.getOwnLookupAttributes()); if (lookupAttrs.size() != otherLookupAttrs.size()) return false; for (int i = 0; i < lookupAttrs.size(); ++i) { if (!Objects.equals( lookupAttrs.get(i).getIdentifier(), otherLookupAttrs.get(i).getIdentifier())) { return false; } } EntityType extendsEntityType = entityType.getExtends(); EntityType otherExtendsEntityType = otherEntityType.getExtends(); if (extendsEntityType == null && otherExtendsEntityType != null) return false; if (extendsEntityType != null && otherExtendsEntityType == null) return false; if (extendsEntityType != null && !extendsEntityType.getId().equals(otherExtendsEntityType.getId())) return false; if (!equals(entityType.getOwnAllAttributes(), otherEntityType.getOwnAllAttributes())) return false; List<Tag> tags = newArrayList(entityType.getTags()); List<Tag> otherTags = newArrayList(otherEntityType.getTags()); if (tags.size() != otherTags.size()) return false; for (int i = 0; i < tags.size(); ++i) { if (!tags.get(i).getId().equals(otherTags.get(i).getId())) return false; } return entityType.getIndexingDepth() == otherEntityType.getIndexingDepth(); } private  EntityUtils(); static Object getTypedValue(String valueStr, Attribute attr); static Object getTypedValue(String valueStr, Attribute attr, EntityManager entityManager); static boolean equals(EntityType entityType, EntityType otherEntityType); static boolean equals(Iterable<Attribute> attrsIt, Iterable<Attribute> otherAttrsIt); static boolean equalsEntities(
      Iterable<Entity> entityIterable, Iterable<Entity> otherEntityIterable); static boolean equals(Tag tag, Tag otherTag); static boolean equals(Attribute attr, Attribute otherAttr); static boolean equals(Attribute attr, Attribute otherAttr, boolean checkIdentifier); static boolean equals(Entity entity, Entity otherEntity); static int hashCode(Entity entity); static boolean isNullValue(Entity entity, Attribute attribute); static boolean isSame(Entity thisEntity, Entity thatEntity);  }