@@ -170,6 +170,8 @@ public String toString()
170170 */
171171 public final static class LongBytesBound extends DataStorageSpec
172172 {
173+ private final long bytes ;
174+
173175 /**
174176 * Creates a {@code DataStorageSpec.LongBytesBound} of the specified amount.
175177 *
@@ -178,6 +180,7 @@ public final static class LongBytesBound extends DataStorageSpec
178180 public LongBytesBound (String value )
179181 {
180182 super (value , BYTES , Long .MAX_VALUE );
183+ bytes = unit ().toBytes (quantity ());
181184 }
182185
183186 /**
@@ -189,6 +192,7 @@ public LongBytesBound(String value)
189192 public LongBytesBound (long quantity , DataStorageUnit unit )
190193 {
191194 super (quantity , unit , BYTES , Long .MAX_VALUE , quantity + unit .symbol );
195+ bytes = unit ().toBytes (quantity ());
192196 }
193197
194198 /**
@@ -206,7 +210,7 @@ public LongBytesBound(long bytes)
206210 */
207211 public long toBytes ()
208212 {
209- return unit (). toBytes ( quantity ()) ;
213+ return bytes ;
210214 }
211215
212216 /**
@@ -225,6 +229,8 @@ public int toMebibytesInt()
225229 */
226230 public final static class IntBytesBound extends DataStorageSpec
227231 {
232+ private final int bytes ;
233+
228234 /**
229235 * Creates a {@code DataStorageSpec.IntBytesBound} of the specified amount.
230236 *
@@ -233,6 +239,7 @@ public final static class IntBytesBound extends DataStorageSpec
233239 public IntBytesBound (String value )
234240 {
235241 super (value , BYTES , Integer .MAX_VALUE );
242+ bytes = Ints .saturatedCast (unit ().toBytes (quantity ()));
236243 }
237244
238245 /**
@@ -244,6 +251,7 @@ public IntBytesBound(String value)
244251 public IntBytesBound (long quantity , DataStorageUnit unit )
245252 {
246253 super (quantity , unit , BYTES , Integer .MAX_VALUE , quantity + unit .symbol );
254+ bytes = Ints .saturatedCast (unit ().toBytes (quantity ()));
247255 }
248256
249257 /**
@@ -263,7 +271,7 @@ public IntBytesBound(long bytes)
263271 */
264272 public int toBytes ()
265273 {
266- return Ints . saturatedCast ( unit (). toBytes ( quantity ())) ;
274+ return bytes ;
267275 }
268276 }
269277
@@ -274,6 +282,8 @@ public int toBytes()
274282 */
275283 public final static class IntKibibytesBound extends DataStorageSpec
276284 {
285+ private final int bytes ;
286+
277287 /**
278288 * Creates a {@code DataStorageSpec.IntKibibytesBound} of the specified amount.
279289 *
@@ -282,6 +292,7 @@ public final static class IntKibibytesBound extends DataStorageSpec
282292 public IntKibibytesBound (String value )
283293 {
284294 super (value , KIBIBYTES , Integer .MAX_VALUE );
295+ bytes = Ints .saturatedCast (unit ().toBytes (quantity ()));
285296 }
286297
287298 /**
@@ -293,6 +304,7 @@ public IntKibibytesBound(String value)
293304 public IntKibibytesBound (long quantity , DataStorageUnit unit )
294305 {
295306 super (quantity , unit , KIBIBYTES , Integer .MAX_VALUE , quantity + unit .symbol );
307+ bytes = Ints .saturatedCast (unit ().toBytes (quantity ()));
296308 }
297309
298310 /**
@@ -312,7 +324,7 @@ public IntKibibytesBound(long kibibytes)
312324 */
313325 public int toBytes ()
314326 {
315- return Ints . saturatedCast ( unit (). toBytes ( quantity ())) ;
327+ return bytes ;
316328 }
317329
318330 /**
@@ -341,6 +353,8 @@ public long toBytesInLong()
341353 */
342354 public final static class LongMebibytesBound extends DataStorageSpec
343355 {
356+ private final long bytes ;
357+
344358 /**
345359 * Creates a {@code DataStorageSpec.LongMebibytesBound} of the specified amount.
346360 *
@@ -349,6 +363,7 @@ public final static class LongMebibytesBound extends DataStorageSpec
349363 public LongMebibytesBound (String value )
350364 {
351365 super (value , MEBIBYTES , Long .MAX_VALUE );
366+ bytes = unit ().toBytes (quantity ());
352367 }
353368
354369 /**
@@ -360,6 +375,7 @@ public LongMebibytesBound(String value)
360375 public LongMebibytesBound (long quantity , DataStorageUnit unit )
361376 {
362377 super (quantity , unit , MEBIBYTES , Long .MAX_VALUE , quantity + unit .symbol );
378+ bytes = unit ().toBytes (quantity ());
363379 }
364380
365381 /**
@@ -377,7 +393,7 @@ public LongMebibytesBound(long mebibytes)
377393 */
378394 public long toBytes ()
379395 {
380- return unit (). toBytes ( quantity ()) ;
396+ return bytes ;
381397 }
382398
383399 /**
@@ -404,6 +420,7 @@ public long toMebibytes()
404420 */
405421 public final static class IntMebibytesBound extends DataStorageSpec
406422 {
423+ private final int bytes ;
407424 /**
408425 * Creates a {@code DataStorageSpec.IntMebibytesBound} of the specified amount.
409426 *
@@ -412,6 +429,7 @@ public final static class IntMebibytesBound extends DataStorageSpec
412429 public IntMebibytesBound (String value )
413430 {
414431 super (value , MEBIBYTES , Integer .MAX_VALUE );
432+ bytes = Ints .saturatedCast (unit ().toBytes (quantity ()));
415433 }
416434
417435 /**
@@ -423,6 +441,7 @@ public IntMebibytesBound(String value)
423441 public IntMebibytesBound (long quantity , DataStorageUnit unit )
424442 {
425443 super (quantity , unit , MEBIBYTES , Integer .MAX_VALUE , quantity + unit .symbol );
444+ bytes = Ints .saturatedCast (unit ().toBytes (quantity ()));
426445 }
427446
428447 /**
@@ -442,7 +461,7 @@ public IntMebibytesBound(long mebibytes)
442461 */
443462 public int toBytes ()
444463 {
445- return Ints . saturatedCast ( unit (). toBytes ( quantity ())) ;
464+ return bytes ;
446465 }
447466
448467 /**
0 commit comments