@Test void getConverterFromFileName() { PolicyConverterTest textExtConverter = new PolicyConverterTest(".test.ext", "test"); PolicyConverterRegistry policyConverterRegistry = new PolicyConverterRegistry(ImmutableSet.of(textExtConverter)); assertEquals(textExtConverter, policyConverterRegistry.getConverterFromFileName("hello.test.ext")); assertThrows(PolicyConverterException.class, () -> policyConverterRegistry.getConverterFromFileName("hello.test")); }
@NotNull public PolicyConverter getConverterFromFileName(String fileName) { return policyConverters.stream() .filter(converter -> fileName.endsWith(converter.getPolicyTypeExtension())) .findFirst().orElseThrow(() -> new PolicyConverterException("Unknown policy file extension for file: " + fileName)); }
PolicyConverterRegistry { @NotNull public PolicyConverter getConverterFromFileName(String fileName) { return policyConverters.stream() .filter(converter -> fileName.endsWith(converter.getPolicyTypeExtension())) .findFirst().orElseThrow(() -> new PolicyConverterException("Unknown policy file extension for file: " + fileName)); } }
PolicyConverterRegistry { @NotNull public PolicyConverter getConverterFromFileName(String fileName) { return policyConverters.stream() .filter(converter -> fileName.endsWith(converter.getPolicyTypeExtension())) .findFirst().orElseThrow(() -> new PolicyConverterException("Unknown policy file extension for file: " + fileName)); } @Inject  PolicyConverterRegistry(final Set<PolicyConverter> converters); }
PolicyConverterRegistry { @NotNull public PolicyConverter getConverterFromFileName(String fileName) { return policyConverters.stream() .filter(converter -> fileName.endsWith(converter.getPolicyTypeExtension())) .findFirst().orElseThrow(() -> new PolicyConverterException("Unknown policy file extension for file: " + fileName)); } @Inject  PolicyConverterRegistry(final Set<PolicyConverter> converters); @NotNull boolean isValidPolicyExtension(String fileName); @NotNull PolicyConverter getConverterFromFileName(String fileName); @NotNull PolicyConverter getFromPolicyElement(String name, Element policy); }
PolicyConverterRegistry { @NotNull public PolicyConverter getConverterFromFileName(String fileName) { return policyConverters.stream() .filter(converter -> fileName.endsWith(converter.getPolicyTypeExtension())) .findFirst().orElseThrow(() -> new PolicyConverterException("Unknown policy file extension for file: " + fileName)); } @Inject  PolicyConverterRegistry(final Set<PolicyConverter> converters); @NotNull boolean isValidPolicyExtension(String fileName); @NotNull PolicyConverter getConverterFromFileName(String fileName); @NotNull PolicyConverter getFromPolicyElement(String name, Element policy);  }