# -*- perl -*-
# DO NOT EDIT - This file is generated by UMMF; http://ummf.sourceforge.net 
# From template: $Id: PerlTemplate.txt,v 1.74 2004/08/01 03:50:07 kstephens Exp $

package UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralExp;

#use 5.6.1;
use strict;
use warnings;

#################################################################
# Version
#

our $VERSION = do { my @r = (q{1.0} =~ /\d+/g); sprintf "%d." . "%03d" x $#r, @r };


#################################################################
# Documentation
#

=head1 NAME

UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralExp -- 

=head1 VERSION

1.0

=head1 SYNOPSIS

=head1 DESCRIPTION 

=head1 USAGE

=head1 EXPORT

=head1 METATYPE

L<UMMF::UML::MetaModel::Foundation::Core::Class|UMMF::UML::MetaModel::Foundation::Core::Class>

=head1 SUPERCLASSES

L<UMMF::UML::MetaModel::OCL::Expressions::LiteralExp|UMMF::UML::MetaModel::OCL::Expressions::LiteralExp>




=head1 ATTRIBUTES


=head2 C<kind> : UMMF::UML::MetaModel::OCL::Expressions::CollectionKind 


=over 4

=item metatype = L<UMMF::UML::MetaModel::Foundation::Core::Attribute|UMMF::UML::MetaModel::Foundation::Core::Attribute>

=item type = L<UMMF::UML::MetaModel::OCL::Expressions::CollectionKind|UMMF::UML::MetaModel::OCL::Expressions::CollectionKind>

=item visibility = C<private>

=item multiplicity = C<1>

=item changeability = C<changeable>

=item targetScope = C<instance>

=item ordering = C<unordered>

=item initialValue = I<UNSPECIFIED>

=item container_type = C<Set::Object>

=back



=head1 ASSOCIATIONS


=head2 C<1> : C<collectionLiteralExp> E<lt>---E<gt>  C<parts> : UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralPart C<0..*>



=over 4

=item metatype = L<UMMF::UML::MetaModel::Foundation::Core::AssociationEnd|UMMF::UML::MetaModel::Foundation::Core::AssociationEnd>

=item type = L<UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralPart|UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralPart>

=item multiplicity = C<0..*>

=item changeability = C<changeable>

=item targetScope = C<instance>

=item ordering = C<ordered>

=item isNavigable = C<1>

=item aggregation = C<none>

=item visibility = C<public>

=item container_type = C<ARRAY>

=back



=head1 METHODS

=cut



#################################################################
# Dependencies
#





use Carp qw(croak confess);
use Set::Object 1.05;
use Class::Multimethods 1.70;
use Data::Dumper;
use Scalar::Util qw(weaken);
use UMMF::UML::MetaModel::__ObjectBase qw(:__ummf_array);


#################################################################
# Generalizations
#

use base qw(
  UMMF::UML::MetaModel::OCL::Expressions::LiteralExp



);


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

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





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


=head2 C<__validate_type>

  UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralExp->__validate_type($value);

Returns true if C<$value> is a valid representation of L<UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralExp|UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralExp>.

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

  no warnings;

  UNIVERSAL::isa($x, 'UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralExp')  ;
}


=head2 C<__typecheck>

  UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralExp->__typecheck($value, $msg);

Calls C<confess()> with C<$msg> if C<<UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralExp->__validate_type($value)>> is false.

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

  confess("typecheck: $msg: type '" . 'UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralExp' . ": value '$x'")
    unless __validate_type($self, $x);
}


=head2 C<isaCollectionLiteralExp>


Returns true if receiver is a L<UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralExp|UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralExp>.
Other receivers will return false.

=cut
sub isaCollectionLiteralExp { 1 }


=head2 C<isaOCL__Expressions__CollectionLiteralExp>


Returns true if receiver is a L<UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralExp|UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralExp>.
Other receivers will return false.
This is the fully qualified version of the C<isaCollectionLiteralExp> method.

=cut
sub isaOCL__Expressions__CollectionLiteralExp { 1 }


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

=head2 C<__model_name> 

  my $name = $obj_or_package->__model_name;

Returns the UML Model name (C<'OCL::Expressions::CollectionLiteralExp'>) for an object or package of
this Classifier.

=cut
sub __model_name { 'OCL::Expressions::CollectionLiteralExp' }



=head2 C<__isAbstract>

  $package->__isAbstract;

Returns C<0>.

=cut
sub __isAbstract { 0; }


my $__tangram_schema;
=head2 C<__tangram_schema>

  my $tangram_schema $obj_or_package->__tangram_schema

Returns a HASH ref that describes this Classifier for Tangram.

See L<UMMF::UML::Export::Perl::Tangram|UMMF::UML::Export::Perl::Tangram>

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

  $__tangram_schema ||=
  {
   'classes' =>
   [
     'UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralExp' =>
     {
       'table' => 'OCL__Expressions__CollectionLiteralExp',
       'abstract' => 0,
       'slots' => 
       { 
	 # Attributes
	 	       'kind'
       => {
	 'type_impl' => 'string',
                                             'col' => 'kind', 

                                                                                                                   }
      ,
         
	 # Associations
	 	 	       'parts'
       => {
	 'type_impl' => 'iarray',
         'class' => 'UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralPart',

                           'table' => 'OCL__Expressions__CollectionLiteralExp__parts', 

                                                               'coll' => 'collectionLiteralExp',

                  'slot' => 'collectionLiteralExp_i', 

                                                                      }
      ,
                         },
       'bases' => [  'UMMF::UML::MetaModel::OCL::Expressions::LiteralExp',  ],
       'sql' => {

       },
     },
   ],

   'sql' =>
   {
    # Note Tangram::Ref::get_exporter() has
    # "UPDATE $table SET $self->{col} = $refid WHERE id = $id",
    # The id_col is hard-coded, 
    # Thus id_col will not work.
    #'id_col' => '__sid',
    #'class_col' => '__stype',
   },
     # 'set_id' => sub { }
     # 'get_id' => sub { }

      
  };
}


#################################################################
# Class Attributes
#


      

#################################################################
# Class Associations
#


    

#################################################################
# Initialization
#


=head2 C<___initialize>

Initialize all Attributes and AssociationEnds in a instance of this Classifier.
Does B<not> initalize slots in its Generalizations.

See also: C<__initialize>.

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

  # Attributes

    # Attribute kind
  if ( exists $self->{'kind'} ) {
    my $x = $self->{'kind'};
    $self->{'kind'} = undef;
    $self->set_kind($x);
  } else {
      }
  


  # Associations

  # AssociationEnd 
  #  collectionLiteralExp 1
  #  <--> 
  #  parts 0..* UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralPart.
    if ( defined $self->{'parts'} ) {
    my $x = $self->{'parts'};
        $self->{'parts'} = [ ];
        $self->set_parts(@$x);
  }
  

  $self;
}


my $__initialize_use;

=head2 C<__initialize>

Initialize all slots in this Classifier and all its Generalizations.

See also: C<___initialize>.

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

  # $DB::single = 1;

  unless ( ! $__initialize_use ) {
    $__initialize_use = 1;
    $self->__use('UMMF::UML::MetaModel::Foundation::Core::Element');
    $self->__use('UMMF::UML::MetaModel::Foundation::Core::ModelElement');
    $self->__use('UMMF::UML::MetaModel::OCL::Expressions::OclExpression');
    $self->__use('UMMF::UML::MetaModel::OCL::Expressions::LiteralExp');
  }

  $self->UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralExp::___initialize;
  $self->UMMF::UML::MetaModel::Foundation::Core::Element::___initialize;
  $self->UMMF::UML::MetaModel::Foundation::Core::ModelElement::___initialize;
  $self->UMMF::UML::MetaModel::OCL::Expressions::OclExpression::___initialize;
  $self->UMMF::UML::MetaModel::OCL::Expressions::LiteralExp::___initialize;

  $self;
}
      

=head2 C<__create>

Calls all <<create>> Methods for this Classifier and all Generalizations.

See also: C<___create>.

=cut
sub __create
{
  my ($self, @args) = @_;

  # $DB::single = 1;
  $self->UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralExp::___create(@args);
  $self->UMMF::UML::MetaModel::Foundation::Core::Element::___create();
  $self->UMMF::UML::MetaModel::Foundation::Core::ModelElement::___create();
  $self->UMMF::UML::MetaModel::OCL::Expressions::OclExpression::___create();
  $self->UMMF::UML::MetaModel::OCL::Expressions::LiteralExp::___create();

  $self;
}




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



=for html <hr/>

=cut

#################################################################
# Attribute kind
# type = UMMF::UML::MetaModel::OCL::Expressions::CollectionKind
# multiplicity = 1
# ordering = unordered
# ownerScope = instance
# initialValue = 

=head2 C<kind>

  my $val = $obj->kind;

Returns the L<UMMF::UML::MetaModel::OCL::Expressions::CollectionKind|UMMF::UML::MetaModel::OCL::Expressions::CollectionKind> value of Attribute C<kind>.

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

  ;

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

  ;

  $val;
}


=head2 C<set_kind>

  $obj->set_kind($val);

Sets the value of Attribute C<kind>.
C<$val> must be of type L<UMMF::UML::MetaModel::OCL::Expressions::CollectionKind|UMMF::UML::MetaModel::OCL::Expressions::CollectionKind> or C<undef>.
Returns C<$obj>.

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

  ;

  if ( defined $val ) {
    $self->__use('UMMF::UML::MetaModel::OCL::Expressions::CollectionKind')->__typecheck($val, "UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralExp.kind");
  }

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

  ;

  $self;
}


=head2 C<count_kind>

  $obj->count_kind;

Returns the number of elements (0 or 1) in C<kind>.

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

  ;

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

  ;

  defined $val ? 1 : 0;
}




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


=for html <hr/>

=cut

#################################################################
# AssociationEnd collectionLiteralExp <---> parts
# type = UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralPart
# multiplicity = 0..*
# ordering = ordered

=head2 C<parts>

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

Returns the AssociationEnd C<parts> values of type L<UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralPart|UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralPart>.
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 parts ($)
{
  my ($self) = @_;

    my $x = $self->{'parts'} ||= [ ];

  wantarray ? @{$x} : $x;
  
}


=head2 C<index_parts>

  my $x = $obj->index_parts($i);
  my @x = $obj->index_parts($i, $count);

In scalar context, returns the value of AssociationEnd C<parts> at index C<$i>.
In array context, returns the values between index C<$i> and C<$i + $count - 1>, inclusive.

=cut
sub index_parts ($$@)
{
  my ($self, $i, $count) = @_;

  ;

  my $val = $self->{'parts'} ||= [ ];

  ;

  wantarray ? $val->[$i .. (defined $count ? $i + $count - 1 : $i)]
            : $val->[$i];
}


=head2 C<index_of_parts>

  my $index = $obj->index_of_parts($val);

Returns the index of C<$val> in AssociationEnd C<parts>.
Return C<undef> if C<$val> is not in C<parts>.

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

  ;

  my $val = $self->{'parts'} ||= [ ];

  ;

  __ummf_array_index($val, $x);
}


=head2 C<set_parts>

  $obj->set_parts(@val);

Sets the AssociationEnd C<parts> value.
Elements of C<@val> must of type L<UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralPart|UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralPart>.
Returns C<$obj>.

=cut
sub set_parts ($@)
{
  my ($self, @val) = @_;
  
  $self->clear_parts;
  $self->add_parts(@val);
}


=head2 C<set_index_parts>

  $obj->set_index_parts($i, $val);

Sets the value of AssociationEnd C<parts> at index C<$i>.
Returns self.

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

  ;

  my $x = $self->{'parts'} ||= [ ];

  no warnings;
  my $old;
  if ( ($old = $x->[$i]) ne $val) {
    # Recursion lock
        $x->[$i] = $val
    ;

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

  
    ;
  }

  $self;
}


=head2 C<add_parts>

  $obj->add_parts(@val);

Adds AssociationEnd C<parts> values.
Elements of C<@val> must of type L<UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralPart|UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralPart>.
Returns C<$obj>.

=cut
sub add_parts ($@)
{
  my ($self, @val) = @_;
  
    my $x = $self->{'parts'} ||= [ ];
    my $old; # Place holder for other MACRO.
  
  for my $val ( @val ) {
    # Recursion lock
        next if grep($_ eq $val, @$x);
        $self->__use('UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralPart')->__typecheck($val, "UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralExp.parts");

    # Recursion lock
        push(@{$x}, $val);
        
    # Remove and add associations with other ends.
        
    $old->remove_collectionLiteralExp($self) if $old;
    $val->add_collectionLiteralExp($self)    if $val;

    }
  
  $self;
}


=head2 C<add_index_parts>

  $obj->add_index_parts($i, @val);

Adds AssociationEnd C<parts> values at index C<$i>.
Elements of C<@val> must of type L<UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralPart|UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralPart>.
Returns C<$obj>.

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

  
    my $x = $self->{'parts'} ||= [ ];
    my $old; # Place holder for other MACRO.
  
  for my $val ( @val ) {
    # Recursion lock
        next if grep($_ eq $val, @$x);
        $self->__use('UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralPart')->__typecheck($val, "UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralExp.parts");

    # Recursion lock
        splice(@{$x}, $i, 0, $val); # Recursion lock
        ++ $i;
    
    # Remove and add associations with other ends.
        
    $old->remove_collectionLiteralExp($self) if $old;
    $val->add_collectionLiteralExp($self)    if $val;

    }
  
  
  $self;
}


=head2 C<remove_parts>

  $obj->remove_parts(@val);

Removes the AssociationEnd C<parts> values C<@val>.
Elements of C<@val> must of type L<UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralPart|UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralPart>.
Returns C<$obj>.

=cut
sub remove_parts ($@)
{
  my ($self, @val) = @_;
  
    my $x = $self->{'parts'} ||= [ ];
  
  for my $old ( @val ) {
    # Recursion lock
        my $i; # index of $old in @$x.
    next unless defined($i = __ummf_array_index($x, $old));
    
    my $val = $old;
      
    $self->__use('UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralPart')->__typecheck($val, "UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralExp.parts");

    # Recursion lock
        splice(@$x, $i, 1);     
    $val = undef;

    # Remove associations with other ends.

        
    $old->remove_collectionLiteralExp($self) if $old;
    $val->add_collectionLiteralExp($self)    if $val;

  ;

  }
  
  $self;
}


=head2 C<clear_parts>

  $obj->clear_parts;

Clears the AssociationEnd C<parts> links to L<UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralPart|UMMF::UML::MetaModel::OCL::Expressions::CollectionLiteralPart>.
Returns C<$obj>.

=cut
sub clear_parts ($) 
{
  my ($self) = @_;
  
    my $x = $self->{'parts'} ||= [ ];
  
  my $val; # Place holder for other MACRO.
  
    $self->{'parts'} = [ ];  # Recursion lock
  for my $old ( @$x ) { # Recursion lock
  
    # Remove associations with other ends.

        
    $old->remove_collectionLiteralExp($self) if $old;
    $val->add_collectionLiteralExp($self)    if $val;

  ;

  }
  
  $self;
}


=head2 C<count_parts>

  $obj->count_parts;

Returns the number of elements associated with C<parts>.

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

  my $x = $self->{'parts'};

    defined $x ? scalar @$x : 0;
  }







# End of Class CollectionLiteralExp


=pod

=for html <hr/>

I<END OF DOCUMENT>

=cut

############################################################################

1; # is true!

############################################################################

### Keep these comments at end of file: kstephens@users.sourceforge.net 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: ###

