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

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

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

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

  no warnings;

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


=head2 __typecheck

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

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

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

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


=head2 isaConstraint

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

=cut
sub isaConstraint { 1 }


=head2 isaFoundation__Core__Constraint

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

=cut
sub isaFoundation__Core__Constraint { 1 }


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

=head2 __model_name 

  my $name = $obj_or_package->__model_name;

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

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




  



# ASSOC: constraint

  

# ASSOC: stereotypeConstraint

  


#################################################################
# 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 body
  if ( exists $self->{'body'} ) {
    my $x = $self->{'body'};
    $self->{'body'} = undef;
    $self->set_body($x);
  } else {
      }
  


  # Associations

  # AssociationEnd 
  #  constraint 0..*
  #  <--> 
  #  constrainedElement 0..1 UML::MetaModel::Foundation::Core::ModelElement.
    if ( defined $self->{'constrainedElement'} ) {
    my $x = $self->{'constrainedElement'};
    $self->{'constrainedElement'} = undef;
    $self->set_constrainedElement($x);
  }
  
  # AssociationEnd 
  #  stereotypeConstraint 0..*
  #  <--> 
  #  constrainedStereotype 0..1 UML::MetaModel::Foundation::Extension_Mechanisms::Stereotype.
    if ( defined $self->{'constrainedStereotype'} ) {
    my $x = $self->{'constrainedStereotype'};
    $self->{'constrainedStereotype'} = undef;
    $self->set_constrainedStereotype($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::Constraint::__initialize;
  $self->UML::MetaModel::Foundation::Core::Element::__initialize;
  $self->UML::MetaModel::Foundation::Core::ModelElement::__initialize;

  $self;
}
      

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



#################################################################
# Attribute body
# type = UML::MetaModel::Foundation::Data_Types::BooleanExpression
# multiplicity = 1

=head2 body

  my $val = $obj->body;

Returns the value of Attribute body.

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

  $self->{'body'};
}


=head2 set_body

  $obj->set_body($val);

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

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

  $self->__use('UML::MetaModel::Foundation::Data_Types::BooleanExpression')->__typecheck($val, "UML::MetaModel::Foundation::Core::Constraint.body");

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

  $self
}


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


#################################################################
# AssociationEnd constraint => constrainedElement
# type = UML::MetaModel::Foundation::Core::ModelElement
# multiplicity = 0..1

=head2 constrainedElement

  my $val = $obj->constrainedElement;

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

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


=head2 set_constrainedElement

  $obj->set_constrainedElement($val);

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

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

    $self->__use('UML::MetaModel::Foundation::Core::ModelElement')->__typecheck($val, "UML::MetaModel::Foundation::Core::Constraint.constrainedElement");

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

    }
		  
  $self;
}


=head2 add_constrainedElement

  $obj->add_constrainedElement($val);

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

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

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

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

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

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

  
  }

  $self;
}


=head2 remove_constrainedElement

  $obj->remove_constrainedElement($val);

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

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

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

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

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

  
  }
}


=head2 clear_constrainedElement

  $obj->clear_constrainedElement;

Clears the Association.
Returns C<$obj>.

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

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

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

  
  }

  $self;
}




#################################################################
# AssociationEnd stereotypeConstraint => constrainedStereotype
# type = UML::MetaModel::Foundation::Extension_Mechanisms::Stereotype
# multiplicity = 0..1

=head2 constrainedStereotype

  my $val = $obj->constrainedStereotype;

Returns the AssociationEnd value of type C<UML::MetaModel::Foundation::Extension_Mechanisms::Stereotype>.

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


=head2 set_constrainedStereotype

  $obj->set_constrainedStereotype($val);

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

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

    $self->__use('UML::MetaModel::Foundation::Extension_Mechanisms::Stereotype')->__typecheck($val, "UML::MetaModel::Foundation::Core::Constraint.constrainedStereotype");

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

    }
		  
  $self;
}


=head2 add_constrainedStereotype

  $obj->add_constrainedStereotype($val);

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

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

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

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

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

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

  
  }

  $self;
}


=head2 remove_constrainedStereotype

  $obj->remove_constrainedStereotype($val);

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

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

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

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

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

  
  }
}


=head2 clear_constrainedStereotype

  $obj->clear_constrainedStereotype;

Clears the Association.
Returns C<$obj>.

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

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

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

