File Coverage

blib/lib/JMX/Jmx4Perl/Alias/Object.pm
Criterion Covered Total %
statement 13 18 72.2
branch 1 2 50.0
condition 2 6 33.3
subroutine 8 13 61.5
pod 5 8 62.5
total 29 47 61.7


line stmt bran cond sub pod time code
1             package JMX::Jmx4Perl::Alias::Object;
2              
3             =head1 NAME
4              
5             JMX::Jmx4Perl::Alias::Object - Internal object representing a concrete alias
6              
7             =head1 DESCRIPTION
8              
9             Simple object which describes an alias. It knows about the following read-only
10             methods
11              
12             =over
13              
14             =item $alias->alias()
15              
16             alias name in uppercase form (e.g. C)
17              
18             =item $alias->name()
19              
20             alias name in lowercase format (e.g. C)
21              
22             =item $alias->description()
23              
24             short description of the alias
25              
26             =item $alias->default()
27              
28             default values for an alias, which can be overwritten by a specific
29             L. This is an arrayref with two values:
30             The MBean's name and the attribute or operation name.
31              
32             =item $alias->type()
33              
34             Either C or C, depending on what kind of MBean part the
35             alias stands for.
36              
37             =back
38              
39             Additional, the C<"">, C<==> and C operators are overloaded to naturally
40             compare and stringify alias values.
41              
42             =cut
43              
44 4     4   26 use Scalar::Util qw(refaddr);
  4         6  
  4         674  
45              
46             use overload
47 10     10   27 q{""} => sub { (shift)->as_string(@_) },
48 2     2   9 q{==} => sub { (shift)->equals(@_) },
49 4     4   21 q{!=} => sub { !(shift)->equals(@_) };
  4     0   9  
  4         56  
  0         0  
50              
51             sub equals {
52 2 50 33 2 0 30 return (ref $_[0] eq ref $_[1] && refaddr $_[0] == refaddr $_[1]) ? 1 : 0;
53             }
54              
55             sub new {
56 228     228 0 244 my $class = shift;
57 228   33     2031 return bless { @_ },ref($class) || $class;
58             }
59              
60 10     10 0 34 sub as_string { return $_[0]->{alias}; }
61 0     0 1 0 sub alias { return shift->{alias}; }
62 1     1 1 45 sub name { return shift->{name}; }
63 0     0 1   sub description { return shift->{description}; }
64 0     0 1   sub default { return shift->{default}; }
65 0     0 1   sub type { return shift->{type}; }
66              
67             =head1 LICENSE
68              
69             This file is part of jmx4perl.
70              
71             Jmx4perl is free software: you can redistribute it and/or modify
72             it under the terms of the GNU General Public License as published by
73             the Free Software Foundation, either version 2 of the License, or
74             (at your option) any later version.
75              
76             jmx4perl is distributed in the hope that it will be useful,
77             but WITHOUT ANY WARRANTY; without even the implied warranty of
78             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
79             GNU General Public License for more details.
80              
81             You should have received a copy of the GNU General Public License
82             along with jmx4perl. If not, see .
83              
84             A commercial license is available as well. Please contact roland@cpan.org for
85             further details.
86              
87             =head1 PROFESSIONAL SERVICES
88              
89             Just in case you need professional support for this module (or Nagios or JMX in
90             general), you might want to have a look at
91             http://www.consol.com/opensource/nagios/. Contact roland.huss@consol.de for
92             further information (or use the contact form at http://www.consol.com/contact/)
93              
94             =head1 AUTHOR
95              
96             roland@cpan.org
97              
98             =cut
99              
100             1;