# -*- 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::Foundation::Core::Parameter;

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::Foundation::Core::Parameter->__validate_type($value);

Returns true if $value is a valid value of UML::MetaModel::Foundation::Core::Parameter.

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

  no warnings;

  UNIVERSAL::isa($x, 'UML::MetaModel::Foundation::Core::Parameter')  ;
}


=head2 __typecheck

  UML::MetaModel::Foundation::Core::Parameter->__typecheck($value, $msg);

Calls C<confess()> with C<$msg> if C<UML::MetaModel::Foundation::Core::Parameter-E<GT>__validate_type($value)> is false.

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

  confess("typecheck: $msg: type 'UML::MetaModel::Foundation::Core::Parameter': value '$x'")
    unless __validate_type($self, $x);
}


=head2 isaParameter

Returns true if receiver is a C<UML::MetaModel::Foundation::Core::Parameter>.
Other receivers will return false.

=cut
sub isaParameter { 1 }


=head2 isaFoundation__Core__Parameter

Returns true if receiver is a C<UML::MetaModel::Foundation::Core::Parameter>.
Other receivers will return false.
This is the fully qualified version of the C<isaParameter> method.

=cut
sub isaFoundation__Core__Parameter { 1 }


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

=head2 __model_name 

  my $name = $obj_or_package->__model_name;

Returns the UML Model name (C<'Foundation::Core::Parameter'>) for an object or package of
this Classifier.

=cut
sub __model_name { 'Foundation::Core::Parameter' }




  


  



# ASSOC: 

  

# ASSOC: parameter
# ASSOC: parameter
# ASSOC: parameter

  


#################################################################
# 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 defaultValue
  if ( exists $self->{'defaultValue'} ) {
    my $x = $self->{'defaultValue'};
    $self->{'defaultValue'} = undef;
    $self->set_defaultValue($x);
  } else {
      }
  
    # Attribute kind
  if ( exists $self->{'kind'} ) {
    my $x = $self->{'kind'};
    $self->{'kind'} = undef;
    $self->set_kind($x);
  } else {
      }
  


  # Associations

  # AssociationEnd 
  #   0..*
  #  <--> 
  #  type 1 UML::MetaModel::Foundation::Core::Classifier.
    if ( defined $self->{'type'} ) {
    my $x = $self->{'type'};
    $self->{'type'} = undef;
    $self->set_type($x);
  }
  
  # AssociationEnd 
  #  parameter 0..*
  #  <--> 
  #  state 0..* UML::MetaModel::Behavioral_Elements::Activity_Graphs::ObjectFlowState.
    if ( defined $self->{'state'} && @{$self->{'state'}} ) {
    my $x = $self->{'state'};
    $self->{'state'} = [ ];
    $self->set_state(@$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::Foundation::Core::Parameter::__initialize;
  $self->UML::MetaModel::Foundation::Core::Element::__initialize;
  $self->UML::MetaModel::Foundation::Core::ModelElement::__initialize;

  $self;
}
      

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



#################################################################
# Attribute defaultValue
# type = UML::MetaModel::Foundation::Data_Types::Expression
# multiplicity = 1

=head2 defaultValue

  my $val = $obj->defaultValue;

Returns the value of Attribute defaultValue.

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

  $self->{'defaultValue'};
}


=head2 set_defaultValue

  $obj->set_defaultValue($val);

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

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

  $self->__use('UML::MetaModel::Foundation::Data_Types::Expression')->__typecheck($val, "UML::MetaModel::Foundation::Core::Parameter.defaultValue");

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

  $self
}

#################################################################
# Attribute kind
# type = UML::MetaModel::Foundation::Data_Types::ParameterDirectionKind
# multiplicity = 1

=head2 kind

  my $val = $obj->kind;

Returns the value of Attribute kind.

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

  $self->{'kind'};
}


=head2 set_kind

  $obj->set_kind($val);

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

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

  $self->__use('UML::MetaModel::Foundation::Data_Types::ParameterDirectionKind')->__typecheck($val, "UML::MetaModel::Foundation::Core::Parameter.kind");

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

  $self
}


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


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

=head2 type

  my $val = $obj->type;

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

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


=head2 set_type

  $obj->set_type($val);

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

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

    $self->__use('UML::MetaModel::Foundation::Core::Classifier')->__typecheck($val, "UML::MetaModel::Foundation::Core::Parameter.type");

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


=head2 add_type

  $obj->add_type($val);

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

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

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

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

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

    # Remove and add associations with other ends.
        
  }

  $self;
}


=head2 remove_type

  $obj->remove_type($val);

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

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

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

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

    # Remove and add associations with other ends.
        
  }
}


=head2 clear_type

  $obj->clear_type;

Clears the Association.
Returns C<$obj>.

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

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

    # Remove and add associations with other ends.
        
  }

  $self;
}




#################################################################
# AssociationEnd parameter => state
# type = UML::MetaModel::Behavioral_Elements::Activity_Graphs::ObjectFlowState
# multiplicity = 0..*

=head2 state

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

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


=head2 set_state

  $obj->set_state(@val);

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

=cut
sub set_state ($@)
{
  my ($self, @val) = @_;
  
  $self->clear_state;
  $self->add_state(@val);
}


=head2 add_state

  $obj->add_state(@val);

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

=cut
sub add_state ($@)
{
  my ($self, @val) = @_;
  
  my $x = $self->{'state'} ||= [ ];
  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::Activity_Graphs::ObjectFlowState')->__typecheck($val, "UML::MetaModel::Foundation::Core::Parameter.state");

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

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

  
  }
  
  $self;
}


=head2 remove_state

  $obj->remove_state($val);

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

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

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

    # Remove associations with other ends.

        
    $old->remove_parameter($self) if $old;
    $val->add_parameter($self)    if $val;

  ;

  }
  
  $self;
}


=head2 clear_state

  $obj->clear_state;

Clears the Association.
Returns C<$obj>.

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

    # Remove associations with other ends.

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

