1111import com .fasterxml .jackson .core .JsonParseException ;
1212import com .fasterxml .jackson .core .JsonParser ;
1313import com .fasterxml .jackson .core .JsonToken ;
14- import com .google .common .primitives .ImmutableDoubleArray ;
15- import com .google .common .primitives .ImmutableIntArray ;
16- import com .google .common .primitives .ImmutableLongArray ;
17- import org .epics .util .array .CollectionNumbers ;
1814import org .epics .util .array .ListDouble ;
1915import org .epics .util .array .ListInteger ;
2016import org .epics .util .array .ListLong ;
4339import java .math .BigInteger ;
4440import java .text .NumberFormat ;
4541import java .time .Instant ;
42+ import java .util .ArrayList ;
43+ import java .util .Collections ;
4644import java .util .LinkedList ;
4745import java .util .List ;
4846import java .util .Locale ;
@@ -103,12 +101,12 @@ public static VType readValue(
103101 parser .getTokenLocation ());
104102 }
105103 Display display = null ;
106- ImmutableDoubleArray double_value = null ;
104+ List < Double > double_value = null ;
107105 EnumDisplay enum_display = null ;
108- ImmutableIntArray enum_value = null ;
106+ List < Integer > enum_value = null ;
109107 String field_name = null ;
110108 boolean found_value = false ;
111- ImmutableLongArray long_value = null ;
109+ List < Long > long_value = null ;
112110 Double maximum = null ;
113111 Double minimum = null ;
114112 String quality = null ;
@@ -280,13 +278,12 @@ public static VType readValue(
280278 if (display == null ) {
281279 display = Display .none ();
282280 }
283- if (double_value .length () == 1 ) {
281+ if (double_value .size () == 1 ) {
284282 return VDouble .of (
285283 double_value .get (0 ), alarm , time , display );
286284 } else {
287285 return VDoubleArray .of (
288- CollectionNumbers .toListDouble (
289- double_value .toArray ()),
286+ toListDouble (double_value ),
290287 alarm ,
291288 time ,
292289 display );
@@ -296,7 +293,7 @@ public static VType readValue(
296293 // Ensure that we have labels for all indices.
297294 int min_value = Integer .MAX_VALUE ;
298295 int max_value = Integer .MIN_VALUE ;
299- for (var i = 0 ; i < enum_value .length (); ++i ) {
296+ for (var i = 0 ; i < enum_value .size (); ++i ) {
300297 final var value = enum_value .get (i );
301298 min_value = Math .min (min_value , value );
302299 max_value = Math .max (max_value , value );
@@ -321,7 +318,7 @@ public static VType readValue(
321318 Range .undefined (),
322319 "" ,
323320 NumberFormats .precisionFormat (0 ));
324- if (enum_value .length () == 1 ) {
321+ if (enum_value .size () == 1 ) {
325322 return VInt .of (
326323 enum_value .get (0 ),
327324 alarm ,
@@ -335,7 +332,7 @@ public static VType readValue(
335332 display );
336333 }
337334 }
338- if (enum_value .length () == 1 ) {
335+ if (enum_value .size () == 1 ) {
339336 return VEnum .of (
340337 enum_value .get (0 ), enum_display , alarm , time );
341338 } else {
@@ -366,7 +363,7 @@ display. getAlarmRange(),
366363 NumberFormats .precisionFormat (0 ),
367364 display .getDescription ());
368365 }
369- if (long_value .length () == 1 ) {
366+ if (long_value .size () == 1 ) {
370367 return VLong .of (long_value .get (0 ), alarm , time , display );
371368 } else {
372369 return VLongArray .of (
@@ -386,7 +383,7 @@ display. getAlarmRange(),
386383 "Mandatory field is missing in object." ,
387384 parser .getTokenLocation ());
388385 }
389- if (double_value .length () == 1 ) {
386+ if (double_value .size () == 1 ) {
390387 return VStatistics .of (
391388 double_value .get (0 ),
392389 Double .NaN ,
@@ -459,9 +456,10 @@ private static boolean readBooleanValue(final JsonParser parser)
459456 return parser .getBooleanValue ();
460457 }
461458
462- private static ImmutableDoubleArray readDoubleArray (
459+ private static List < Double > readDoubleArray (
463460 final JsonParser parser ) throws IOException {
464- final var array_builder = ImmutableDoubleArray .builder (1 );
461+
462+ final List <Double > values = new ArrayList <>();
465463 var token = parser .getCurrentToken ();
466464 if (token != JsonToken .START_ARRAY ) {
467465 throw new JsonParseException (
@@ -477,9 +475,9 @@ private static ImmutableDoubleArray readDoubleArray(
477475 if (token == JsonToken .END_ARRAY ) {
478476 break ;
479477 }
480- array_builder .add (readDoubleValue (parser ));
478+ values .add (readDoubleValue (parser ));
481479 }
482- return array_builder . build ( );
480+ return Collections . unmodifiableList ( values );
483481 }
484482
485483 private static double readDoubleValue (final JsonParser parser )
@@ -515,9 +513,9 @@ private static Instant readInstant(final JsonParser parser)
515513 return bigIntegerToTimestamp (parser .getBigIntegerValue ());
516514 }
517515
518- private static ImmutableIntArray readIntArray (final JsonParser parser )
516+ private static List < Integer > readIntArray (final JsonParser parser )
519517 throws IOException {
520- final var array_builder = ImmutableIntArray . builder ( 1 );
518+ final List < Integer > values = new ArrayList <>( );
521519 var token = parser .getCurrentToken ();
522520 if (token != JsonToken .START_ARRAY ) {
523521 throw new JsonParseException (
@@ -533,9 +531,9 @@ private static ImmutableIntArray readIntArray(final JsonParser parser)
533531 if (token == JsonToken .END_ARRAY ) {
534532 break ;
535533 }
536- array_builder .add (readIntValue (parser ));
534+ values .add (readIntValue (parser ));
537535 }
538- return array_builder . build ( );
536+ return Collections . unmodifiableList ( values );
539537 }
540538
541539 private static int readIntValue (final JsonParser parser )
@@ -551,9 +549,9 @@ private static int readIntValue(final JsonParser parser)
551549 return parser .getIntValue ();
552550 }
553551
554- private static ImmutableLongArray readLongArray (final JsonParser parser )
552+ private static List < Long > readLongArray (final JsonParser parser )
555553 throws IOException {
556- final var array_builder = ImmutableLongArray . builder ( 1 );
554+ final List < Long > values = new ArrayList <>( );
557555 var token = parser .getCurrentToken ();
558556 if (token != JsonToken .START_ARRAY ) {
559557 throw new JsonParseException (
@@ -569,9 +567,9 @@ private static ImmutableLongArray readLongArray(final JsonParser parser)
569567 if (token == JsonToken .END_ARRAY ) {
570568 break ;
571569 }
572- array_builder .add (readLongValue (parser ));
570+ values .add (readLongValue (parser ));
573571 }
574- return array_builder . build ( );
572+ return Collections . unmodifiableList ( values );
575573 }
576574
577575 private static long readLongValue (final JsonParser parser )
@@ -888,7 +886,7 @@ private static double stringToSpecialDouble(
888886 };
889887 }
890888
891- private static ListDouble toListDouble (final ImmutableDoubleArray array ) {
889+ private static ListDouble toListDouble (final List < Double > array ) {
892890 return new ListDouble () {
893891 @ Override
894892 public double getDouble (int index ) {
@@ -897,12 +895,12 @@ public double getDouble(int index) {
897895
898896 @ Override
899897 public int size () {
900- return array .length ();
898+ return array .size ();
901899 }
902900 };
903901 }
904902
905- private static ListInteger toListInteger (final ImmutableIntArray array ) {
903+ private static ListInteger toListInteger (final List < Integer > array ) {
906904 return new ListInteger () {
907905 @ Override
908906 public int getInt (int index ) {
@@ -911,12 +909,12 @@ public int getInt(int index) {
911909
912910 @ Override
913911 public int size () {
914- return array .length ();
912+ return array .size ();
915913 }
916914 };
917915 }
918916
919- private static ListLong toListLong (final ImmutableLongArray array ) {
917+ private static ListLong toListLong (final List < Long > array ) {
920918 return new ListLong () {
921919 @ Override
922920 public long getLong (int index ) {
@@ -925,7 +923,7 @@ public long getLong(int index) {
925923
926924 @ Override
927925 public int size () {
928- return array .length ();
926+ return array .size ();
929927 }
930928 };
931929 }
0 commit comments