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

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

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

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

  no warnings;

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


=head2 __typecheck

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

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

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

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


=head2 isaGeneralizableElement

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

=cut
sub isaGeneralizableElement { 1 }


=head2 isaFoundation__Core__GeneralizableElement

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

=cut
sub isaFoundation__Core__GeneralizableElement { 1 }


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

=head2 __model_name 

  my $name = $obj_or_package->__model_name;

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

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




  


  


  



# ASSOC: child

  

# ASSOC: parent

  


#################################################################
# 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 isRoot
  if ( exists $self->{'isRoot'} ) {
    my $x = $self->{'isRoot'};
    $self->{'isRoot'} = undef;
    $self->set_isRoot($x);
  } else {
      }
  
    # Attribute isLeaf
  if ( exists $self->{'isLeaf'} ) {
    my $x = $self->{'isLeaf'};
    $self->{'isLeaf'} = undef;
    $self->set_isLeaf($x);
  } else {
      }
  
    # Attribute isAbstract
  if ( exists $self->{'isAbstract'} ) {
    my $x = $self->{'isAbstract'};
    $self->{'isAbstract'} = undef;
    $self->set_isAbstract($x);
  } else {
      }
  


  # Associations

  # AssociationEnd 
  #  child 1
  #  <--> 
  #  generalization 0..* UML::MetaModel::Foundation::Core::Generalization.
    if ( defined $self->{'generalization'} && @{$self->{'generalization'}} ) {
    my $x = $self->{'generalization'};
    $self->{'generalization'} = [ ];
    $self->set_generalization(@$x);
  }
  
  # AssociationEnd 
  #  parent 1
  #  <--> 
  #  specialization 0..* UML::MetaModel::Foundation::Core::Generalization.
    if ( defined $self->{'specialization'} && @{$self->{'specialization'}} ) {
    my $x = $self->{'specialization'};
    $self->{'specialization'} = [ ];
    $self->set_specialization(@$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::GeneralizableElement::__initialize;
  $self->UML::MetaModel::Foundation::Core::Element::__initialize;
  $self->UML::MetaModel::Foundation::Core::ModelElement::__initialize;

  $self;
}
      

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



#################################################################
# Attribute isRoot
# type = UML::MetaModel::Foundation::Data_Types::Boolean
# multiplicity = 1

=head2 isRoot

  my $val = $obj->isRoot;

Returns the value of Attribute isRoot.

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

  $self->{'isRoot'};
}


=head2 set_isRoot

  $obj->set_isRoot($val);

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

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

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

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

  $self
}

#################################################################
# Attribute isLeaf
# type = UML::MetaModel::Foundation::Data_Types::Boolean
# multiplicity = 1

=head2 isLeaf

  my $val = $obj->isLeaf;

Returns the value of Attribute isLeaf.

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

  $self->{'isLeaf'};
}


=head2 set_isLeaf

  $obj->set_isLeaf($val);

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

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

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

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

  $self
}

#################################################################
# Attribute isAbstract
# type = UML::MetaModel::Foundation::Data_Types::Boolean
# multiplicity = 1

=head2 isAbstract

  my $val = $obj->isAbstract;

Returns the value of Attribute isAbstract.

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

  $self->{'isAbstract'};
}


=head2 set_isAbstract

  $obj->set_isAbstract($val);

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

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

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

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

  $self
}


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


#################################################################
# AssociationEnd child => generalization
# type = UML::MetaModel::Foundation::Core::Generalization
# multiplicity = 0..*

=head2 generalization

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

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


=head2 set_generalization

  $obj->set_generalization(@val);

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

=cut
sub set_generalization ($@)
{
  my ($self, @val) = @_;
  
  $self->clear_generalization;
  $self->add_generalization(@val);
}


=head2 add_generalization

  $obj->add_generalization(@val);

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

=cut
sub add_generalization ($@)
{
  my ($self, @val) = @_;
  
  my $x = $self->{'generalization'} ||= [ ];
  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::Generalization')->__typecheck($val, "UML::MetaModel::Foundation::Core::GeneralizableElement.generalization");

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

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

  
  }
  
  $self;
}


=head2 remove_generalization

  $obj->remove_generalization($val);

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

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

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

    # Remove associations with other ends.

        
    $old->remove_child($self) if $old;
    $val->add_child($self)    if $val;

  ;

  }
  
  $self;
}


=head2 clear_generalization

  $obj->clear_generalization;

Clears the Association.
Returns C<$obj>.

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

    # Remove associations with other ends.

        
    $old->remove_child($self) if $old;
    $val->add_child($self)    if $val;

  ;

  }
  
  $self;
}


#################################################################
# AssociationEnd parent => specialization
# type = UML::MetaModel::Foundation::Core::Generalization
# multiplicity = 0..*

=head2 specialization

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

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


=head2 set_specialization

  $obj->set_specialization(@val);

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

=cut
sub set_specialization ($@)
{
  my ($self, @val) = @_;
  
  $self->clear_specialization;
  $self->add_specialization(@val);
}


=head2 add_specialization

  $obj->add_specialization(@val);

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

=cut
sub add_specialization ($@)
{
  my ($self, @val) = @_;
  
  my $x = $self->{'specialization'} ||= [ ];
  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::Generalization')->__typecheck($val, "UML::MetaModel::Foundation::Core::GeneralizableElement.specialization");

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

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

  
  }
  
  $self;
}


=head2 remove_specialization

  $obj->remove_specialization($val);

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

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

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

    # Remove associations with other ends.

        
    $old->remove_parent($self) if $old;
    $val->add_parent($self)    if $val;

  ;

  }
  
  $self;
}


=head2 clear_specialization

  $obj->clear_specialization;

Clears the Association.
Returns C<$obj>.

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

    # Remove associations with other ends.

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

