ProductItemToImage implements Function<ProductItem, Image> { public static Function<String, String> osVersion() { return new Function<String, String>() { @Override public String apply(final String description) { OsFamily family = osFamily().apply(description); if (Objects.equal(family, OsFamily.CENTOS)) return parseVersion(description, CENTOS); else if (Objects.equal(family, OsFamily.DEBIAN)) return parseVersion(description, DEBIAN); else if (Objects.equal(family, OsFamily.FEDORA)) return parseVersion(description, FEDORA); else if (Objects.equal(family, OsFamily.RHEL)) return parseVersion(description, RHEL); else if (Objects.equal(family, OsFamily.UBUNTU)) return parseVersion(description, UBUNTU); else if (Objects.equal(family, OsFamily.WINDOWS)) return parseVersion(description, WINDOWS); else if (Objects.equal(family, OsFamily.CLOUD_LINUX)) return parseVersion(description, CLOUD_LINUX); return null; } }; }  @Override Image apply(ProductItem productItem); static Function<String, OsFamily> osFamily(); static Function<String, String> osVersion(); static Function<String, Integer> osBits(); static Function<ProductItem, String> imageId();  }
@Test public void testOsVersion() { assertEquals("2099",osVersion().apply("Windows Server 2099 (256 bit)")); }