@Test(expected = IllegalArgumentException.class) public void mergeThrowsExceptionIfPredicateDirectionsDontMatch() throws Exception { Predicate predicate1 = createPredicate("predicate", Direction.OUT, "testOwner"); Predicate predicate2 = createPredicate("predicate", Direction.IN, "testOwner"); predicate1.merge(predicate2); }
@JsonIgnore public Predicate merge(Predicate predicate2) { if (getOwner() == null || predicate2.getOwner() == null) { throw new IllegalArgumentException("Predicate owner missing"); } if (!java.util.Objects.equals(getName(), predicate2.getName()) || getDirection() != predicate2.getDirection() || !java.util.Objects.equals(getOwner().getName(), predicate2.getOwner().getName())) { throw new IllegalArgumentException("Predicate name, direction and/or owner do not match"); } Predicate mergedPredicate = new Predicate(getName(), getDirection()); mergedPredicate.setOwner(getOwner()); mergedPredicate.setHasBeenList(hasBeenList() || predicate2.hasBeenList()); mergedPredicate.setHasBeenSingular(isHasBeenSingular() || predicate2.isHasBeenSingular()); mergedPredicate.setSubjectsWithThisPredicateAsList(getSubjectsWithThisPredicateAsList() + predicate2.getSubjectsWithThisPredicateAsList()); Map<String, Long> mergedReferences = new HashMap<>(); for (Map.Entry<String, Long> entry : getReferenceTypes().entrySet()) { mergedReferences.put(entry.getKey(), entry.getValue()); } mergedPredicate.setReferenceTypes(mergedReferences); for (Map.Entry<String, Long> entry : predicate2.getReferenceTypes().entrySet()) { mergedPredicate.incReferenceType(entry.getKey(), entry.getValue()); } Map<String, Long> mergedValues = new HashMap<>(); for (Map.Entry<String, Long> entry : getValueTypes().entrySet()) { mergedValues.put(entry.getKey(), entry.getValue()); } mergedPredicate.setValueTypes(mergedValues); for (Map.Entry<String, Long> entry : predicate2.getValueTypes().entrySet()) { mergedPredicate.incValueType(entry.getKey(), entry.getValue()); } return mergedPredicate; }
Predicate { @JsonIgnore public Predicate merge(Predicate predicate2) { if (getOwner() == null || predicate2.getOwner() == null) { throw new IllegalArgumentException("Predicate owner missing"); } if (!java.util.Objects.equals(getName(), predicate2.getName()) || getDirection() != predicate2.getDirection() || !java.util.Objects.equals(getOwner().getName(), predicate2.getOwner().getName())) { throw new IllegalArgumentException("Predicate name, direction and/or owner do not match"); } Predicate mergedPredicate = new Predicate(getName(), getDirection()); mergedPredicate.setOwner(getOwner()); mergedPredicate.setHasBeenList(hasBeenList() || predicate2.hasBeenList()); mergedPredicate.setHasBeenSingular(isHasBeenSingular() || predicate2.isHasBeenSingular()); mergedPredicate.setSubjectsWithThisPredicateAsList(getSubjectsWithThisPredicateAsList() + predicate2.getSubjectsWithThisPredicateAsList()); Map<String, Long> mergedReferences = new HashMap<>(); for (Map.Entry<String, Long> entry : getReferenceTypes().entrySet()) { mergedReferences.put(entry.getKey(), entry.getValue()); } mergedPredicate.setReferenceTypes(mergedReferences); for (Map.Entry<String, Long> entry : predicate2.getReferenceTypes().entrySet()) { mergedPredicate.incReferenceType(entry.getKey(), entry.getValue()); } Map<String, Long> mergedValues = new HashMap<>(); for (Map.Entry<String, Long> entry : getValueTypes().entrySet()) { mergedValues.put(entry.getKey(), entry.getValue()); } mergedPredicate.setValueTypes(mergedValues); for (Map.Entry<String, Long> entry : predicate2.getValueTypes().entrySet()) { mergedPredicate.incValueType(entry.getKey(), entry.getValue()); } return mergedPredicate; } }
Predicate { @JsonIgnore public Predicate merge(Predicate predicate2) { if (getOwner() == null || predicate2.getOwner() == null) { throw new IllegalArgumentException("Predicate owner missing"); } if (!java.util.Objects.equals(getName(), predicate2.getName()) || getDirection() != predicate2.getDirection() || !java.util.Objects.equals(getOwner().getName(), predicate2.getOwner().getName())) { throw new IllegalArgumentException("Predicate name, direction and/or owner do not match"); } Predicate mergedPredicate = new Predicate(getName(), getDirection()); mergedPredicate.setOwner(getOwner()); mergedPredicate.setHasBeenList(hasBeenList() || predicate2.hasBeenList()); mergedPredicate.setHasBeenSingular(isHasBeenSingular() || predicate2.isHasBeenSingular()); mergedPredicate.setSubjectsWithThisPredicateAsList(getSubjectsWithThisPredicateAsList() + predicate2.getSubjectsWithThisPredicateAsList()); Map<String, Long> mergedReferences = new HashMap<>(); for (Map.Entry<String, Long> entry : getReferenceTypes().entrySet()) { mergedReferences.put(entry.getKey(), entry.getValue()); } mergedPredicate.setReferenceTypes(mergedReferences); for (Map.Entry<String, Long> entry : predicate2.getReferenceTypes().entrySet()) { mergedPredicate.incReferenceType(entry.getKey(), entry.getValue()); } Map<String, Long> mergedValues = new HashMap<>(); for (Map.Entry<String, Long> entry : getValueTypes().entrySet()) { mergedValues.put(entry.getKey(), entry.getValue()); } mergedPredicate.setValueTypes(mergedValues); for (Map.Entry<String, Long> entry : predicate2.getValueTypes().entrySet()) { mergedPredicate.incValueType(entry.getKey(), entry.getValue()); } return mergedPredicate; } @JsonCreator  Predicate(@JsonProperty("name") String name, @JsonProperty("direction") Direction direction); }
Predicate { @JsonIgnore public Predicate merge(Predicate predicate2) { if (getOwner() == null || predicate2.getOwner() == null) { throw new IllegalArgumentException("Predicate owner missing"); } if (!java.util.Objects.equals(getName(), predicate2.getName()) || getDirection() != predicate2.getDirection() || !java.util.Objects.equals(getOwner().getName(), predicate2.getOwner().getName())) { throw new IllegalArgumentException("Predicate name, direction and/or owner do not match"); } Predicate mergedPredicate = new Predicate(getName(), getDirection()); mergedPredicate.setOwner(getOwner()); mergedPredicate.setHasBeenList(hasBeenList() || predicate2.hasBeenList()); mergedPredicate.setHasBeenSingular(isHasBeenSingular() || predicate2.isHasBeenSingular()); mergedPredicate.setSubjectsWithThisPredicateAsList(getSubjectsWithThisPredicateAsList() + predicate2.getSubjectsWithThisPredicateAsList()); Map<String, Long> mergedReferences = new HashMap<>(); for (Map.Entry<String, Long> entry : getReferenceTypes().entrySet()) { mergedReferences.put(entry.getKey(), entry.getValue()); } mergedPredicate.setReferenceTypes(mergedReferences); for (Map.Entry<String, Long> entry : predicate2.getReferenceTypes().entrySet()) { mergedPredicate.incReferenceType(entry.getKey(), entry.getValue()); } Map<String, Long> mergedValues = new HashMap<>(); for (Map.Entry<String, Long> entry : getValueTypes().entrySet()) { mergedValues.put(entry.getKey(), entry.getValue()); } mergedPredicate.setValueTypes(mergedValues); for (Map.Entry<String, Long> entry : predicate2.getValueTypes().entrySet()) { mergedPredicate.incValueType(entry.getKey(), entry.getValue()); } return mergedPredicate; } @JsonCreator  Predicate(@JsonProperty("name") String name, @JsonProperty("direction") Direction direction); Map<String, Long> getReferenceTypes(); void setReferenceTypes(Map<String, Long> referenceTypes); Map<String, Long> getValueTypes(); void setValueTypes(Map<String, Long> valueTypes); @JsonIgnore Set<String> getUsedReferenceTypes(); @JsonIgnore Set<String> getUsedValueTypes(); void registerSubject(long occurrences); long getSubjectsWithThisPredicate(); @JsonIgnore boolean inUse(); @JsonIgnore boolean isExplicit(); String getName(); @JsonIgnore Type getOwner(); void setOwner(Type owner); long getSubjectsWithThisPredicateAsList(); void setSubjectsWithThisPredicateAsList(long occurrences); @JsonProperty("hasBeenList") boolean hasBeenList(); void setIsExplicit(boolean isExplicit); @JsonProperty("hasBeenList") void setHasBeenList(boolean hasBeenList); @JsonProperty("hasBeenSingular") boolean isHasBeenSingular(); @JsonProperty("hasBeenSingular") void setHasBeenSingular(boolean hasBeenSingular); @JsonIgnore boolean isList(); @Override String toString(); @Override boolean equals(Object obj); Direction getDirection(); void incValueType(String valueType, long mut); void incReferenceType(String referenceType, long mut); void registerListOccurrence(int mut); void finish(); @JsonIgnore Predicate merge(Predicate predicate2); }
Predicate { @JsonIgnore public Predicate merge(Predicate predicate2) { if (getOwner() == null || predicate2.getOwner() == null) { throw new IllegalArgumentException("Predicate owner missing"); } if (!java.util.Objects.equals(getName(), predicate2.getName()) || getDirection() != predicate2.getDirection() || !java.util.Objects.equals(getOwner().getName(), predicate2.getOwner().getName())) { throw new IllegalArgumentException("Predicate name, direction and/or owner do not match"); } Predicate mergedPredicate = new Predicate(getName(), getDirection()); mergedPredicate.setOwner(getOwner()); mergedPredicate.setHasBeenList(hasBeenList() || predicate2.hasBeenList()); mergedPredicate.setHasBeenSingular(isHasBeenSingular() || predicate2.isHasBeenSingular()); mergedPredicate.setSubjectsWithThisPredicateAsList(getSubjectsWithThisPredicateAsList() + predicate2.getSubjectsWithThisPredicateAsList()); Map<String, Long> mergedReferences = new HashMap<>(); for (Map.Entry<String, Long> entry : getReferenceTypes().entrySet()) { mergedReferences.put(entry.getKey(), entry.getValue()); } mergedPredicate.setReferenceTypes(mergedReferences); for (Map.Entry<String, Long> entry : predicate2.getReferenceTypes().entrySet()) { mergedPredicate.incReferenceType(entry.getKey(), entry.getValue()); } Map<String, Long> mergedValues = new HashMap<>(); for (Map.Entry<String, Long> entry : getValueTypes().entrySet()) { mergedValues.put(entry.getKey(), entry.getValue()); } mergedPredicate.setValueTypes(mergedValues); for (Map.Entry<String, Long> entry : predicate2.getValueTypes().entrySet()) { mergedPredicate.incValueType(entry.getKey(), entry.getValue()); } return mergedPredicate; } @JsonCreator  Predicate(@JsonProperty("name") String name, @JsonProperty("direction") Direction direction); Map<String, Long> getReferenceTypes(); void setReferenceTypes(Map<String, Long> referenceTypes); Map<String, Long> getValueTypes(); void setValueTypes(Map<String, Long> valueTypes); @JsonIgnore Set<String> getUsedReferenceTypes(); @JsonIgnore Set<String> getUsedValueTypes(); void registerSubject(long occurrences); long getSubjectsWithThisPredicate(); @JsonIgnore boolean inUse(); @JsonIgnore boolean isExplicit(); String getName(); @JsonIgnore Type getOwner(); void setOwner(Type owner); long getSubjectsWithThisPredicateAsList(); void setSubjectsWithThisPredicateAsList(long occurrences); @JsonProperty("hasBeenList") boolean hasBeenList(); void setIsExplicit(boolean isExplicit); @JsonProperty("hasBeenList") void setHasBeenList(boolean hasBeenList); @JsonProperty("hasBeenSingular") boolean isHasBeenSingular(); @JsonProperty("hasBeenSingular") void setHasBeenSingular(boolean hasBeenSingular); @JsonIgnore boolean isList(); @Override String toString(); @Override boolean equals(Object obj); Direction getDirection(); void incValueType(String valueType, long mut); void incReferenceType(String referenceType, long mut); void registerListOccurrence(int mut); void finish(); @JsonIgnore Predicate merge(Predicate predicate2);  }