@Test public void testComputeInstancePath() { Instance instance1 = new Instance(); Assert.assertEquals( "/", InstanceHelpers.computeInstancePath( instance1 )); instance1.setName( "inst1" ); Assert.assertEquals( "/inst1", InstanceHelpers.computeInstancePath( instance1 )); Instance instance2 = new Instance( "inst2" ); Assert.assertEquals( "/inst2", InstanceHelpers.computeInstancePath( instance2 )); instance1.getChildren().add( instance2 ); instance2.setParent( instance1 ); Assert.assertEquals( "/inst1", InstanceHelpers.computeInstancePath( instance1 )); Assert.assertEquals( "/inst1/inst2", InstanceHelpers.computeInstancePath( instance2 )); }
public static String computeInstancePath( Instance inst ) { StringBuilder sb = new StringBuilder(); for( Instance current = inst; current != null; current = current.getParent()) { StringBuilder currentSb = new StringBuilder( "/" ); if( ! Utils.isEmptyOrWhitespaces( current.getName())) currentSb.append( current.getName()); sb.insert( 0, currentSb.toString()); } return sb.toString(); }
InstanceHelpers { public static String computeInstancePath( Instance inst ) { StringBuilder sb = new StringBuilder(); for( Instance current = inst; current != null; current = current.getParent()) { StringBuilder currentSb = new StringBuilder( "/" ); if( ! Utils.isEmptyOrWhitespaces( current.getName())) currentSb.append( current.getName()); sb.insert( 0, currentSb.toString()); } return sb.toString(); } }
InstanceHelpers { public static String computeInstancePath( Instance inst ) { StringBuilder sb = new StringBuilder(); for( Instance current = inst; current != null; current = current.getParent()) { StringBuilder currentSb = new StringBuilder( "/" ); if( ! Utils.isEmptyOrWhitespaces( current.getName())) currentSb.append( current.getName()); sb.insert( 0, currentSb.toString()); } return sb.toString(); } private  InstanceHelpers(); }
InstanceHelpers { public static String computeInstancePath( Instance inst ) { StringBuilder sb = new StringBuilder(); for( Instance current = inst; current != null; current = current.getParent()) { StringBuilder currentSb = new StringBuilder( "/" ); if( ! Utils.isEmptyOrWhitespaces( current.getName())) currentSb.append( current.getName()); sb.insert( 0, currentSb.toString()); } return sb.toString(); } private  InstanceHelpers(); static String computeInstancePath( Instance inst ); static boolean haveSamePath( Instance i1, Instance i2 ); static String findInstanceName( String instancePath ); static List<Instance> buildHierarchicalList( Instance inst ); static void insertChild( Instance parent, Instance child ); static Map<String,String> findAllExportedVariables( Instance instance ); static Instance findInstanceByPath( AbstractApplication application, String instancePath ); static Instance findInstanceByPath( Instance rootInstance, String instancePath ); static List<Instance> findInstancesByComponentName( AbstractApplication application, String componentName ); static Instance findRootInstance( Instance instance ); static Instance findScopedInstance( Instance instance ); static List<Instance> findAllScopedInstances( AbstractApplication app ); static List<Instance> getAllInstances( AbstractApplication application ); static boolean tryToInsertChildInstance( AbstractApplication application, Instance parentInstance, Instance childInstance ); static boolean hasChildWithThisName( AbstractApplication application, Instance parentInstance, String nameToSearch ); static File findInstanceDirectoryOnAgent( Instance instance ); static int countInstances( String instancePath ); static Instance replicateInstance( Instance instance ); static boolean isTarget( Instance instance ); static void removeOffScopeInstances( Instance scopedInstance ); static String findRootInstancePath( String scopedInstancePath ); static void fixOverriddenExports( Instance instance ); }
InstanceHelpers { public static String computeInstancePath( Instance inst ) { StringBuilder sb = new StringBuilder(); for( Instance current = inst; current != null; current = current.getParent()) { StringBuilder currentSb = new StringBuilder( "/" ); if( ! Utils.isEmptyOrWhitespaces( current.getName())) currentSb.append( current.getName()); sb.insert( 0, currentSb.toString()); } return sb.toString(); } private  InstanceHelpers(); static String computeInstancePath( Instance inst ); static boolean haveSamePath( Instance i1, Instance i2 ); static String findInstanceName( String instancePath ); static List<Instance> buildHierarchicalList( Instance inst ); static void insertChild( Instance parent, Instance child ); static Map<String,String> findAllExportedVariables( Instance instance ); static Instance findInstanceByPath( AbstractApplication application, String instancePath ); static Instance findInstanceByPath( Instance rootInstance, String instancePath ); static List<Instance> findInstancesByComponentName( AbstractApplication application, String componentName ); static Instance findRootInstance( Instance instance ); static Instance findScopedInstance( Instance instance ); static List<Instance> findAllScopedInstances( AbstractApplication app ); static List<Instance> getAllInstances( AbstractApplication application ); static boolean tryToInsertChildInstance( AbstractApplication application, Instance parentInstance, Instance childInstance ); static boolean hasChildWithThisName( AbstractApplication application, Instance parentInstance, String nameToSearch ); static File findInstanceDirectoryOnAgent( Instance instance ); static int countInstances( String instancePath ); static Instance replicateInstance( Instance instance ); static boolean isTarget( Instance instance ); static void removeOffScopeInstances( Instance scopedInstance ); static String findRootInstancePath( String scopedInstancePath ); static void fixOverriddenExports( Instance instance );  }