line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSON::TypeInference::Type::Maybe; |
2
|
4
|
|
|
4
|
|
1930
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
98
|
|
3
|
4
|
|
|
4
|
|
18
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
116
|
|
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
19
|
use List::Util qw(any); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
1235
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub looks_like_maybe { |
9
|
26
|
|
|
26
|
1
|
2491
|
my ($class, $candidate_types) = @_; |
10
|
26
|
|
100
|
8
|
|
185
|
return (scalar(@$candidate_types) == 2) && any { $_->isa('JSON::TypeInference::Type::Null') } @$candidate_types; |
|
8
|
|
|
|
|
101
|
|
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
2
|
|
|
2
|
0
|
13
|
my ($class, $type) = @_; |
15
|
2
|
|
|
|
|
13
|
return bless { type => $type }, $class; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub name { |
19
|
0
|
|
|
0
|
0
|
0
|
my ($class) = @_; |
20
|
0
|
|
|
|
|
0
|
return 'maybe'; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub type { |
24
|
2
|
|
|
2
|
0
|
1135
|
my ($self) = @_; |
25
|
2
|
|
|
|
|
16
|
return $self->{type}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub signature { |
29
|
1
|
|
|
1
|
0
|
6
|
my ($self) = @_; |
30
|
1
|
|
|
|
|
5
|
return sprintf 'maybe[%s]', $self->type->signature; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub accepts { |
34
|
7
|
|
|
7
|
0
|
1584
|
my ($class, $data) = @_; |
35
|
7
|
|
|
|
|
27
|
return 0; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
__END__ |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=encoding utf-8 |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 NAME |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
JSON::TypeInference::Type::Maybe - maybe type |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 DESCRIPTION |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
C< JSON::TypeInference::Type::Maybe > represents a possibility whether a value type exists or not. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
The type consists of a value type and C<< JSON::TypeInference::Type::Null >>. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
It is a container type, and has a type parameter. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 METHODS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=over 4 |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item C<< looks_like_maybe($candidate_types: ArrayRef[JSON::TypeInference::Type]); # => Bool >> |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Returns whether the given types conform to C< JSON::TypeInference::Type::Maybe > structure. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=back |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 AUTHOR |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
aereal E<lt>aereal@aereal.orgE<gt> |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 SEE ALSO |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
L<JSON::TypeInference::Type::Null> |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|