ProductItemToImage implements Function<ProductItem, Image> { public static Function<String, OsFamily> osFamily() { return new Function<String, OsFamily>() { @Override public OsFamily apply(final String description) { if (description != null) { if (description.startsWith(CENTOS)) return OsFamily.CENTOS; else if (description.startsWith(DEBIAN)) return OsFamily.DEBIAN; else if (description.startsWith(FEDORA)) return OsFamily.FEDORA; else if (description.startsWith(RHEL)) return OsFamily.RHEL; else if (description.startsWith(UBUNTU)) return OsFamily.UBUNTU; else if (description.startsWith(WINDOWS)) return OsFamily.WINDOWS; else if (description.startsWith(CLOUD_LINUX)) return OsFamily.CLOUD_LINUX; } return OsFamily.UNRECOGNIZED; } }; }  @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 testOsFamily() { assertEquals(OsFamily.UBUNTU,osFamily().apply("Ubuntu Linux os")); }