@Test public void isCanonicalClassNameUsed_A$String$String$ClassMeta_ImportWildCard() throws Exception { String expectedCanonicalClassName = "com.example.bean.SampleBean"; String usedClassName = "SampleBean"; ClassMeta targetClassMeta = new ClassMeta(); targetClassMeta.importedList.add("com.example.bean.*"); boolean actual = GeneratorImplFunction.isCanonicalClassNameUsed(expectedCanonicalClassName, usedClassName, targetClassMeta); boolean expected = true; assertThat(actual, is(equalTo(expected))); }
static boolean isCanonicalClassNameUsed(String expectedCanonicalClassName, String usedClassName, ClassMeta targetClassMeta) { Assertion.on("expectedCanonicalClassName").mustNotBeNull(expectedCanonicalClassName); Assertion.on("usedClassName").mustNotBeNull(usedClassName); Assertion.on("targetClassMeta").mustNotBeNull(targetClassMeta); if (usedClassName.equals(expectedCanonicalClassName) || usedClassName.equals(expectedCanonicalClassName.replace("java.lang.", ""))) { return true; } else { String[] extSplitted = expectedCanonicalClassName.split("\\."); String extClassName = extSplitted[extSplitted.length - 1]; if (usedClassName.equals(extClassName)) { String extInSamplePackage = targetClassMeta.packageName + "." + extClassName; if (extInSamplePackage.equals(expectedCanonicalClassName)) { return true; } else { for (String imported : targetClassMeta.importedList) { String target = expectedCanonicalClassName.replaceFirst(extClassName, ""); if (imported.matches(expectedCanonicalClassName) || imported.matches(target + ".+")) { return true; } } } } } return false; }
GeneratorImplFunction { static boolean isCanonicalClassNameUsed(String expectedCanonicalClassName, String usedClassName, ClassMeta targetClassMeta) { Assertion.on("expectedCanonicalClassName").mustNotBeNull(expectedCanonicalClassName); Assertion.on("usedClassName").mustNotBeNull(usedClassName); Assertion.on("targetClassMeta").mustNotBeNull(targetClassMeta); if (usedClassName.equals(expectedCanonicalClassName) || usedClassName.equals(expectedCanonicalClassName.replace("java.lang.", ""))) { return true; } else { String[] extSplitted = expectedCanonicalClassName.split("\\."); String extClassName = extSplitted[extSplitted.length - 1]; if (usedClassName.equals(extClassName)) { String extInSamplePackage = targetClassMeta.packageName + "." + extClassName; if (extInSamplePackage.equals(expectedCanonicalClassName)) { return true; } else { for (String imported : targetClassMeta.importedList) { String target = expectedCanonicalClassName.replaceFirst(extClassName, ""); if (imported.matches(expectedCanonicalClassName) || imported.matches(target + ".+")) { return true; } } } } } return false; } }
GeneratorImplFunction { static boolean isCanonicalClassNameUsed(String expectedCanonicalClassName, String usedClassName, ClassMeta targetClassMeta) { Assertion.on("expectedCanonicalClassName").mustNotBeNull(expectedCanonicalClassName); Assertion.on("usedClassName").mustNotBeNull(usedClassName); Assertion.on("targetClassMeta").mustNotBeNull(targetClassMeta); if (usedClassName.equals(expectedCanonicalClassName) || usedClassName.equals(expectedCanonicalClassName.replace("java.lang.", ""))) { return true; } else { String[] extSplitted = expectedCanonicalClassName.split("\\."); String extClassName = extSplitted[extSplitted.length - 1]; if (usedClassName.equals(extClassName)) { String extInSamplePackage = targetClassMeta.packageName + "." + extClassName; if (extInSamplePackage.equals(expectedCanonicalClassName)) { return true; } else { for (String imported : targetClassMeta.importedList) { String target = expectedCanonicalClassName.replaceFirst(extClassName, ""); if (imported.matches(expectedCanonicalClassName) || imported.matches(target + ".+")) { return true; } } } } } return false; } private  GeneratorImplFunction(); }
GeneratorImplFunction { static boolean isCanonicalClassNameUsed(String expectedCanonicalClassName, String usedClassName, ClassMeta targetClassMeta) { Assertion.on("expectedCanonicalClassName").mustNotBeNull(expectedCanonicalClassName); Assertion.on("usedClassName").mustNotBeNull(usedClassName); Assertion.on("targetClassMeta").mustNotBeNull(targetClassMeta); if (usedClassName.equals(expectedCanonicalClassName) || usedClassName.equals(expectedCanonicalClassName.replace("java.lang.", ""))) { return true; } else { String[] extSplitted = expectedCanonicalClassName.split("\\."); String extClassName = extSplitted[extSplitted.length - 1]; if (usedClassName.equals(extClassName)) { String extInSamplePackage = targetClassMeta.packageName + "." + extClassName; if (extInSamplePackage.equals(expectedCanonicalClassName)) { return true; } else { for (String imported : targetClassMeta.importedList) { String target = expectedCanonicalClassName.replaceFirst(extClassName, ""); if (imported.matches(expectedCanonicalClassName) || imported.matches(target + ".+")) { return true; } } } } } return false; } private  GeneratorImplFunction();  }
GeneratorImplFunction { static boolean isCanonicalClassNameUsed(String expectedCanonicalClassName, String usedClassName, ClassMeta targetClassMeta) { Assertion.on("expectedCanonicalClassName").mustNotBeNull(expectedCanonicalClassName); Assertion.on("usedClassName").mustNotBeNull(usedClassName); Assertion.on("targetClassMeta").mustNotBeNull(targetClassMeta); if (usedClassName.equals(expectedCanonicalClassName) || usedClassName.equals(expectedCanonicalClassName.replace("java.lang.", ""))) { return true; } else { String[] extSplitted = expectedCanonicalClassName.split("\\."); String extClassName = extSplitted[extSplitted.length - 1]; if (usedClassName.equals(extClassName)) { String extInSamplePackage = targetClassMeta.packageName + "." + extClassName; if (extInSamplePackage.equals(expectedCanonicalClassName)) { return true; } else { for (String imported : targetClassMeta.importedList) { String target = expectedCanonicalClassName.replaceFirst(extClassName, ""); if (imported.matches(expectedCanonicalClassName) || imported.matches(target + ".+")) { return true; } } } } } return false; } private  GeneratorImplFunction();   }