@Test public void testIsAncestorOrSame() throws Exception{ URI ancestor = new URI("etl-hdfs: URI descendant = new URI("etl-hdfs: Assert.assertTrue(ConfigClientUtils.isAncestorOrSame(descendant, ancestor)); descendant = new URI("etl-hdfs: Assert.assertTrue(ConfigClientUtils.isAncestorOrSame(descendant, ancestor)); descendant = new URI("etl-hdfs: Assert.assertTrue(!ConfigClientUtils.isAncestorOrSame(descendant, ancestor)); descendant = new URI("etl-hdfs: Assert.assertTrue(!ConfigClientUtils.isAncestorOrSame(descendant, ancestor)); ConfigKeyPath data = SingleLinkedListConfigKeyPath.ROOT.createChild("data"); ConfigKeyPath data2 = SingleLinkedListConfigKeyPath.ROOT.createChild("data2"); ConfigKeyPath identity = SingleLinkedListConfigKeyPath.ROOT.createChild("data").createChild("databases").createChild("Identity"); Assert.assertTrue(ConfigClientUtils.isAncestorOrSame(identity, data)); Assert.assertTrue(ConfigClientUtils.isAncestorOrSame(identity, SingleLinkedListConfigKeyPath.ROOT)); Assert.assertTrue(!ConfigClientUtils.isAncestorOrSame(identity, data2)); }
public static boolean isAncestorOrSame(URI descendant, URI ancestor) { Preconditions.checkNotNull(descendant, "input can not be null"); Preconditions.checkNotNull(ancestor, "input can not be null"); if (!stringSame(descendant.getScheme(), ancestor.getScheme())) { return false; } if (!stringSame(descendant.getAuthority(), ancestor.getAuthority())) { return false; } return isAncestorOrSame(getConfigKeyPath(descendant.getPath()), getConfigKeyPath(ancestor.getPath())); }
ConfigClientUtils { public static boolean isAncestorOrSame(URI descendant, URI ancestor) { Preconditions.checkNotNull(descendant, "input can not be null"); Preconditions.checkNotNull(ancestor, "input can not be null"); if (!stringSame(descendant.getScheme(), ancestor.getScheme())) { return false; } if (!stringSame(descendant.getAuthority(), ancestor.getAuthority())) { return false; } return isAncestorOrSame(getConfigKeyPath(descendant.getPath()), getConfigKeyPath(ancestor.getPath())); } }
ConfigClientUtils { public static boolean isAncestorOrSame(URI descendant, URI ancestor) { Preconditions.checkNotNull(descendant, "input can not be null"); Preconditions.checkNotNull(ancestor, "input can not be null"); if (!stringSame(descendant.getScheme(), ancestor.getScheme())) { return false; } if (!stringSame(descendant.getAuthority(), ancestor.getAuthority())) { return false; } return isAncestorOrSame(getConfigKeyPath(descendant.getPath()), getConfigKeyPath(ancestor.getPath())); }  }
ConfigClientUtils { public static boolean isAncestorOrSame(URI descendant, URI ancestor) { Preconditions.checkNotNull(descendant, "input can not be null"); Preconditions.checkNotNull(ancestor, "input can not be null"); if (!stringSame(descendant.getScheme(), ancestor.getScheme())) { return false; } if (!stringSame(descendant.getAuthority(), ancestor.getAuthority())) { return false; } return isAncestorOrSame(getConfigKeyPath(descendant.getPath()), getConfigKeyPath(ancestor.getPath())); }  static ConfigKeyPath buildConfigKeyPath(URI configKeyURI, ConfigStore cs); static URI buildUriInClientFormat(ConfigKeyPath configKeyPath, ConfigStore cs, boolean returnURIWithAuthority); static Collection<URI> buildUriInClientFormat(Collection<ConfigKeyPath> configKeyPaths, ConfigStore cs,
      boolean returnURIWithAuthority); static ConfigKeyPath getConfigKeyPath(String input); static List<ConfigKeyPath> getConfigKeyPath(List<String> input); static boolean isAncestorOrSame(URI descendant, URI ancestor); static boolean stringSame(String l, String r); static boolean isAncestorOrSame(ConfigKeyPath descendant, ConfigKeyPath ancestor); static Optional<Config> getOptionalRuntimeConfig(Properties properties); }
ConfigClientUtils { public static boolean isAncestorOrSame(URI descendant, URI ancestor) { Preconditions.checkNotNull(descendant, "input can not be null"); Preconditions.checkNotNull(ancestor, "input can not be null"); if (!stringSame(descendant.getScheme(), ancestor.getScheme())) { return false; } if (!stringSame(descendant.getAuthority(), ancestor.getAuthority())) { return false; } return isAncestorOrSame(getConfigKeyPath(descendant.getPath()), getConfigKeyPath(ancestor.getPath())); }  static ConfigKeyPath buildConfigKeyPath(URI configKeyURI, ConfigStore cs); static URI buildUriInClientFormat(ConfigKeyPath configKeyPath, ConfigStore cs, boolean returnURIWithAuthority); static Collection<URI> buildUriInClientFormat(Collection<ConfigKeyPath> configKeyPaths, ConfigStore cs,
      boolean returnURIWithAuthority); static ConfigKeyPath getConfigKeyPath(String input); static List<ConfigKeyPath> getConfigKeyPath(List<String> input); static boolean isAncestorOrSame(URI descendant, URI ancestor); static boolean stringSame(String l, String r); static boolean isAncestorOrSame(ConfigKeyPath descendant, ConfigKeyPath ancestor); static Optional<Config> getOptionalRuntimeConfig(Properties properties);  }