# -*- perl -*-
# DO NOT EDIT - This file is generated by UML2CODE.
# From template: $Id: PerlTemplate.txt,v 1.12 2003/05/11 06:16:02 stephens Exp $

package UML::MetaModel::Behavioral_Elements::Common_Behavior::Link;

use 5.6.1;
use strict;
use warnings;

#################################################################
# Version
#

our $VERSION = do { my @r = (q$Revision: 1.12 $ =~ /\d+/g); sprintf "%d." . "%03d" x $#r, @r };

#################################################################
# Dependencies
#



use Carp qw(croak confess);

#################################################################
# Generalizations
#

use base qw(
  UML::MetaModel::Foundation::Core::ModelElement


);

#################################################################
# Exports
#

our @EXPORT_OK = qw(
);
our %EXPORT_TAGS = ( ':all' => \@EXPORT_OK );





#################################################################
# Validation
#


=head2 __validate_type

  UML::MetaModel::Behavioral_Elements::Common_Behavior::Link->__validate_type($value);

Returns true if $value is a valid value of UML::MetaModel::Behavioral_Elements::Common_Behavior::Link.

=cut
sub __validate_type($$)
{
  my ($self, $x) = @_;

  no warnings;

  UNIVERSAL::isa($x, 'UML::MetaModel::Behavioral_Elements::Common_Behavior::Link')  ;
}


=head2 __typecheck

  UML::MetaModel::Behavioral_Elements::Common_Behavior::Link->__typecheck($value, $msg);

Calls C<confess()> with C<$msg> if C<UML::MetaModel::Behavioral_Elements::Common_Behavior::Link-E<GT>__validate_type($value)> is false.

=cut
sub __typecheck
{
  my ($self, $x, $msg) = @_;

  confess("typecheck: $msg: type 'UML::MetaModel::Behavioral_Elements::Common_Behavior::Link': value '$x'")
    unless __validate_type($self, $x);
}


=head2 isaLink

Returns true if receiver is a C<UML::MetaModel::Behavioral_Elements::Common_Behavior::Link>.
Other receivers will return false.

=cut
sub isaLink { 1 }


=head2 isaBehavioral_Elements__Common_Behavior__Link

Returns true if receiver is a C<UML::MetaModel::Behavioral_Elements::Common_Behavior::Link>.
Other receivers will return false.
This is the fully qualified version of the C<isaLink> method.

=cut
sub isaBehavioral_Elements__Common_Behavior__Link { 1 }


#################################################################
# Introspection
#

=head2 __model_name 

  my $name = $obj_or_package->__model_name;

Returns the UML Model name (C<'Behavioral_Elements::Common_Behavior::Link'>) for an object or package of
this Classifier.

=cut
sub __model_name { 'Behavioral_Elements::Common_Behavior::Link' }





# ASSOC: communicationsLink
# ASSOC: ownedLink

  

# ASSOC: 

  

# ASSOC: 

  

# ASSOC: particpatingLink

#################################################################
# Class Attributes
#


    

#################################################################
# Initialization
#

 
=head2 __intialize

Initialize all slots in this Classifier.
Does not initlaize slots in Generalizations.

See also: C<_initialize>.

=cut
sub __initialize
{
  my ($self) = @_;

  # Attributes



  # Associations

  # AssociationEnd 
  #  ownedLink 0..*
  #  <--> 
  #  owner_Link 0..1 UML::MetaModel::Behavioral_Elements::Common_Behavior::Instance.
    if ( defined $self->{'owner_Link'} ) {
    my $x = $self->{'owner_Link'};
    $self->{'owner_Link'} = undef;
    $self->set_owner_Link($x);
  }
  
  # AssociationEnd 
  #   1
  #  <--> 
  #  connection 2..* UML::MetaModel::Behavioral_Elements::Common_Behavior::LinkEnd.
    if ( defined $self->{'connection'} && @{$self->{'connection'}} ) {
    my $x = $self->{'connection'};
    $self->{'connection'} = [ ];
    $self->set_connection(@$x);
  }
  
  # AssociationEnd 
  #   0..*
  #  <--> 
  #  association 1 UML::MetaModel::Foundation::Core::Association.
    if ( defined $self->{'association'} ) {
    my $x = $self->{'association'};
    $self->{'association'} = undef;
    $self->set_association($x);
  }
  

  $self;
}


my $__initialize_use;

=head2 _intialize

Initialize all slots in this Classifier and all Generalizations.

See also: C<__initialize>.

=cut
sub _initialize
{
  my ($self) = @_;

  # $DB::single = 1;

  unless ( ! $__initialize_use ) {
    $__initialize_use = 1;
    $self->__use('UML::MetaModel::Foundation::Core::Element');
    $self->__use('UML::MetaModel::Foundation::Core::ModelElement');
  }

  $self->UML::MetaModel::Behavioral_Elements::Common_Behavior::Link::__initialize;
  $self->UML::MetaModel::Foundation::Core::Element::__initialize;
  $self->UML::MetaModel::Foundation::Core::ModelElement::__initialize;

  $self;
}
      

#################################################################
# Attributes
#




#################################################################
# Association
#


#################################################################
# AssociationEnd ownedLink => owner_Link
# type = UML::MetaModel::Behavioral_Elements::Common_Behavior::Instance
# multiplicity = 0..1

=head2 owner_Link

  my $val = $obj->owner_Link;

Returns the AssociationEnd value of type C<UML::MetaModel::Behavioral_Elements::Common_Behavior::Instance>.

=cut
sub owner_Link ($)
{
  my ($self) = @_;
		  
  $self->{'owner_Link'};
}


=head2 set_owner_Link

  $obj->set_owner_Link($val);

Sets the AssociationEnd value.
C<$val> must of of type C<UML::MetaModel::Behavioral_Elements::Common_Behavior::Instance>.
Returns C<$obj>.

=cut
sub set_owner_Link ($$)
{
  my ($self, $val) = @_;
		  
  no warnings; # Use of uninitialized value in string ne at ...
		  
  my $old;
  if ( ($old = $self->{'owner_Link'}) ne $val ) { # Recursion lock

    $self->__use('UML::MetaModel::Behavioral_Elements::Common_Behavior::Instance')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::Common_Behavior::Link.owner_Link");

    $self->{'owner_Link'} = $val;                 # Recursion lock
    # Remove and add associations with other ends.
        
    $old->remove_ownedLink($self) if $old;
    $val->add_ownedLink($self)    if $val;

    }
		  
  $self;
}


=head2 add_owner_Link

  $obj->add_owner_Link($val);

Adds the AssociationEnd value.
C<$val> must of of type C<UML::MetaModel::Behavioral_Elements::Common_Behavior::Instance>.
Throws exception if a value already exists.
Returns C<$obj>.

=cut
sub add_owner_Link ($$)
{
  my ($self, $val) = @_;

  no warnings; # Use of uninitialized value in string ne at ...

  my $old;
  if ( ($old = $self->{'owner_Link'}) ne $val ) { # Recursion lock
    $self->__use('UML::MetaModel::Behavioral_Elements::Common_Behavior::Instance')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::Common_Behavior::Link.owner_Link");
      
    # confess("UML::MetaModel::Behavioral_Elements::Common_Behavior::Link::owner_Link: too many")
    # if defined $self->{'owner_Link'};

    $self->{'owner_Link'} = $val;                 # Recursion lock

    # Remove and add associations with other ends.
        
    $old->remove_ownedLink($self) if $old;
    $val->add_ownedLink($self)    if $val;

  
  }

  $self;
}


=head2 remove_owner_Link

  $obj->remove_owner_Link($val);

Removes the Association to C<$val>.
Returns C<$obj>.

=cut
sub remove_owner_Link ($$)
{
  my ($self, $val) = @_;

  no warnings; # Use of uninitialized value in string ne at ...

  my $old;
  if ( ($old = $self->{'owner_Link'}) eq $val ) { # Recursion lock
    $val = $self->{'owner_Link'} = undef;         # Recursion lock

    # Remove and add associations with other ends.
        
    $old->remove_ownedLink($self) if $old;
    $val->add_ownedLink($self)    if $val;

  
  }
}


=head2 clear_owner_Link

  $obj->clear_owner_Link;

Clears the Association.
Returns C<$obj>.

=cut
sub clear_owner_Link ($@)
{
  my ($self) = @_;

  my $old;
  if ( defined ($old = $self->{'owner_Link'}) ) { # Recursion lock
    my $val = $self->{'owner_Link'} = undef;      # Recursion lock

    # Remove and add associations with other ends.
        
    $old->remove_ownedLink($self) if $old;
    $val->add_ownedLink($self)    if $val;

  
  }

  $self;
}




#################################################################
# AssociationEnd  => connection
# type = UML::MetaModel::Behavioral_Elements::Common_Behavior::LinkEnd
# multiplicity = 2..*

=head2 connection

  my @val = $obj->connection;
  my $ary_val = $obj->connection;

Returns the AssociationEnd value.
In array context, returns all the objects in the Association.
In scalar context, returns an array ref of all the objects in the Association.

=cut
sub connection ($)
{
  my ($self) = @_;
		  
  my $x = $self->{'connection'} ||= [ ];
  wantarray ? @{$x} : $x;
}


=head2 set_connection

  $obj->set_connection(@val);

Sets the AssociationEnd value.
Elements of C<@val> must of of type C<UML::MetaModel::Behavioral_Elements::Common_Behavior::LinkEnd>.
Returns C<$obj>.

=cut
sub set_connection ($@)
{
  my ($self, @val) = @_;
  
  $self->clear_connection;
  $self->add_connection(@val);
}


=head2 add_connection

  $obj->add_connection(@val);

Sets the AssociationEnd value.
Elements of C<@val> must of of type C<UML::MetaModel::Behavioral_Elements::Common_Behavior::LinkEnd>.
Returns C<$obj>.

=cut
sub add_connection ($@)
{
  my ($self, @val) = @_;
  
  my $x = $self->{'connection'} ||= [ ];
  my $old; # Place holder for other MACRO.
  
  for my $val ( @val ) {
    next if grep($_ eq $val, @$x);   # Recursion lock
    $self->__use('UML::MetaModel::Behavioral_Elements::Common_Behavior::LinkEnd')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::Common_Behavior::Link.connection");

    push(@{$x}, $val);               # Recursion lock

    # Remove and add associations with other ends.
        
  }
  
  $self;
}


=head2 remove_connection

  $obj->remove_connection($val);

Removes the Association to C<$val>.
Returns C<$obj>.

=cut
sub remove_connection ($@)
{
  my ($self, @val) = @_;
  
  my $x = $self->{'connection'} ||= [ ];
  
  for my $old ( @val ) {
    next unless grep($_ eq $old, @$x); # Recursion lock
    my $val = $old;
      
    $self->__use('UML::MetaModel::Behavioral_Elements::Common_Behavior::LinkEnd')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::Common_Behavior::Link.connection");

    @$x = grep($_ ne $old, @$x);       # Recursion lock
    $val = undef;

    # Remove associations with other ends.

        ;

  }
  
  $self;
}


=head2 clear_connection

  $obj->clear_connection;

Clears the Association.
Returns C<$obj>.

=cut
sub clear_connection ($) 
{
  my ($self) = @_;
  
  my $x = $self->{'connection'} ||= [ ];
  my $val; # Place holder for other MACRO.
  
  $self->{'connection'} = [ ];  # Recursion lock
  for my $old ( @$x ) { # Recursion lock

    # Remove associations with other ends.

        ;

  }
  
  $self;
}


#################################################################
# AssociationEnd  => association
# type = UML::MetaModel::Foundation::Core::Association
# multiplicity = 1

=head2 association

  my $val = $obj->association;

Returns the AssociationEnd value of type C<UML::MetaModel::Foundation::Core::Association>.

=cut
sub association ($)
{
  my ($self) = @_;
		  
  $self->{'association'};
}


=head2 set_association

  $obj->set_association($val);

Sets the AssociationEnd value.
C<$val> must of of type C<UML::MetaModel::Foundation::Core::Association>.
Returns C<$obj>.

=cut
sub set_association ($$)
{
  my ($self, $val) = @_;
		  
  no warnings; # Use of uninitialized value in string ne at ...
		  
  my $old;
  if ( ($old = $self->{'association'}) ne $val ) { # Recursion lock

    $self->__use('UML::MetaModel::Foundation::Core::Association')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::Common_Behavior::Link.association");

    $self->{'association'} = $val;                 # Recursion lock
    # Remove and add associations with other ends.
          }
		  
  $self;
}


=head2 add_association

  $obj->add_association($val);

Adds the AssociationEnd value.
C<$val> must of of type C<UML::MetaModel::Foundation::Core::Association>.
Throws exception if a value already exists.
Returns C<$obj>.

=cut
sub add_association ($$)
{
  my ($self, $val) = @_;

  no warnings; # Use of uninitialized value in string ne at ...

  my $old;
  if ( ($old = $self->{'association'}) ne $val ) { # Recursion lock
    $self->__use('UML::MetaModel::Foundation::Core::Association')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::Common_Behavior::Link.association");
      
    # confess("UML::MetaModel::Behavioral_Elements::Common_Behavior::Link::association: too many")
    # if defined $self->{'association'};

    $self->{'association'} = $val;                 # Recursion lock

    # Remove and add associations with other ends.
        
  }

  $self;
}


=head2 remove_association

  $obj->remove_association($val);

Removes the Association to C<$val>.
Returns C<$obj>.

=cut
sub remove_association ($$)
{
  my ($self, $val) = @_;

  no warnings; # Use of uninitialized value in string ne at ...

  my $old;
  if ( ($old = $self->{'association'}) eq $val ) { # Recursion lock
    $val = $self->{'association'} = undef;         # Recursion lock

    # Remove and add associations with other ends.
        
  }
}


=head2 clear_association

  $obj->clear_association;

Clears the Association.
Returns C<$obj>.

=cut
sub clear_association ($@)
{
  my ($self) = @_;

  my $old;
  if ( defined ($old = $self->{'association'}) ) { # Recursion lock
    my $val = $self->{'association'} = undef;      # Recursion lock

    # Remove and add associations with other ends.
        
  }

  $self;
}






############################################################################

1; # is true!

############################################################################

### Keep these comments at end of file: ks.perl@kurtstephens.com 2003/04/06 ###
### Local Variables: ###
### mode:perl ###
### perl-indent-level:2 ###
### perl-continued-statement-offset:0 ###
### perl-brace-offset:0 ###
### perl-label-offset:0 ###
### End: ###

