public static List<String> relativize( List<String> from, List<String> to ) { if ( from.equals( Collections.singletonList( "" ) )) { return to; } List<String> ret = new ArrayList<>(); int suf = findCommenSuffix( from, to ); int i; for ( i= 0 ; i < from.size()-suf; i++ ) { ret.add( ".." ); } for ( i= suf ; i < to.size(); i++ ) { ret.add( to.get( i ) ); } if ( ret.isEmpty() ) { return Collections.singletonList(""); } return ret; } }
public Path _relativize( Path other ) { EightyPath eightOther = checkOther( other ); if( isAbsolute() != eightOther.isAbsolute() ) { throw new IllegalArgumentException( "'other' is different type of Path" ); } return new EightyPath( fileSystem, Optional.empty(), false, Relativize.relativize( elems, eightOther.elems ) ); }