Imports { @Nullable public Import find(@Nonnull final String typeName) { Check.notEmpty(typeName, "typeName"); Import ret = null; final Type type = new Type(typeName); for (final Import imp : imports) { if (imp.getType().getName().equals(type.getName())) { ret = imp; break; } } if (ret == null) { final Type javaLangType = Type.evaluateJavaLangType(typeName); if (javaLangType != null) { ret = Import.of(javaLangType); } } return ret; } private  Imports(final Iterable<Import> imports); static Imports allOf(@Nonnull final Clazz clazz); static Imports allOf(@Nonnull final Field field); static Imports allOf(@Nonnull final Method method); static Imports copyOf(final Iterable<Import> imports); static Imports of(final Import... imports); static Imports of(final Iterable<Import> imports); @Nonnull List<Import> asList(); @Nonnull Imports copyAndAdd(final Collection<Import> imports); @Nonnull Imports copyAndAdd(final Imports imports); @Nonnull Imports filter(); @Nullable Import find(@Nonnull final String typeName); @Nonnull Imports sortByName();  }
@Test public void find() { final List<Import> set = ImmutableList.of(Import.of(String.class), Import.of(Date.class), Import.of(Integer.class)); final Imports imports = Imports.copyOf(set); assertEquals(Import.of(String.class), imports.find("String")); assertEquals(Import.of(String.class), imports.find("java.lang.String")); assertEquals(Import.of(Date.class), imports.find("Date")); assertEquals(Import.of(Date.class), imports.find("java.util.Date")); assertEquals(Import.of(Integer.class), imports.find("Integer")); assertEquals(Import.of(Integer.class), imports.find("java.lang.Integer")); }