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

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

Returns true if $value is a valid value of UML::MetaModel::Behavioral_Elements::State_Machines::StateVertex.

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

  no warnings;

  UNIVERSAL::isa($x, 'UML::MetaModel::Behavioral_Elements::State_Machines::StateVertex')  ;
}


=head2 __typecheck

  UML::MetaModel::Behavioral_Elements::State_Machines::StateVertex->__typecheck($value, $msg);

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

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

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


=head2 isaStateVertex

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

=cut
sub isaStateVertex { 1 }


=head2 isaBehavioral_Elements__State_Machines__StateVertex

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

=cut
sub isaBehavioral_Elements__State_Machines__StateVertex { 1 }


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

=head2 __model_name 

  my $name = $obj_or_package->__model_name;

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

=cut
sub __model_name { 'Behavioral_Elements::State_Machines::StateVertex' }





# ASSOC: subvertex

  

# ASSOC: source

  

# ASSOC: target

  


#################################################################
# 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 
  #  subvertex 0..*
  #  <--> 
  #  container_StateVertex 0..1 UML::MetaModel::Behavioral_Elements::State_Machines::CompositeState.
    if ( defined $self->{'container_StateVertex'} ) {
    my $x = $self->{'container_StateVertex'};
    $self->{'container_StateVertex'} = undef;
    $self->set_container_StateVertex($x);
  }
  
  # AssociationEnd 
  #  source 1
  #  <--> 
  #  outgoing 0..* UML::MetaModel::Behavioral_Elements::State_Machines::Transition.
    if ( defined $self->{'outgoing'} && @{$self->{'outgoing'}} ) {
    my $x = $self->{'outgoing'};
    $self->{'outgoing'} = [ ];
    $self->set_outgoing(@$x);
  }
  
  # AssociationEnd 
  #  target 1
  #  <--> 
  #  incoming 0..* UML::MetaModel::Behavioral_Elements::State_Machines::Transition.
    if ( defined $self->{'incoming'} && @{$self->{'incoming'}} ) {
    my $x = $self->{'incoming'};
    $self->{'incoming'} = [ ];
    $self->set_incoming(@$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::State_Machines::StateVertex::__initialize;
  $self->UML::MetaModel::Foundation::Core::Element::__initialize;
  $self->UML::MetaModel::Foundation::Core::ModelElement::__initialize;

  $self;
}
      

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




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


#################################################################
# AssociationEnd subvertex => container_StateVertex
# type = UML::MetaModel::Behavioral_Elements::State_Machines::CompositeState
# multiplicity = 0..1

=head2 container_StateVertex

  my $val = $obj->container_StateVertex;

Returns the AssociationEnd value of type C<UML::MetaModel::Behavioral_Elements::State_Machines::CompositeState>.

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


=head2 set_container_StateVertex

  $obj->set_container_StateVertex($val);

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

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

    $self->__use('UML::MetaModel::Behavioral_Elements::State_Machines::CompositeState')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::State_Machines::StateVertex.container_StateVertex");

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

    }
		  
  $self;
}


=head2 add_container_StateVertex

  $obj->add_container_StateVertex($val);

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

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

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

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

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

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

  
  }

  $self;
}


=head2 remove_container_StateVertex

  $obj->remove_container_StateVertex($val);

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

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

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

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

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

  
  }
}


=head2 clear_container_StateVertex

  $obj->clear_container_StateVertex;

Clears the Association.
Returns C<$obj>.

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

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

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

  
  }

  $self;
}




#################################################################
# AssociationEnd source => outgoing
# type = UML::MetaModel::Behavioral_Elements::State_Machines::Transition
# multiplicity = 0..*

=head2 outgoing

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

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


=head2 set_outgoing

  $obj->set_outgoing(@val);

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

=cut
sub set_outgoing ($@)
{
  my ($self, @val) = @_;
  
  $self->clear_outgoing;
  $self->add_outgoing(@val);
}


=head2 add_outgoing

  $obj->add_outgoing(@val);

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

=cut
sub add_outgoing ($@)
{
  my ($self, @val) = @_;
  
  my $x = $self->{'outgoing'} ||= [ ];
  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::State_Machines::Transition')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::State_Machines::StateVertex.outgoing");

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

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

  
  }
  
  $self;
}


=head2 remove_outgoing

  $obj->remove_outgoing($val);

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

=cut
sub remove_outgoing ($@)
{
  my ($self, @val) = @_;
  
  my $x = $self->{'outgoing'} ||= [ ];
  
  for my $old ( @val ) {
    next unless grep($_ eq $old, @$x); # Recursion lock
    my $val = $old;
      
    $self->__use('UML::MetaModel::Behavioral_Elements::State_Machines::Transition')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::State_Machines::StateVertex.outgoing");

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

    # Remove associations with other ends.

        
    $old->remove_source($self) if $old;
    $val->add_source($self)    if $val;

  ;

  }
  
  $self;
}


=head2 clear_outgoing

  $obj->clear_outgoing;

Clears the Association.
Returns C<$obj>.

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

    # Remove associations with other ends.

        
    $old->remove_source($self) if $old;
    $val->add_source($self)    if $val;

  ;

  }
  
  $self;
}


#################################################################
# AssociationEnd target => incoming
# type = UML::MetaModel::Behavioral_Elements::State_Machines::Transition
# multiplicity = 0..*

=head2 incoming

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

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


=head2 set_incoming

  $obj->set_incoming(@val);

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

=cut
sub set_incoming ($@)
{
  my ($self, @val) = @_;
  
  $self->clear_incoming;
  $self->add_incoming(@val);
}


=head2 add_incoming

  $obj->add_incoming(@val);

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

=cut
sub add_incoming ($@)
{
  my ($self, @val) = @_;
  
  my $x = $self->{'incoming'} ||= [ ];
  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::State_Machines::Transition')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::State_Machines::StateVertex.incoming");

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

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

  
  }
  
  $self;
}


=head2 remove_incoming

  $obj->remove_incoming($val);

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

=cut
sub remove_incoming ($@)
{
  my ($self, @val) = @_;
  
  my $x = $self->{'incoming'} ||= [ ];
  
  for my $old ( @val ) {
    next unless grep($_ eq $old, @$x); # Recursion lock
    my $val = $old;
      
    $self->__use('UML::MetaModel::Behavioral_Elements::State_Machines::Transition')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::State_Machines::StateVertex.incoming");

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

    # Remove associations with other ends.

        
    $old->remove_target($self) if $old;
    $val->add_target($self)    if $val;

  ;

  }
  
  $self;
}


=head2 clear_incoming

  $obj->clear_incoming;

Clears the Association.
Returns C<$obj>.

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

    # Remove associations with other ends.

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

