FunctionInputDef extends Annotated { public IVarDef findVarPath( String pathName) { String[] path = DefUtils.toPath( pathName); IVarDef var; return path == null? null : (var = getVarDef( StringUtils.trimToNull( path[0]))) == null? null : var.find( Arrays.copyOfRange( path, 1, path.length)); } FunctionInputDef();  FunctionInputDef( String name); void setName( String name); String getName(); FunctionInputDef addVarDef( IVarDef varDef); FunctionInputDef removeVarDef( String name); IVarDef getVarDef( String name); Iterator<IVarDef> getVarDefs(); String[] getVarTypes(); IVarDef findVarPath( String pathName); VarDef findVarDefPath( String pathName); int hashCode(); boolean equals( Object object); String toString();  }
@Test public void findVarPath_Unknown() { FunctionInputDefBuilder functionInputDefBuilder = new FunctionInputDefBuilder(); functionInputDefBuilder.varDefAtPath( "A.B.C.D"); FunctionInputDef functionInputDef = functionInputDefBuilder.build(); IVarDef var; var = functionInputDef.findVarPath( "X"); assertThat( "Unknown start", var, is( (Object) null)); var = functionInputDef.findVarPath( "A.B.D"); assertThat( "Unknown middle", var, is( (Object) null)); var = functionInputDef.findVarPath( "A.B.C.D.E"); assertThat( "Unknown end", var, is( (Object) null)); var = functionInputDef.findVarPath( null); assertThat( "Null", var, is( (Object) null)); }
@Test public void findVarPath_VarDef() { FunctionInputDefBuilder functionInputDefBuilder = new FunctionInputDefBuilder(); functionInputDefBuilder.varDefAtPath( "A.B.C.D"); FunctionInputDef functionInputDef = functionInputDefBuilder.build(); IVarDef var; var = functionInputDef.findVarPath( "A.B.C.D"); assertThat( "Descendant", var.getPathName(), is( "A.B.C.D")); functionInputDefBuilder.varDefAtPath( "X"); functionInputDef = functionInputDefBuilder.build(); var = functionInputDef.findVarPath( "X"); assertThat( "Top-level", var.getPathName(), is( "X")); }
@Test public void findVarPath_VarSet() { FunctionInputDefBuilder functionInputDefBuilder = new FunctionInputDefBuilder(); functionInputDefBuilder.varDefAtPath( "A.B.C.D"); FunctionInputDef functionInputDef = functionInputDefBuilder.build(); IVarDef var; var = functionInputDef.findVarPath( "A.B.C"); assertThat( "Descendant", var.getPathName(), is( "A.B.C")); var = functionInputDef.findVarPath( "A"); assertThat( "Top-level", var.getPathName(), is( "A")); }