@Test public void testFromImport() { assertEquals("fjdkjfkdjf", Source.fromImport("import \"fjdkjfkdjf\"")); assertEquals("fjdkjfkdjf", Source.fromImport("import 'fjdkjfkdjf'")); assertEquals(null, Source.fromImport("import fjdkjfkdjf")); }
protected static String fromImport(final String line) { return extractLiteralPart(line).flatMap(literal -> { for (final String quote : QUOTES) { if (literal.startsWith(quote) && literal.endsWith(quote)) { return of(literal.substring(quote.length(), literal.length() - quote.length()).trim()); } } return empty(); }).orElse(null); }
Source extends File { protected static String fromImport(final String line) { return extractLiteralPart(line).flatMap(literal -> { for (final String quote : QUOTES) { if (literal.startsWith(quote) && literal.endsWith(quote)) { return of(literal.substring(quote.length(), literal.length() - quote.length()).trim()); } } return empty(); }).orElse(null); } }
Source extends File { protected static String fromImport(final String line) { return extractLiteralPart(line).flatMap(literal -> { for (final String quote : QUOTES) { if (literal.startsWith(quote) && literal.endsWith(quote)) { return of(literal.substring(quote.length(), literal.length() - quote.length()).trim()); } } return empty(); }).orElse(null); } Source(final Project project, final String location); }
Source extends File { protected static String fromImport(final String line) { return extractLiteralPart(line).flatMap(literal -> { for (final String quote : QUOTES) { if (literal.startsWith(quote) && literal.endsWith(quote)) { return of(literal.substring(quote.length(), literal.length() - quote.length()).trim()); } } return empty(); }).orElse(null); } Source(final Project project, final String location); @Override List<Resource> getDependencies(final ResourceManager resourceManager); List<String> readImports(); Text getBody(); @Override int hashCode(); @Override boolean equals(Object obj); }
Source extends File { protected static String fromImport(final String line) { return extractLiteralPart(line).flatMap(literal -> { for (final String quote : QUOTES) { if (literal.startsWith(quote) && literal.endsWith(quote)) { return of(literal.substring(quote.length(), literal.length() - quote.length()).trim()); } } return empty(); }).orElse(null); } Source(final Project project, final String location); @Override List<Resource> getDependencies(final ResourceManager resourceManager); List<String> readImports(); Text getBody(); @Override int hashCode(); @Override boolean equals(Object obj);  }