ValueSpecification (as specialized)

A package is used to group elements, and provides a namespace for the grouped elements.

Description
A package is a namespace for its members, and may contain other packages. Only packageable elements can be owned
members of a package. By virtue of being a namespace, a package can import either individual members of other
packages, or all the members of other packages.

In addition a package can be merged with other packages.

Attributes
No additional attributes.

Associations

nestedPackage: Package [*] References the owned members that are Packages. Subsets Package::ownedMember and
redefines Basic::Package::nestedPackage.
ownedMember: PackageableElement [*]Specifies the members that are owned by this Package. Redefines
Namespace::ownedMember.
ownedType: Type [*] References the owned members that are Types. Subsets Package::ownedMember and
redefines Basic::Package::ownedType.
package: Package [0..1] References the owning package of a package. Subsets NamedElement::namespace and
redefines Basic::Package::nestingPackage.
packageMerge: Package [*] References the PackageMerges that are owned by this Package. Subsets Ele-
ment::ownedElement
.

Constraints

  1. If an element that is owned by a package has visibility, it is public or private.

    self.ownedElements->forAll(e | e.visibility->notEmpty() implies e.visbility = #public or e.visibility = #private)

Additional Operations

  1. The query mustBeOwned() indicates whether elements of this type must have an owner.

    Package::mustBeOwned() : Boolean
    mustBeOwned = false

  2. The query visibleMembers() defines which members of a Package can be accessed outside it.

    Package::visibleMembers() : Set(PackageableElement);
    visibleMembers = member->select( m | self.makesVisible(m))

  3. The query makesVisible() defines whether a Package makes an element visible outside itself. Elements with no visibility
    and elements with public visibility are made visible.

    Package::makesVisible(el: Namespaces::NamedElement) : Boolean;
    pre: self.member->includes(el)
    makesVisible = el.visibility->isEmpty() or el.visibility = #public

Semantics
A package is a namespace and is also a packageable element that can be contained in other packages.

The elements that can be referred to using non-qualified names within a package are owned elements, imported elements,
and elements in enclosing (outer) namespaces. Owned and imported elements may each have a visibility that determines
whether they are available outside the package.

A package owns its owned members, with the implication that if a package is removed from a model, so are the elements
owned by the package.

The public contents of a package is always accessible outside the package through the use of qualified names.

Notation
A package is shown as a large rectangle with a small rectangle (a "tab") attached to the left side of the top of the large
rectangle. The members of the package may be shown within the large rectangle. Members may also be shown by
branching lines to member elements, drawn outside the package. A plus sign (+) within a circle is drawn at the end
attached to the namespace (package).

The visibility of a package element may be indicated by preceding the name of the element by a visibility symbol (`+' for
public and `-' for private).

Presentation Options
A tool may show visibility by a graphic marker, such as color or font. A tool may also show visibility by selectively
displaying those elements that meet a given visibility level, e.g., only public elements. A diagram showing a package with
contents must not necessarily show all its contents; it may show a subset of the contained elements according to some
criterion.

Elements that become available for use in a importing package through a package import or an element import may have
a distinct color or be dimmed to indicate that they cannot be modified.

Examples
There are three representations of the same package Types in Figure 95. The one on the left just shows the package
without revealing any of its members. The middle one shows some of the members within the borders of the package, and
the one to the right shows some of the members using the alternative membership notation.