示例#1
0
 public static Imports allOf(@Nonnull final Field field) {
   Check.notNull(field, "field");
   final List<Import> imports = Lists.newArrayList();
   imports.add(Import.of(field));
   imports.addAll(ofAnnotations(field.getAnnotations()).asList());
   return new Imports(imports);
 }
示例#2
0
 public static Imports allOf(@Nonnull final Method method) {
   Check.notNull(method, "method");
   final List<Import> imports = Lists.newArrayList();
   imports.add(Import.of(method.getReturnType().getType()));
   imports.addAll(ofAnnotations(method.getAnnotations()).asList());
   return new Imports(imports);
 }
示例#3
0
 private static Imports ofInterfaces(@Nonnull final Iterable<Interface> interfaces) {
   Check.notNull(interfaces, "interfaces");
   final List<Import> imports = Lists.newArrayList();
   for (final Interface i : interfaces) {
     imports.add(Import.of(i));
   }
   return new Imports(imports);
 }
示例#4
0
 private static Imports ofFields(@Nonnull final Iterable<Field> fields) {
   Check.notNull(fields, "fields");
   final List<Import> imports = Lists.newArrayList();
   for (final Field field : fields) {
     imports.add(Import.of(field));
   }
   return new Imports(imports);
 }
示例#5
0
 private static Imports ofAttributes(@Nonnull final Iterable<Attribute> attributes) {
   Check.notNull(attributes, "attributes");
   final List<Import> imports = Lists.newArrayList();
   for (final Attribute attribute : attributes) {
     imports.add(Import.of(attribute));
   }
   return new Imports(imports);
 }
示例#6
0
 private static Imports ofAnnotations(@Nonnull final Iterable<Annotation> annotations) {
   Check.notNull(annotations, "annotations");
   final List<Import> imports = Lists.newArrayList();
   for (final Annotation annotation : annotations) {
     imports.add(Import.of(annotation));
   }
   return new Imports(imports);
 }
示例#7
0
 /**
  * Searches the set of imports to find a matching import by type name.
  *
  * @param typeName name of type (qualified or simple name allowed)
  * @return found import or {@code null}
  */
 @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;
 }