Object/FormatCondition.pm untested

filter: Statementstmt 0.0% 0 / 111 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 24 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 150 CC 6 SCAR 14.7
CC
6
Cov
0%
from_hash
12.0
_deserialize
12.0
TO_JSON
6.0
CRAP 4.3
1 =begin comment
2
3 Copyright (c) 2026 Aspose.Cells Cloud
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21
22 =end comment
23
24 =cut
25
26 package AsposeCellsCloud::Object::FormatCondition;
27
28 require 5.6.0;
29 use strict;
30 use warnings;
31 use utf8;
32 use JSON qw(decode_json);
33 use Data::Dumper;
34 use Module::Runtime qw(use_module);
35 use Log::Any qw($log);
36 use Date::Parse;
37 use DateTime;
38 use AsposeCellsCloud::Object::AboveAverage;
39 use AsposeCellsCloud::Object::ColorScale;
40 use AsposeCellsCloud::Object::DataBar;
41 use AsposeCellsCloud::Object::IconSet;
42 use AsposeCellsCloud::Object::Link;
43 use AsposeCellsCloud::Object::LinkElement;
44 use AsposeCellsCloud::Object::Style;
45 use AsposeCellsCloud::Object::Top10;
46
47
48 use base ("Class::Accessor", "Class::Data::Inheritable");
49
50
51
52 __PACKAGE__->mk_classdata('attribute_map' => {});
53 __PACKAGE__->mk_classdata('swagger_types' => {});
54 __PACKAGE__->mk_classdata('method_documentation' => {});
55 __PACKAGE__->mk_classdata('class_documentation' => {});
56
57 # new object
58 sub new {
59 my ($class, %args) = @_;
60
61 my $self = bless {}, $class;
62
63 foreach my $attribute (keys %{$class->attribute_map}) {
64 my $args_key = $class->attribute_map->{$attribute};
65 $self->$attribute( $args{ $args_key } );
66 }
67
68 return $self;
69 }
70
71 # return perl hash
72 sub to_hash {
73 return decode_json(JSON->new->convert_blessed->encode( shift ));
74 }
75
76 # used by JSON for serialization
77 sub TO_JSON {
78 my $self = shift;
79 my $_data = {};
80 foreach my $_key (keys %{$self->attribute_map}) {
81 if (defined $self->{$_key}) {
82 $_data->{$self->attribute_map->{$_key}} = $self->{$_key};
83 }
84 }
85 return $_data;
86 }
87
88 # from Perl hashref
89 sub from_hash {
90 my ($self, $hash) = @_;
91
92 # loop through attributes and use swagger_types to deserialize the data
93 while ( my ($_key, $_type) = each %{$self->swagger_types} ) {
94 my $_json_attribute = $self->attribute_map->{$_key};
95 if ($_type =~ /^array\[/i) { # array
96 my $_subclass = substr($_type, 6, -1);
97 my @_array = ();
98 foreach my $_element (@{$hash->{$_json_attribute}}) {
99 push @_array, $self->_deserialize($_subclass, $_element);
100 }
101 $self->{$_key} = \@_array;
102 } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
103 $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
104 } else {
105 $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
106 }
107 }
108
109 return $self;
110 }
111
112 # deserialize non-array data
113 sub _deserialize {
114 my ($self, $type, $data) = @_;
115 $log->debugf("deserializing %s with %s",Dumper($data), $type);
116
117 if ($type eq 'DateTime') {
118 return DateTime->from_epoch(epoch => str2time($data));
119 } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
120 return $data;
121 } else { # hash(model)
122 my $_instance = eval "AsposeCellsCloud::Object::$type->new()";
123 return $_instance->from_hash($data);
124 }
125 }
126
127
128 __PACKAGE__->class_documentation({description => 'Represents conditional formatting condition.',
129 class => 'FormatCondition',
130 required => [], # TODO
131 } );
132
133
134 __PACKAGE__->method_documentation({
135 'priority' => {
136 datatype => 'int',
137 base_name => 'Priority',
138 description => 'The priority of this conditional formatting rule. This value is used to determine which format should be evaluated and rendered. Lower numeric values are higher priority than higher numeric values, where `1` is the highest priority.',
139 format => '',
140 read_only => '',
141 },
142 'type' => {
143 datatype => 'string',
144 base_name => 'Type',
145 description => 'Gets and sets whether the conditional format Type.',
146 format => '',
147 read_only => '',
148 },
149 'stop_if_true' => {
150 datatype => 'boolean',
151 base_name => 'StopIfTrue',
152 description => 'True, no rules with lower priority may be applied over this rule, when this rule evaluates to true. Only applies for Excel 2007;',
153 format => '',
154 read_only => '',
155 },
156 'above_average' => {
157 datatype => 'AboveAverage',
158 base_name => 'AboveAverage',
159 description => 'Get the conditional formatting`s "AboveAverage" instance. The default instance`s rule highlights cells that are above the average for all values in the range. Valid only for type = AboveAverage.',
160 format => '',
161 read_only => '',
162 },
163 'color_scale' => {
164 datatype => 'ColorScale',
165 base_name => 'ColorScale',
166 description => 'Get the conditional formatting`s "ColorScale" instance. The default instance is a "green-yellow-red" 3ColorScale . Valid only for type = ColorScale.',
167 format => '',
168 read_only => '',
169 },
170 'data_bar' => {
171 datatype => 'DataBar',
172 base_name => 'DataBar',
173 description => 'Get the conditional formatting`s "DataBar" instance. The default instance`s color is blue. Valid only for type is DataBar.',
174 format => '',
175 read_only => '',
176 },
177 'formula1' => {
178 datatype => 'string',
179 base_name => 'Formula1',
180 description => 'Gets and sets the value or expression associated with conditional formatting.',
181 format => '',
182 read_only => '',
183 },
184 'formula2' => {
185 datatype => 'string',
186 base_name => 'Formula2',
187 description => 'Gets and sets the value or expression associated with conditional formatting.',
188 format => '',
189 read_only => '',
190 },
191 'icon_set' => {
192 datatype => 'IconSet',
193 base_name => 'IconSet',
194 description => 'Get the conditional formatting`s "IconSet" instance. The default instance`s IconSetType is TrafficLights31. Valid only for type = IconSet.',
195 format => '',
196 read_only => '',
197 },
198 'operator' => {
199 datatype => 'string',
200 base_name => 'Operator',
201 description => 'Gets and sets the conditional format operator type.',
202 format => '',
203 read_only => '',
204 },
205 'style' => {
206 datatype => 'Style',
207 base_name => 'Style',
208 description => 'Gets or setts style of conditional formatted cell ranges.',
209 format => '',
210 read_only => '',
211 },
212 'text' => {
213 datatype => 'string',
214 base_name => 'Text',
215 description => 'The text value in a "text contains" conditional formatting rule. Valid only for type = containsText, notContainsText, beginsWith and endsWith. The default value is null.',
216 format => '',
217 read_only => '',
218 },
219 'time_period' => {
220 datatype => 'string',
221 base_name => 'TimePeriod',
222 description => 'The applicable time period in a "date occurring…" conditional formatting rule. Valid only for type = timePeriod. The default value is TimePeriodType.Today.',
223 format => '',
224 read_only => '',
225 },
226 'top10' => {
227 datatype => 'Top10',
228 base_name => 'Top10',
229 description => 'Get the conditional formatting`s "Top10" instance. The default instance`s rule highlights cells whose values fall in the top 10 bracket. Valid only for type is Top10.',
230 format => '',
231 read_only => '',
232 },
233 'link' => {
234 datatype => 'Link',
235 base_name => 'link',
236 description => '',
237 format => '',
238 read_only => '',
239 },
240 });
241
242 __PACKAGE__->swagger_types( {
243 'priority' => 'int',
244 'type' => 'string',
245 'stop_if_true' => 'boolean',
246 'above_average' => 'AboveAverage',
247 'color_scale' => 'ColorScale',
248 'data_bar' => 'DataBar',
249 'formula1' => 'string',
250 'formula2' => 'string',
251 'icon_set' => 'IconSet',
252 'operator' => 'string',
253 'style' => 'Style',
254 'text' => 'string',
255 'time_period' => 'string',
256 'top10' => 'Top10',
257 'link' => 'Link'
258 } );
259
260 __PACKAGE__->attribute_map( {
261 'priority' => 'Priority',
262 'type' => 'Type',
263 'stop_if_true' => 'StopIfTrue',
264 'above_average' => 'AboveAverage',
265 'color_scale' => 'ColorScale',
266 'data_bar' => 'DataBar',
267 'formula1' => 'Formula1',
268 'formula2' => 'Formula2',
269 'icon_set' => 'IconSet',
270 'operator' => 'Operator',
271 'style' => 'Style',
272 'text' => 'Text',
273 'time_period' => 'TimePeriod',
274 'top10' => 'Top10',
275 'link' => 'link'
276 } );
277
278 __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
279
280
281 1;