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

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::Classifier


);

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

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





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


=head2 __validate_type

  UML::MetaModel::Behavioral_Elements::Collaborations::ClassifierRole->__validate_type($value);

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

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

  no warnings;

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


=head2 __typecheck

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

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

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

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


=head2 isaClassifierRole

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

=cut
sub isaClassifierRole { 1 }


=head2 isaBehavioral_Elements__Collaborations__ClassifierRole

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

=cut
sub isaBehavioral_Elements__Collaborations__ClassifierRole { 1 }


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

=head2 __model_name 

  my $name = $obj_or_package->__model_name;

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

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




  



# ASSOC: 

  

# ASSOC: 

  

# ASSOC: playedRole

  

# ASSOC: sender
# ASSOC: receiver

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

    # Attribute multiplicity
  if ( exists $self->{'multiplicity'} ) {
    my $x = $self->{'multiplicity'};
    $self->{'multiplicity'} = undef;
    $self->set_multiplicity($x);
  } else {
      }
  


  # Associations

  # AssociationEnd 
  #   0..*
  #  <--> 
  #  availableFeature 0..* UML::MetaModel::Foundation::Core::Feature.
    if ( defined $self->{'availableFeature'} && @{$self->{'availableFeature'}} ) {
    my $x = $self->{'availableFeature'};
    $self->{'availableFeature'} = [ ];
    $self->set_availableFeature(@$x);
  }
  
  # AssociationEnd 
  #   0..*
  #  <--> 
  #  base 1..* UML::MetaModel::Foundation::Core::Classifier.
    if ( defined $self->{'base'} && @{$self->{'base'}} ) {
    my $x = $self->{'base'};
    $self->{'base'} = [ ];
    $self->set_base(@$x);
  }
  
  # AssociationEnd 
  #  playedRole 0..*
  #  <--> 
  #  conformingInstance 0..* UML::MetaModel::Behavioral_Elements::Common_Behavior::Instance.
    if ( defined $self->{'conformingInstance'} && @{$self->{'conformingInstance'}} ) {
    my $x = $self->{'conformingInstance'};
    $self->{'conformingInstance'} = [ ];
    $self->set_conformingInstance(@$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::Namespace');
    $self->__use('UML::MetaModel::Foundation::Core::Element');
    $self->__use('UML::MetaModel::Foundation::Core::ModelElement');
    $self->__use('UML::MetaModel::Foundation::Core::GeneralizableElement');
    $self->__use('UML::MetaModel::Foundation::Core::Classifier');
  }

  $self->UML::MetaModel::Behavioral_Elements::Collaborations::ClassifierRole::__initialize;
  $self->UML::MetaModel::Foundation::Core::Namespace::__initialize;
  $self->UML::MetaModel::Foundation::Core::Element::__initialize;
  $self->UML::MetaModel::Foundation::Core::ModelElement::__initialize;
  $self->UML::MetaModel::Foundation::Core::GeneralizableElement::__initialize;
  $self->UML::MetaModel::Foundation::Core::Classifier::__initialize;

  $self;
}
      

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



#################################################################
# Attribute multiplicity
# type = UML::MetaModel::Foundation::Data_Types::Multiplicity
# multiplicity = 1

=head2 multiplicity

  my $val = $obj->multiplicity;

Returns the value of Attribute multiplicity.

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

  $self->{'multiplicity'};
}


=head2 set_multiplicity

  $obj->set_multiplicity($val);

Sets the value of Attribute multiplicity.
C<$val> must be of type C<UML::MetaModel::Foundation::Data_Types::Multiplicity>.
Returns C<$obj>.

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

  $self->__use('UML::MetaModel::Foundation::Data_Types::Multiplicity')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::Collaborations::ClassifierRole.multiplicity");

  $self->{'multiplicity'} = $val;

  $self
}


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


#################################################################
# AssociationEnd  => availableFeature
# type = UML::MetaModel::Foundation::Core::Feature
# multiplicity = 0..*

=head2 availableFeature

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

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


=head2 set_availableFeature

  $obj->set_availableFeature(@val);

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

=cut
sub set_availableFeature ($@)
{
  my ($self, @val) = @_;
  
  $self->clear_availableFeature;
  $self->add_availableFeature(@val);
}


=head2 add_availableFeature

  $obj->add_availableFeature(@val);

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

=cut
sub add_availableFeature ($@)
{
  my ($self, @val) = @_;
  
  my $x = $self->{'availableFeature'} ||= [ ];
  my $old; # Place holder for other MACRO.
  
  for my $val ( @val ) {
    next if grep($_ eq $val, @$x);   # Recursion lock
    $self->__use('UML::MetaModel::Foundation::Core::Feature')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::Collaborations::ClassifierRole.availableFeature");

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

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


=head2 remove_availableFeature

  $obj->remove_availableFeature($val);

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

=cut
sub remove_availableFeature ($@)
{
  my ($self, @val) = @_;
  
  my $x = $self->{'availableFeature'} ||= [ ];
  
  for my $old ( @val ) {
    next unless grep($_ eq $old, @$x); # Recursion lock
    my $val = $old;
      
    $self->__use('UML::MetaModel::Foundation::Core::Feature')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::Collaborations::ClassifierRole.availableFeature");

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

    # Remove associations with other ends.

        ;

  }
  
  $self;
}


=head2 clear_availableFeature

  $obj->clear_availableFeature;

Clears the Association.
Returns C<$obj>.

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

    # Remove associations with other ends.

        ;

  }
  
  $self;
}


#################################################################
# AssociationEnd  => base
# type = UML::MetaModel::Foundation::Core::Classifier
# multiplicity = 1..*

=head2 base

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

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


=head2 set_base

  $obj->set_base(@val);

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

=cut
sub set_base ($@)
{
  my ($self, @val) = @_;
  
  $self->clear_base;
  $self->add_base(@val);
}


=head2 add_base

  $obj->add_base(@val);

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

=cut
sub add_base ($@)
{
  my ($self, @val) = @_;
  
  my $x = $self->{'base'} ||= [ ];
  my $old; # Place holder for other MACRO.
  
  for my $val ( @val ) {
    next if grep($_ eq $val, @$x);   # Recursion lock
    $self->__use('UML::MetaModel::Foundation::Core::Classifier')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::Collaborations::ClassifierRole.base");

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

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


=head2 remove_base

  $obj->remove_base($val);

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

=cut
sub remove_base ($@)
{
  my ($self, @val) = @_;
  
  my $x = $self->{'base'} ||= [ ];
  
  for my $old ( @val ) {
    next unless grep($_ eq $old, @$x); # Recursion lock
    my $val = $old;
      
    $self->__use('UML::MetaModel::Foundation::Core::Classifier')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::Collaborations::ClassifierRole.base");

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

    # Remove associations with other ends.

        ;

  }
  
  $self;
}


=head2 clear_base

  $obj->clear_base;

Clears the Association.
Returns C<$obj>.

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

    # Remove associations with other ends.

        ;

  }
  
  $self;
}


#################################################################
# AssociationEnd playedRole => conformingInstance
# type = UML::MetaModel::Behavioral_Elements::Common_Behavior::Instance
# multiplicity = 0..*

=head2 conformingInstance

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

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


=head2 set_conformingInstance

  $obj->set_conformingInstance(@val);

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

=cut
sub set_conformingInstance ($@)
{
  my ($self, @val) = @_;
  
  $self->clear_conformingInstance;
  $self->add_conformingInstance(@val);
}


=head2 add_conformingInstance

  $obj->add_conformingInstance(@val);

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

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

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

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

  
  }
  
  $self;
}


=head2 remove_conformingInstance

  $obj->remove_conformingInstance($val);

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

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

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

    # Remove associations with other ends.

        
    $old->remove_playedRole($self) if $old;
    $val->add_playedRole($self)    if $val;

  ;

  }
  
  $self;
}


=head2 clear_conformingInstance

  $obj->clear_conformingInstance;

Clears the Association.
Returns C<$obj>.

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

    # Remove associations with other ends.

        
    $old->remove_playedRole($self) if $old;
    $val->add_playedRole($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: ###

