# -*- 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::LinkEnd;

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::LinkEnd->__validate_type($value);

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

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

  no warnings;

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


=head2 __typecheck

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

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

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

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


=head2 isaLinkEnd

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

=cut
sub isaLinkEnd { 1 }


=head2 isaBehavioral_Elements__Common_Behavior__LinkEnd

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

=cut
sub isaBehavioral_Elements__Common_Behavior__LinkEnd { 1 }


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

=head2 __model_name 

  my $name = $obj_or_package->__model_name;

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

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





# ASSOC: connection
# ASSOC: 

  

# ASSOC: linkEnd

  


#################################################################
# 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 
  #   0..1
  #  <--> 
  #  qualifierValue 0..* UML::MetaModel::Behavioral_Elements::Common_Behavior::AttributeLink.
    if ( defined $self->{'qualifierValue'} && @{$self->{'qualifierValue'}} ) {
    my $x = $self->{'qualifierValue'};
    $self->{'qualifierValue'} = [ ];
    $self->set_qualifierValue(@$x);
  }
  
  # AssociationEnd 
  #  linkEnd 0..*
  #  <--> 
  #  instance 1 UML::MetaModel::Behavioral_Elements::Common_Behavior::Instance.
    if ( defined $self->{'instance'} ) {
    my $x = $self->{'instance'};
    $self->{'instance'} = undef;
    $self->set_instance($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::LinkEnd::__initialize;
  $self->UML::MetaModel::Foundation::Core::Element::__initialize;
  $self->UML::MetaModel::Foundation::Core::ModelElement::__initialize;

  $self;
}
      

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




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


#################################################################
# AssociationEnd  => qualifierValue
# type = UML::MetaModel::Behavioral_Elements::Common_Behavior::AttributeLink
# multiplicity = 0..*

=head2 qualifierValue

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

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 qualifierValue ($)
{
  my ($self) = @_;
		  
  my $x = $self->{'qualifierValue'} ||= [ ];
  wantarray ? @{$x} : $x;
}


=head2 set_qualifierValue

  $obj->set_qualifierValue(@val);

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

=cut
sub set_qualifierValue ($@)
{
  my ($self, @val) = @_;
  
  $self->clear_qualifierValue;
  $self->add_qualifierValue(@val);
}


=head2 add_qualifierValue

  $obj->add_qualifierValue(@val);

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

=cut
sub add_qualifierValue ($@)
{
  my ($self, @val) = @_;
  
  my $x = $self->{'qualifierValue'} ||= [ ];
  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::AttributeLink')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::Common_Behavior::LinkEnd.qualifierValue");

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

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


=head2 remove_qualifierValue

  $obj->remove_qualifierValue($val);

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

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

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

    # Remove associations with other ends.

        ;

  }
  
  $self;
}


=head2 clear_qualifierValue

  $obj->clear_qualifierValue;

Clears the Association.
Returns C<$obj>.

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

    # Remove associations with other ends.

        ;

  }
  
  $self;
}


#################################################################
# AssociationEnd linkEnd => instance
# type = UML::MetaModel::Behavioral_Elements::Common_Behavior::Instance
# multiplicity = 1

=head2 instance

  my $val = $obj->instance;

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

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


=head2 set_instance

  $obj->set_instance($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_instance ($$)
{
  my ($self, $val) = @_;
		  
  no warnings; # Use of uninitialized value in string ne at ...
		  
  my $old;
  if ( ($old = $self->{'instance'}) ne $val ) { # Recursion lock

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

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

    }
		  
  $self;
}


=head2 add_instance

  $obj->add_instance($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_instance ($$)
{
  my ($self, $val) = @_;

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

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

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

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

  
  }

  $self;
}


=head2 remove_instance

  $obj->remove_instance($val);

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

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

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

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

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

  
  }
}


=head2 clear_instance

  $obj->clear_instance;

Clears the Association.
Returns C<$obj>.

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

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

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

  
  }

  $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: ###

