Skip to content

Commit

Permalink
Update tagged profile merger
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximPlusov committed Oct 11, 2024
1 parent 40f5d8a commit 8ea8f33
Showing 1 changed file with 12 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,10 @@ private RuleData constructZeroOrOne(ParsedRelationStructure rel) {
}

String childTest = constructChildElemAmountPart(child) + " <= 1";
String testObj;

String parent = rel.getParent();
switch (parent) {
case STRUCT_TREE_ROOT:
testObj = STRUCT_TREE_ROOT_OBJECT;
break;
default:
testObj = String.format(STRUCT_ELEM_FORMAT, parent);
}

String testObj = getTestObject(parent);

return new RuleData(testObj, childTest,
getDescriptionOrErrorMessage(ZERO_OR_ONE_DESCRIPTION_FORMAT, parent, child),
getDescriptionOrErrorMessage(ZERO_OR_ONE_ERROR_FORMAT, parent, child));
Expand All @@ -252,16 +245,9 @@ private RuleData constructOne(ParsedRelationStructure rel) {
}

String childTest = constructChildElemAmountPart(child) + " == 1";
String testObj;

String parent = rel.getParent();
switch (parent) {
case STRUCT_TREE_ROOT:
testObj = STRUCT_TREE_ROOT_OBJECT;
break;
default:
testObj = String.format(STRUCT_ELEM_FORMAT, parent);
}
String testObj = getTestObject(parent);

return new RuleData(testObj, childTest,
getDescriptionOrErrorMessage(ONE_DESCRIPTION_FORMAT, parent, child),
Expand All @@ -281,14 +267,7 @@ private RuleData constructAtLeastOne(ParsedRelationStructure rel) {
childTest = constructChildElemAmountPart(child) + " > 0";
}

String testObj;
switch (parent) {
case STRUCT_TREE_ROOT:
testObj = STRUCT_TREE_ROOT_OBJECT;
break;
default:
testObj = String.format(STRUCT_ELEM_FORMAT, parent);
}
String testObj = getTestObject(parent);

return new RuleData(testObj, childTest,
getDescriptionOrErrorMessage(AT_LEAST_ONE_DESCRIPTION_FORMAT, parent, child),
Expand All @@ -303,8 +282,8 @@ private RuleData constructForbidden(ParsedRelationStructure rel) {
String testObj;
switch (child) {
case CONTENT_ITEM:
testObj = getTestObject(parent);
childTest = "hasContentItems == false";
testObj = String.format(STRUCT_ELEM_FORMAT, parent);
break;
default:
if (HN.equals(parent)) {
Expand Down Expand Up @@ -338,6 +317,13 @@ private String getStringRepresentation(String string) {
}
return "<" + string + ">";
}

private String getTestObject(String object) {
if (STRUCT_TREE_ROOT.equals(object)) {
return STRUCT_TREE_ROOT_OBJECT;
}
return String.format(STRUCT_ELEM_FORMAT, object);
}

private String constructChildElemAmountPart(String child) {
switch (child) {
Expand Down

0 comments on commit 8ea8f33

Please sign in to comment.