comparison Lib/Schema/DB/Column.pm @ 0:03e58a454b20

Создан репозитарий
author Sergey
date Tue, 14 Jul 2009 12:54:37 +0400
parents
children 16ada169ca75
comparison
equal deleted inserted replaced
-1:000000000000 0:03e58a454b20
1 package Schema::DB::Column;
2 use Common;
3 our @ISA = qw(Object);
4
5 BEGIN {
6 DeclareProperty Name => ACCESS_READ;
7 DeclareProperty Type => ACCESS_READ;
8 DeclareProperty CanBeNull => ACCESS_READ;
9 DeclareProperty DefaultValue => ACCESS_READ;
10 DeclareProperty Tag => ACCESS_READ;
11 }
12
13 sub CTOR {
14 my $this = shift;
15 $this->SUPER::CTOR(@_);
16
17 $this->{$Name} or die new Exception('a column name is required');
18 $this->{$CanBeNull} = 0 if not exists $this->{$CanBeNull};
19 UNIVERSAL::isa($this->{$Type},'Schema::DB::Type') or die new Exception('a type is required for the column',$this->{$Name});
20 }
21
22 sub isEqualsStr {
23 my ($a,$b) = @_;
24
25 if (defined $a and defined $b) {
26 return $a eq $b;
27 } else {
28 if (defined $a or defined $b) {
29 return 0;
30 } else {
31 return 1;
32 }
33 }
34 }
35
36 sub isEquals {
37 my ($a,$b) = @_;
38
39 if (defined $a and defined $b) {
40 return $a == $b;
41 } else {
42 if (defined $a or defined $b) {
43 return 0;
44 } else {
45 return 1;
46 }
47 }
48 }
49
50 sub isSame {
51 my ($this,$other) = @_;
52
53 return ($this->{$Name} eq $other->{$Name} and $this->{$CanBeNull} == $other->{$CanBeNull} and isEqualsStr($this->{$DefaultValue}, $other->{$DefaultValue}) and $this->{$Type}->isSame($other->{$Type}));
54 }
55
56 1;