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

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

Returns true if $value is a valid value of UML::MetaModel::Behavioral_Elements::Collaborations::InteractionInstanceSet.

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

  no warnings;

  UNIVERSAL::isa($x, 'UML::MetaModel::Behavioral_Elements::Collaborations::InteractionInstanceSet')  ;
}


=head2 __typecheck

  UML::MetaModel::Behavioral_Elements::Collaborations::InteractionInstanceSet->__typecheck($value, $msg);

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

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

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


=head2 isaInteractionInstanceSet

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

=cut
sub isaInteractionInstanceSet { 1 }


=head2 isaBehavioral_Elements__Collaborations__InteractionInstanceSet

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

=cut
sub isaBehavioral_Elements__Collaborations__InteractionInstanceSet { 1 }


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

=head2 __model_name 

  my $name = $obj_or_package->__model_name;

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

=cut
sub __model_name { 'Behavioral_Elements::Collaborations::InteractionInstanceSet' }





# ASSOC: 

  

# ASSOC: interactionInstance

  

# ASSOC: 

  


#################################################################
# 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..*
  #  <--> 
  #  interaction 0..1 UML::MetaModel::Behavioral_Elements::Collaborations::Interaction.
    if ( defined $self->{'interaction'} ) {
    my $x = $self->{'interaction'};
    $self->{'interaction'} = undef;
    $self->set_interaction($x);
  }
  
  # AssociationEnd 
  #  interactionInstance 0..*
  #  <--> 
  #  context 1 UML::MetaModel::Behavioral_Elements::Collaborations::CollaborationInstanceSet.
    if ( defined $self->{'context'} ) {
    my $x = $self->{'context'};
    $self->{'context'} = undef;
    $self->set_context($x);
  }
  
  # AssociationEnd 
  #   0..*
  #  <--> 
  #  particpatingStimulus 1..* UML::MetaModel::Behavioral_Elements::Common_Behavior::Stimulus.
    if ( defined $self->{'particpatingStimulus'} && @{$self->{'particpatingStimulus'}} ) {
    my $x = $self->{'particpatingStimulus'};
    $self->{'particpatingStimulus'} = [ ];
    $self->set_particpatingStimulus(@$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::Collaborations::InteractionInstanceSet::__initialize;
  $self->UML::MetaModel::Foundation::Core::Element::__initialize;
  $self->UML::MetaModel::Foundation::Core::ModelElement::__initialize;

  $self;
}
      

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




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


#################################################################
# AssociationEnd  => interaction
# type = UML::MetaModel::Behavioral_Elements::Collaborations::Interaction
# multiplicity = 0..1

=head2 interaction

  my $val = $obj->interaction;

Returns the AssociationEnd value of type C<UML::MetaModel::Behavioral_Elements::Collaborations::Interaction>.

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


=head2 set_interaction

  $obj->set_interaction($val);

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

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

    $self->__use('UML::MetaModel::Behavioral_Elements::Collaborations::Interaction')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::Collaborations::InteractionInstanceSet.interaction");

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


=head2 add_interaction

  $obj->add_interaction($val);

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

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

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

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

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

    # Remove and add associations with other ends.
        
  }

  $self;
}


=head2 remove_interaction

  $obj->remove_interaction($val);

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

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

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

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

    # Remove and add associations with other ends.
        
  }
}


=head2 clear_interaction

  $obj->clear_interaction;

Clears the Association.
Returns C<$obj>.

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

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

    # Remove and add associations with other ends.
        
  }

  $self;
}




#################################################################
# AssociationEnd interactionInstance => context
# type = UML::MetaModel::Behavioral_Elements::Collaborations::CollaborationInstanceSet
# multiplicity = 1

=head2 context

  my $val = $obj->context;

Returns the AssociationEnd value of type C<UML::MetaModel::Behavioral_Elements::Collaborations::CollaborationInstanceSet>.

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


=head2 set_context

  $obj->set_context($val);

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

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

    $self->__use('UML::MetaModel::Behavioral_Elements::Collaborations::CollaborationInstanceSet')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::Collaborations::InteractionInstanceSet.context");

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

    }
		  
  $self;
}


=head2 add_context

  $obj->add_context($val);

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

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

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

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

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

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

  
  }

  $self;
}


=head2 remove_context

  $obj->remove_context($val);

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

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

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

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

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

  
  }
}


=head2 clear_context

  $obj->clear_context;

Clears the Association.
Returns C<$obj>.

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

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

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

  
  }

  $self;
}




#################################################################
# AssociationEnd  => particpatingStimulus
# type = UML::MetaModel::Behavioral_Elements::Common_Behavior::Stimulus
# multiplicity = 1..*

=head2 particpatingStimulus

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

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


=head2 set_particpatingStimulus

  $obj->set_particpatingStimulus(@val);

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

=cut
sub set_particpatingStimulus ($@)
{
  my ($self, @val) = @_;
  
  $self->clear_particpatingStimulus;
  $self->add_particpatingStimulus(@val);
}


=head2 add_particpatingStimulus

  $obj->add_particpatingStimulus(@val);

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

=cut
sub add_particpatingStimulus ($@)
{
  my ($self, @val) = @_;
  
  my $x = $self->{'particpatingStimulus'} ||= [ ];
  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::Stimulus')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::Collaborations::InteractionInstanceSet.particpatingStimulus");

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

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


=head2 remove_particpatingStimulus

  $obj->remove_particpatingStimulus($val);

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

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

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

    # Remove associations with other ends.

        ;

  }
  
  $self;
}


=head2 clear_particpatingStimulus

  $obj->clear_particpatingStimulus;

Clears the Association.
Returns C<$obj>.

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

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

