File tree Expand file tree Collapse file tree
src/main/java/org/variantsync/diffdetective/variation/diff/serialize/nodeformat Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package org .variantsync .diffdetective .variation .diff .serialize .nodeformat ;
2+
3+ import java .util .ArrayList ;
4+ import java .util .List ;
5+
6+ import org .variantsync .diffdetective .variation .Label ;
7+ import org .variantsync .diffdetective .variation .diff .DiffNode ;
8+ import org .variantsync .diffdetective .variation .diff .Time ;
9+ import org .variantsync .functjonal .Cast ;
10+
11+ /**
12+ * Labels nodes using their index in their parent list at all times.
13+ */
14+ public class IndexFormat <L extends Label > implements DiffNodeLabelFormat <L > {
15+ @ Override
16+ public String toLabel (final DiffNode <? extends L > n ) {
17+ final DiffNode <L > node = Cast .unchecked (n );
18+ final Time [] allTimes = Time .values ();
19+ final List <String > values = new ArrayList <>(allTimes .length );
20+ for (final Time t : allTimes ) {
21+ values .add (node .getDiffType ().existsAtTime (t ) && !node .isRoot ()
22+ ? Integer .toString (node .getParent (t ).indexOfChild (node , t ))
23+ : "_" );
24+ }
25+ return "(" + String .join (", " , values ) + ")" ;
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments