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

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


);

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

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





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


=head2 __validate_type

  UML::MetaModel::Foundation::Core::Generalization->__validate_type($value);

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

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

  no warnings;

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


=head2 __typecheck

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

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

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

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


=head2 isaGeneralization

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

=cut
sub isaGeneralization { 1 }


=head2 isaFoundation__Core__Generalization

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

=cut
sub isaFoundation__Core__Generalization { 1 }


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

=head2 __model_name 

  my $name = $obj_or_package->__model_name;

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

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





# ASSOC: generalization

  

# ASSOC: specialization

  

# ASSOC: powertypeRange

  


#################################################################
# 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 
  #  generalization 0..*
  #  <--> 
  #  child 1 UML::MetaModel::Foundation::Core::GeneralizableElement.
    if ( defined $self->{'child'} ) {
    my $x = $self->{'child'};
    $self->{'child'} = undef;
    $self->set_child($x);
  }
  
  # AssociationEnd 
  #  specialization 0..*
  #  <--> 
  #  parent 1 UML::MetaModel::Foundation::Core::GeneralizableElement.
    if ( defined $self->{'parent'} ) {
    my $x = $self->{'parent'};
    $self->{'parent'} = undef;
    $self->set_parent($x);
  }
  
  # AssociationEnd 
  #  powertypeRange 0..*
  #  <--> 
  #  powertype 0..1 UML::MetaModel::Foundation::Core::Classifier.
    if ( defined $self->{'powertype'} ) {
    my $x = $self->{'powertype'};
    $self->{'powertype'} = undef;
    $self->set_powertype($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->__use('UML::MetaModel::Foundation::Core::Relationship');
  }

  $self->UML::MetaModel::Foundation::Core::Generalization::__initialize;
  $self->UML::MetaModel::Foundation::Core::Element::__initialize;
  $self->UML::MetaModel::Foundation::Core::ModelElement::__initialize;
  $self->UML::MetaModel::Foundation::Core::Relationship::__initialize;

  $self;
}
      

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




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


#################################################################
# AssociationEnd generalization => child
# type = UML::MetaModel::Foundation::Core::GeneralizableElement
# multiplicity = 1

=head2 child

  my $val = $obj->child;

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

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


=head2 set_child

  $obj->set_child($val);

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

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

    $self->__use('UML::MetaModel::Foundation::Core::GeneralizableElement')->__typecheck($val, "UML::MetaModel::Foundation::Core::Generalization.child");

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

    }
		  
  $self;
}


=head2 add_child

  $obj->add_child($val);

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

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

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

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

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

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

  
  }

  $self;
}


=head2 remove_child

  $obj->remove_child($val);

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

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

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

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

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

  
  }
}


=head2 clear_child

  $obj->clear_child;

Clears the Association.
Returns C<$obj>.

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

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

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

  
  }

  $self;
}




#################################################################
# AssociationEnd specialization => parent
# type = UML::MetaModel::Foundation::Core::GeneralizableElement
# multiplicity = 1

=head2 parent

  my $val = $obj->parent;

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

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


=head2 set_parent

  $obj->set_parent($val);

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

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

    $self->__use('UML::MetaModel::Foundation::Core::GeneralizableElement')->__typecheck($val, "UML::MetaModel::Foundation::Core::Generalization.parent");

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

    }
		  
  $self;
}


=head2 add_parent

  $obj->add_parent($val);

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

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

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

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

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

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

  
  }

  $self;
}


=head2 remove_parent

  $obj->remove_parent($val);

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

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

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

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

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

  
  }
}


=head2 clear_parent

  $obj->clear_parent;

Clears the Association.
Returns C<$obj>.

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

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

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

  
  }

  $self;
}




#################################################################
# AssociationEnd powertypeRange => powertype
# type = UML::MetaModel::Foundation::Core::Classifier
# multiplicity = 0..1

=head2 powertype

  my $val = $obj->powertype;

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

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


=head2 set_powertype

  $obj->set_powertype($val);

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

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

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

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

    }
		  
  $self;
}


=head2 add_powertype

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

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

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

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

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

  
  }

  $self;
}


=head2 remove_powertype

  $obj->remove_powertype($val);

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

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

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

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

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

  
  }
}


=head2 clear_powertype

  $obj->clear_powertype;

Clears the Association.
Returns C<$obj>.

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

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

    # Remove and add associations with other ends.
        
    $old->remove_powertypeRange($self) if $old;
    $val->add_powertypeRange($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: ###

