-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Specify hierarchical loop identifiers via schema instead of hard-coding
- Loading branch information
Showing
24 changed files
with
2,495 additions
and
2,108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/java/io/xlate/edi/internal/schema/ElementPosition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package io.xlate.edi.internal.schema; | ||
|
||
import java.util.Objects; | ||
|
||
import io.xlate.edi.schema.EDIElementPosition; | ||
|
||
public class ElementPosition implements EDIElementPosition { | ||
|
||
private static final String TOSTRING_FORMAT = "%d.%d"; | ||
private final int elementPosition; | ||
private final int componentPosition; | ||
|
||
public ElementPosition(int elementPosition, int componentPosition) { | ||
super(); | ||
this.elementPosition = elementPosition; | ||
this.componentPosition = componentPosition; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
|
||
if (!getClass().isInstance(o)) { | ||
return false; | ||
} | ||
|
||
ElementPosition other = (ElementPosition) o; | ||
|
||
return Objects.equals(elementPosition, other.elementPosition) && | ||
Objects.equals(componentPosition, other.componentPosition); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(elementPosition, componentPosition); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format(TOSTRING_FORMAT, elementPosition, componentPosition); | ||
} | ||
|
||
@Override | ||
public int getElementPosition() { | ||
return elementPosition; | ||
} | ||
|
||
@Override | ||
public int getComponentPosition() { | ||
return componentPosition > 0 ? componentPosition : -1; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.xlate.edi.internal.schema; | ||
|
||
import java.util.List; | ||
|
||
import io.xlate.edi.schema.EDIElementPosition; | ||
import io.xlate.edi.schema.EDILoopType; | ||
import io.xlate.edi.schema.EDIReference; | ||
import io.xlate.edi.schema.EDISyntaxRule; | ||
import io.xlate.edi.schema.EDIType; | ||
|
||
@SuppressWarnings("java:S2160") // Intentionally inherit 'equals' from superclass | ||
class LoopType extends StructureType implements EDILoopType { | ||
|
||
private final EDIElementPosition levelIdPosition; | ||
private final EDIElementPosition parentIdPosition; | ||
|
||
LoopType(String code, | ||
List<EDIReference> references, | ||
List<EDISyntaxRule> syntaxRules, | ||
EDIElementPosition levelIdPosition, | ||
EDIElementPosition parentIdPosition, | ||
String title, | ||
String description) { | ||
|
||
super(code, EDIType.Type.LOOP, code, references, syntaxRules, title, description); | ||
this.levelIdPosition = levelIdPosition; | ||
this.parentIdPosition = parentIdPosition; | ||
} | ||
|
||
@Override | ||
public EDIElementPosition getLevelIdPosition() { | ||
return levelIdPosition; | ||
} | ||
|
||
@Override | ||
public EDIElementPosition getParentIdPosition() { | ||
return parentIdPosition; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.