@Test public void of() { Assert.assertEquals(new CharStreamSource(Scheme.classpath, "/my/path"), CharStreamSource.of("classpath:/my/path")); Assert.assertEquals(new CharStreamSource(Scheme.file, "my/path"), CharStreamSource.of("file:my/path")); Assert.assertEquals(new CharStreamSource(Scheme.literal, " hello"), CharStreamSource.of("literal: hello")); Assert.assertEquals(new CharStreamSource(Scheme.literal, ""), CharStreamSource.of("literal:")); }
public static CharStreamSource of(String value) { for (Scheme scheme : Scheme.values()) { final String schemeName = scheme.name(); if (value.startsWith(schemeName)) { int len = schemeName.length(); if (value.length() >= len && value.charAt(len) == ':') { return new CharStreamSource(scheme, value.substring(len + 1)); } } } throw new IllegalArgumentException( String.format("Cannot parse [%s] to a " + CharStreamSource.class.getSimpleName(), value)); }
CharStreamSource { public static CharStreamSource of(String value) { for (Scheme scheme : Scheme.values()) { final String schemeName = scheme.name(); if (value.startsWith(schemeName)) { int len = schemeName.length(); if (value.length() >= len && value.charAt(len) == ':') { return new CharStreamSource(scheme, value.substring(len + 1)); } } } throw new IllegalArgumentException( String.format("Cannot parse [%s] to a " + CharStreamSource.class.getSimpleName(), value)); } }
CharStreamSource { public static CharStreamSource of(String value) { for (Scheme scheme : Scheme.values()) { final String schemeName = scheme.name(); if (value.startsWith(schemeName)) { int len = schemeName.length(); if (value.length() >= len && value.charAt(len) == ':') { return new CharStreamSource(scheme, value.substring(len + 1)); } } } throw new IllegalArgumentException( String.format("Cannot parse [%s] to a " + CharStreamSource.class.getSimpleName(), value)); } CharStreamSource(Scheme scheme, String resource); }
CharStreamSource { public static CharStreamSource of(String value) { for (Scheme scheme : Scheme.values()) { final String schemeName = scheme.name(); if (value.startsWith(schemeName)) { int len = schemeName.length(); if (value.length() >= len && value.charAt(len) == ':') { return new CharStreamSource(scheme, value.substring(len + 1)); } } } throw new IllegalArgumentException( String.format("Cannot parse [%s] to a " + CharStreamSource.class.getSimpleName(), value)); } CharStreamSource(Scheme scheme, String resource); static CharStreamSource defaultModelTransformer(); static CharStreamSource of(String value); @Override boolean equals(Object obj); String getResource(); Scheme getScheme(); @Override int hashCode(); Reader openReader(Charset encoding, Path resolveAgainst); @Override String toString(); }
CharStreamSource { public static CharStreamSource of(String value) { for (Scheme scheme : Scheme.values()) { final String schemeName = scheme.name(); if (value.startsWith(schemeName)) { int len = schemeName.length(); if (value.length() >= len && value.charAt(len) == ':') { return new CharStreamSource(scheme, value.substring(len + 1)); } } } throw new IllegalArgumentException( String.format("Cannot parse [%s] to a " + CharStreamSource.class.getSimpleName(), value)); } CharStreamSource(Scheme scheme, String resource); static CharStreamSource defaultModelTransformer(); static CharStreamSource of(String value); @Override boolean equals(Object obj); String getResource(); Scheme getScheme(); @Override int hashCode(); Reader openReader(Charset encoding, Path resolveAgainst); @Override String toString();  }