本文整理汇总了Java中com.google.common.reflect.ClassPath.ResourceInfo.getResourceName方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceInfo.getResourceName方法的具体用法?Java ResourceInfo.getResourceName怎么用?Java ResourceInfo.getResourceName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.reflect.ClassPath.ResourceInfo
的用法示例。
在下文中一共展示了ResourceInfo.getResourceName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ApiDocumentMetadata
import com.google.common.reflect.ClassPath.ResourceInfo; //导入方法依赖的package包/类
/**
*
* @param document The resource pointing to the document to be represented
* @param docSuffix The portion of the filename that should be removed for Title generation
*/
public ApiDocumentMetadata(ResourceInfo document, String docSuffix) {
this.document = document;
String name = document.getResourceName();
String title = name;
if (name.contains("/") && !name.endsWith("/")) {
name = name.substring(name.lastIndexOf("/") + 1);
title = StringUtils.capitalize(name).replace(docSuffix, "");
}
this.path = name;
this.title = title;
}
示例2: data
import com.google.common.reflect.ClassPath.ResourceInfo; //导入方法依赖的package包/类
@Parameters(name = "{index}: {0}")
public static Iterable<Object[]> data() throws IOException {
Path testDataPath = Paths.get("com/google/googlejavaformat/java/testdata");
ClassLoader classLoader = FormatterIntegrationTest.class.getClassLoader();
Map<String, String> inputs = new TreeMap<>();
Map<String, String> outputs = new TreeMap<>();
for (ResourceInfo resourceInfo : ClassPath.from(classLoader).getResources()) {
String resourceName = resourceInfo.getResourceName();
Path resourceNamePath = Paths.get(resourceName);
if (resourceNamePath.startsWith(testDataPath)) {
Path subPath = testDataPath.relativize(resourceNamePath);
assertEquals("bad testdata file names", 1, subPath.getNameCount());
String baseName = getNameWithoutExtension(subPath.getFileName().toString());
String extension = getFileExtension(subPath.getFileName().toString());
String contents;
try (InputStream stream =
FormatterIntegrationTest.class.getClassLoader().getResourceAsStream(resourceName)) {
contents = CharStreams.toString(new InputStreamReader(stream, UTF_8));
}
switch (extension) {
case "input":
inputs.put(baseName, contents);
break;
case "output":
outputs.put(baseName, contents);
break;
default:
}
}
}
List<Object[]> testInputs = new ArrayList<>();
assertEquals("unmatched inputs and outputs", inputs.size(), outputs.size());
for (Map.Entry<String, String> entry : inputs.entrySet()) {
String fileName = entry.getKey();
String input = inputs.get(fileName);
assertTrue("unmatched input", outputs.containsKey(fileName));
String expectedOutput = outputs.get(fileName);
testInputs.add(new Object[] {fileName, input, expectedOutput});
}
return testInputs;
}