Filters primitive types, types without a package declaration and duplicates and returns them as new instance of
{@code Imports}.

@return new instance of {@code Imports}
341135
@Nonnull
	public Imports filter() {
		return new Imports(Sets.newHashSet(Collections2.filter(imports, Predicates.and(IGNORE_JAVA_LANG, IGNORE_UNDEFINED))));
	}
1301568
def copy(self):
        
        other = PackageFilterList.__new__(PackageFilterList)
        other.filters = [x.copy() for x in self.filters]
        return other
460854
private static Converter<List<String>, Object> createListConverter(Type resultType) {
    // Use boxed type if raw type is primitive type. Otherwise the type won't change.
    Class<?> resultClass = getRawClass(resultType);

    // For string, just return the first value
    if (resultClass == String.class) {
      return new BasicConverter(defaultValue(resultClass)) {
        @Override
        protected Object convert(String value) throws Exception {
          return value;
        }
      };
    }

    // Creates converter based on the type

    // Primitive
    Converter<List<String>, Object> converter = createPrimitiveTypeConverter(resultClass);
    if (converter != null) {
      return converter;
    }

    // String constructor
    converter = createStringConstructorConverter(resultClass);
    if (converter != null) {
      return converter;
    }

    // Static string argument methods
    converter = createStringMethodConverter(resultClass);
    if (converter != null) {
      return converter;
    }

    // Collection
    converter = createCollectionConverter(resultType);
    if (converter != null) {
      return converter;
    }

    throw new IllegalArgumentException("Unsupported type " + resultType + " of type class " + resultType.getClass());
  }
1132232
@Override
    public ZipImporter importFrom(final ZipFile file) throws ArchiveImportException {
        return importFrom(file, Filters.includeAll());
    }
677114
protected PrimitiveTypeConfiguration primitiveType( Class type ) {
        if ( !type.isPrimitive() ) {
            throw new IllegalArgumentException( "Type " + type + " is not a primitive. Call type(Class) instead" );
        }
        return new PrimitiveTypeConfiguration( type );
    }
1097767
public static Package newInstance(Package aPackage) {
    Package packageCopy = new Package(aPackage.getEntityType());
    packageCopy.setId(aPackage.getId());
    packageCopy.setLabel(aPackage.getLabel());
    packageCopy.setDescription(aPackage.getDescription());
    Package parent = aPackage.getParent();
    packageCopy.setParent(parent != null ? Package.newInstance(parent) : null);
    Iterable<Tag> tags = aPackage.getTags();
    packageCopy.setTags(stream(tags).map(Tag::newInstance).collect(toList()));
    return packageCopy;
  }
330799
public static void convertBaseClasses (ImportSet imports)
    {
        // replace primitive types with OOO types (required for unboxing)
        imports.replace("byte", "com.threerings.util.Byte");
        imports.replace("boolean", "com.threerings.util.langBoolean");
        imports.replace("[B", "flash.utils.ByteArray");
        imports.replace("float", "com.threerings.util.Float");
        imports.replace("long", "com.threerings.util.Long");

        if (imports.removeAll("[*") > 0) {
            imports.add("com.threerings.io.TypedArray");
        }

        // convert java primitive boxes to their ooo counterparts
        imports.replace(Integer.class, "com.threerings.util.Integer");

        // convert some java.util types to their ooo counterparts
        imports.replace(Map.class, "com.threerings.util.Map");

        // get rid of java.lang stuff and any remaining primitives
        imports.removeGlobals();

        // get rid of remaining arrays
        imports.removeArrays();
    }
630036
@Nonnull
  public static DAType from(@Nonnull Class<?> clazz, @Nonnull List<DAType> typeArgs) {
    return instance(clazz.getSimpleName(), clazz.getCanonicalName(), typeArgs);
  }
200981
@PublicAPI(usage = ACCESS)
    public JavaClasses importClasses(Collection<Class<?>> classes) {
        Set<Location> locations = new HashSet<>();
        for (Class<?> clazz : classes) {
            locations.addAll(Locations.ofClass(clazz));
        }
        return importLocations(locations);
    }
123146
public static <T> List<T> removeTypes(final List<T> list, final List<Class<? extends T>> filter) {
        final Iterator it = list.iterator();
        while (it.hasNext()) {
            final Class type = it.next().getClass();
            if (filter.contains(type)) {
                it.remove();
            }
        }
        return list;
    }
1060340
Map<String, ClassName> suggestedImports() {
    Map<String, ClassName> result = new LinkedHashMap<>(importableTypes);
    result.keySet().removeAll(referencedNames);
    return result;
  }
994236
@Nonnull
	public Imports sortByName() {
		final List<Import> imports = Lists.newArrayList(this.imports);
		Collections.sort(imports, ORDER.nullsLast());
		return new Imports(imports);
	}
362765
private CourierImportDeclarations addNthImport(CourierImportDeclaration importDecl) {
    CourierTopLevel root = getRoot();
    CourierImportDeclarations importDecls = root.getImportDeclarations();
    if (importDecl.getFullname() == null) {
      return importDecls;
    }

    boolean added = false;
    for (CourierImportDeclaration existing : importDecls.getImportDeclarationList()) {
      if (existing.getFullname() != null && importDecl.getFullname().toString().compareTo(existing.getFullname().toString()) < 0) {
        importDecls.addBefore(importDecl, existing);
        added = true;
        break;
      }
    }
    if (!added) {
      importDecls.add(importDecl);
    }
    return importDecls;
  }
34909
public java.util.List<String> getImportTablesCompleted() {
        if (importTablesCompleted == null) {
            importTablesCompleted = new com.amazonaws.internal.SdkInternalList<String>();
        }
        return importTablesCompleted;
    }
1031020
public static <T> T newInstance(Class<T> type) {
        try {
            return type.newInstance();
        } catch (InstantiationException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        }
    }
1135857
def _get_imports_m(self, data_types, default_imports):
        """"""
        if not isinstance(data_types, list):
            data_types = [data_types]

        import_classes = default_imports

        for data_type in data_types:
            import_classes.append(fmt_class_prefix(data_type))

            if data_type.parent_type:
                import_classes.append(fmt_class_prefix(data_type.parent_type))

            if is_struct_type(
                    data_type) and data_type.has_enumerated_subtypes():
                for _, subtype in data_type.get_all_subtypes_with_tags():
                    import_classes.append(fmt_class_prefix(subtype))

            for field in data_type.all_fields:
                data_type, _ = unwrap_nullable(field.data_type)

                # unpack list or map
                while is_list_type(data_type) or is_map_type(data_type):
                    data_type = (data_type.value_data_type if
                        is_map_type(data_type) else data_type.data_type)

                if is_user_defined_type(data_type):
                    import_classes.append(fmt_class_prefix(data_type))

        if import_classes:
            import_classes = list(set(import_classes))
            import_classes.sort()

        return import_classes
192777
private static List<ImportStatement> canonicalizeImports(
      Multimap<String, ImportStatement> importsByNamespace) {
    List<ImportStatement> canonicalImports = new ArrayList<>();

    for (String namespace : importsByNamespace.keySet()) {
      Collection<ImportStatement> allImports = importsByNamespace.get(namespace);

      // Find the strongest primitive across all existing imports. Every emitted import for this
      // namespace will use this primitive. This makes the logic simpler and cannot change runtime
      // behavior, but may produce spurious changes when multiple aliasing imports of differing
      // strength exist (which are already in violation of the style guide).
      ImportPrimitive strongestPrimitive =
          allImports.stream()
              .map(ImportStatement::primitive)
              .reduce(ImportPrimitive.WEAKEST, ImportPrimitive::stronger);

      // Emit each aliasing import separately, as deduplicating them would require code references
      // to be rewritten.
      boolean hasAliasing = false;
      for (ImportStatement stmt : Iterables.filter(allImports, ImportStatement::isAliasing)) {
        canonicalImports.add(stmt.upgrade(strongestPrimitive));
        hasAliasing = true;
      }

      // Emit a single destructuring import with a non-empty pattern, merged from the existing
      // destructuring imports.
      boolean hasDestructuring = false;
      ImmutableList<Node> destructuringNodes =
          allImports.stream()
              .filter(ImportStatement::isDestructuring)
              .flatMap(i -> i.nodes().stream())
              .collect(toImmutableList());
      ImmutableList<DestructuringBinding> destructures =
          allImports.stream()
              .filter(ImportStatement::isDestructuring)
              .flatMap(i -> i.destructures().stream())
              .distinct()
              .sorted()
              .collect(toImmutableList());
      if (!destructures.isEmpty()) {
        canonicalImports.add(
            ImportStatement.of(
                destructuringNodes,
                strongestPrimitive,
                namespace,
                /* alias= */ null,
                destructures));
        hasDestructuring = true;
      }

      // Emit a standalone import unless an aliasing or destructuring one already exists.
      if (!hasAliasing && !hasDestructuring) {
        ImmutableList<Node> standaloneNodes =
            allImports.stream()
                .filter(ImportStatement::isStandalone)
                .flatMap(i -> i.nodes().stream())
                .collect(toImmutableList());
        canonicalImports.add(
            ImportStatement.of(
                standaloneNodes,
                strongestPrimitive,
                namespace,
                /* alias= */ null,
                /* destructures= */ null));
      }
    }

    // Sorting by natural order yields the correct result due to the implementation of
    // ImportStatement#compareTo.
    Collections.sort(canonicalImports);

    return canonicalImports;
  }