/*
(non-Javadoc)

@see org.jboss.declarchive.api.container.ClassContainer#addPackages(boolean, java.lang.Package[])
512896
@Override
    public T addPackages(boolean recursive, Package... packages) throws IllegalArgumentException {
        Validate.notNull(packages, "Packages must be specified");

        return addPackages(recursive, Filters.includeAll(), packages);
    }
707460
private Set<PackageResourceReferenceWrapper> addFoundPackageResourceReferences(
		Set<PackageResourceReferenceWrapper> packageResourceReferences, final Class<?> iface)
	{
		final Set<PackageResourceReferenceWrapper> prr = PackageResourceReferences.getInstance()
			.getPackageResourceReferenceMap().get(iface);
		if ((packageResourceReferences != null) && !packageResourceReferences.isEmpty())
		{
			if ((prr != null) && !prr.isEmpty())
			{
				packageResourceReferences.addAll(prr);
			}
			else
			{

			}
		}
		else
		{
			if ((prr != null) && !prr.isEmpty())
			{
				packageResourceReferences = prr;
			}
		}
		return packageResourceReferences;
	}
772608
public static List<Package> getAllPackages(String packageName) throws CachingException {
        List<Package> allPackages = new ArrayList<>();
        for (Package packageVO : getPackageList()) {
            if (packageVO.getName().equals(packageName)) {
                allPackages.add(packageVO);
            }
        }
        return allPackages;
    }
165042
public void addExportedPackages(Set<String> packages) {
		String s = (String) getMainAttributes().get(EXPORT_PACKAGE);
		Wrapper<Boolean> modified = Wrapper.wrap(this.modified);
		String result = mergeIntoCommaSeparatedList(s, packages, modified, lineDelimiter);
		this.modified = modified.get();
		getMainAttributes().put(EXPORT_PACKAGE, result);
	}
1303348
function addAll(packages, packageIndex) {
		
	// iterate over packages and prepare urls before I call the registry
	for (var p in packages) {
		if(p.indexOf('@') === 0) {
			p = p.substring(p.indexOf('/') + 1, p.length)
		}
		var package = p + '@' + packages[p]

		if (packageIndex.indexOf(package) === -1) {
			packageIndex.push(package)
		}
	}	
}
1143266
private void resetPackageList() {
		final Set<PackageDoc> set = new TreeSet<>();
        for (final PackageDoc pack : this.root.specifiedPackages()) {
            set.add(pack);
        }
        for (final ClassDoc clazz : this.root.specifiedClasses()) {
            set.add(clazz.containingPackage());
        }
        this.packages = Utils.toArray(this.packages, set);
	}
1026326
protected void addPackageList(Content contentTree) {
        Content caption = getTableCaption(configuration.getContent(
                "doclet.ClassUse_Packages.that.use.0",
                getPackageLink(packageElement, utils.getPackageName(packageElement))));
        Content table = (configuration.isOutputHtml5())
                ? HtmlTree.TABLE(HtmlStyle.useSummary, caption)
                : HtmlTree.TABLE(HtmlStyle.useSummary, useTableSummary, caption);
        table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
        Content tbody = new HtmlTree(HtmlTag.TBODY);
        boolean altColor = true;
        for (String pkgname: usingPackageToUsedClasses.keySet()) {
            PackageElement pkg = utils.elementUtils.getPackageElement(pkgname);
            HtmlTree tr = new HtmlTree(HtmlTag.TR);
            tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
            altColor = !altColor;
            addPackageUse(pkg, tr);
            tbody.addContent(tr);
        }
        table.addContent(tbody);
        Content li = HtmlTree.LI(HtmlStyle.blockList, table);
        contentTree.addContent(li);
    }
906484
@PublicAPI(usage = ACCESS)
    public JavaClasses importPackagesOf(Collection<Class<?>> classes) {
        Set<String> pkgs = new HashSet<>();
        for (Class<?> clazz : classes) {
            pkgs.add(clazz.getPackage().getName());
        }
        return importPackages(pkgs);
    }
937866
private Set<PackageResourceReferenceWrapper> addPackageResourceReferenceFromInterfaces(
		Set<PackageResourceReferenceWrapper> packageResourceReferences, final Class<?> searchClass)
	{
		final Class<?>[] interfaces = searchClass.getInterfaces();
		for (final Class<?> iface : interfaces)
		{
			packageResourceReferences = addFoundPackageResourceReferences(packageResourceReferences,
				iface);
		}
		return packageResourceReferences;
	}
1047194
@Override
    public T addPackage(Package pack) throws IllegalArgumentException {
        Validate.notNull(pack, "Pack must be specified");

        return addPackage(pack.getName());
    }
288515
@Override
    public Object addingBundle(Bundle bundle, BundleEvent event) {
        // Packages become available on resolution, so take that as the state we care about

        //ignore gateway bundles
        if (!isGateway(bundle)) {
            /*
             * Make sure privatePackages isn't null.
             * If new bundles arrive while we're still populating our package list, we'll go through all bundles twice,
             * but at least we'll be correct.
             */
            BundlePackages bp = populatePackageLists();
            harvestPackageList(bp, bundle);
        }
        return null;
    }
855974
void addPackageInfo(final PackageInfo packageInfo) {
        if (packageInfoSet == null) {
            packageInfoSet = new HashSet<>();
        }
        packageInfoSet.add(packageInfo);
    }
716985
public Blade scanPackages(@NonNull String... packages) {
        this.packages.addAll(Arrays.asList(packages));
        return this;
    }
952928
public void addImportedPackages(String[] imports) {
        if (imports == null) { return; }

        for (String imported : imports) {
            this.mImports.add(imported);
        }
    }
254722
@Override
    public T addAsManifestResources(Package resourcePackage, String... resourceNames) throws IllegalArgumentException {
        Validate.notNull(resourcePackage, "ResourcePackage must be specified");
        Validate.notNullAndNoNullValues(resourceNames,
            "ResourceNames must be specified and can not container null values");
        for (String resourceName : resourceNames) {
            addAsManifestResource(resourcePackage, resourceName);
        }
        return covarientReturn();
    }
271650
public void initializePackageContents() {
		if (isInitialized) return;
		isInitialized = true;

		// Initialize package
		setName(eNAME);
		setNsPrefix(eNS_PREFIX);
		setNsURI(eNS_URI);

		// Create type parameters

		// Set bounds for type parameters

		// Add supertypes to classes
		unknsfEClass.getESuperTypes().add(this.getSF());
		sfGrouperEClass.getESuperTypes().add(this.getSF());

		// Initialize classes and features; add operations and parameters
		initEClass(afpEClass, org.afplib.base.AFP.class, "AFP", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
		initEReference(getAFP_StructuredFields(), this.getSF(), null, "structuredFields", null, 0, -1, org.afplib.base.AFP.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);

		initEClass(sfEClass, org.afplib.base.SF.class, "SF", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
		initEAttribute(getSF_Number(), ecorePackage.getELong(), "number", null, 0, 1, org.afplib.base.SF.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEAttribute(getSF_Offset(), ecorePackage.getELong(), "offset", null, 0, 1, org.afplib.base.SF.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEAttribute(getSF_Id(), ecorePackage.getEInt(), "id", null, 0, 1, org.afplib.base.SF.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEAttribute(getSF_Length(), ecorePackage.getEInt(), "length", null, 0, 1, org.afplib.base.SF.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEReference(getSF_Children(), this.getSF(), null, "children", null, 0, -1, org.afplib.base.SF.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEAttribute(getSF_RawData(), ecorePackage.getEByteArray(), "rawData", null, 0, 1, org.afplib.base.SF.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEAttribute(getSF_Charset(), this.getCharset(), "charset", null, 0, 1, org.afplib.base.SF.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);

		addEOperation(sfEClass, ecorePackage.getEBoolean(), "isBegin", 0, 1, IS_UNIQUE, IS_ORDERED);

		addEOperation(sfEClass, ecorePackage.getEBoolean(), "isEnd", 0, 1, IS_UNIQUE, IS_ORDERED);

		EOperation op = addEOperation(sfEClass, ecorePackage.getEBoolean(), "isDefault", 0, 1, IS_UNIQUE, IS_ORDERED);
		addEParameter(op, ecorePackage.getEString(), "value", 0, 1, IS_UNIQUE, IS_ORDERED);

		initEClass(unknsfEClass, org.afplib.base.UNKNSF.class, "UNKNSF", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);

		initEClass(sfGrouperEClass, SFGrouper.class, "SFGrouper", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);

		initEClass(tripletEClass, Triplet.class, "Triplet", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
		initEAttribute(getTriplet_Label(), ecorePackage.getEString(), "label", null, 0, 1, Triplet.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEAttribute(getTriplet_Charset(), this.getCharset(), "charset", null, 0, 1, Triplet.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEAttribute(getTriplet_FileOffset(), ecorePackage.getELong(), "fileOffset", null, 0, 1, Triplet.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEAttribute(getTriplet_TripletLength(), ecorePackage.getEInt(), "tripletLength", null, 0, 1, Triplet.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEAttribute(getTriplet_TripletId(), ecorePackage.getEInt(), "tripletId", null, 0, 1, Triplet.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEAttribute(getTriplet_TripletNumber(), ecorePackage.getEInt(), "tripletNumber", null, 0, 1, Triplet.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);

		// Initialize data types
		initEDataType(modcaStringEDataType, String.class, "ModcaString", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
		initEDataType(modcaString4EDataType, String.class, "ModcaString4", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
		initEDataType(modcaString8EDataType, String.class, "ModcaString8", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
		initEDataType(modcaString32EDataType, String.class, "ModcaString32", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
		initEDataType(charsetEDataType, Charset.class, "Charset", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);

		// Create resource
		createResource(eNS_URI);

		// Create annotations
		// http:///org/eclipse/emf/ecore/util/ExtendedMetaData
		createExtendedMetaDataAnnotations();
	}
779665
def add_package(self, package):
        
        self._data.setdefault('packages', {})
        
        self._data['packages'][package.name] = package.source

        for package in package.deploy_packages:
            self.add_package(package)

        self._save()