diff --git a/sdk/search/azure-search/src/main/java/com/azure/search/Document.java b/sdk/search/azure-search/src/main/java/com/azure/search/Document.java index 73ef7df6ed86c..f66ae7a060751 100644 --- a/sdk/search/azure-search/src/main/java/com/azure/search/Document.java +++ b/sdk/search/azure-search/src/main/java/com/azure/search/Document.java @@ -2,13 +2,13 @@ // Licensed under the MIT License. package com.azure.search; -import java.util.LinkedHashMap; +import java.util.HashMap; /** * Represents a document * A property bag is used for scenarios where the index schema is only known at run-time * If the schema is known, user can convert the properties to a specific object type */ -public class Document extends LinkedHashMap { +public class Document extends HashMap { private static final long serialVersionUID = 1L; } diff --git a/sdk/search/azure-search/src/test/java/com/azure/search/SearchAsyncTests.java b/sdk/search/azure-search/src/test/java/com/azure/search/SearchAsyncTests.java index 09f8690516b91..96d252fe6482f 100644 --- a/sdk/search/azure-search/src/test/java/com/azure/search/SearchAsyncTests.java +++ b/sdk/search/azure-search/src/test/java/com/azure/search/SearchAsyncTests.java @@ -30,7 +30,6 @@ import java.util.Collections; import java.util.Date; import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -122,12 +121,12 @@ public void canSearchWithSelectedFields() throws IOException { HashMap expectedHotel2 = new HashMap<>(); expectedHotel2.put("HotelName", "Secret Point Motel"); expectedHotel2.put("Rating", 4); - HashMap address = new LinkedHashMap<>(); + HashMap address = new HashMap<>(); address.put("City", "New York"); expectedHotel2.put("Address", address); - HashMap rooms = new LinkedHashMap<>(); + HashMap rooms = new HashMap<>(); rooms.put("Type", "Budget Room"); - HashMap rooms2 = new LinkedHashMap<>(); + HashMap rooms2 = new HashMap<>(); rooms2.put("Type", "Budget Room"); expectedHotel2.put("Rooms", Arrays.asList(rooms, rooms2)); diff --git a/sdk/search/azure-search/src/test/java/com/azure/search/SearchSyncTests.java b/sdk/search/azure-search/src/test/java/com/azure/search/SearchSyncTests.java index fc5bda95d2d90..2e16fbdc5f52f 100644 --- a/sdk/search/azure-search/src/test/java/com/azure/search/SearchSyncTests.java +++ b/sdk/search/azure-search/src/test/java/com/azure/search/SearchSyncTests.java @@ -30,7 +30,6 @@ import java.util.Date; import java.util.HashMap; import java.util.Iterator; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -271,12 +270,12 @@ public void canSearchWithSelectedFields() throws IOException { HashMap expectedHotel2 = new HashMap<>(); expectedHotel2.put("HotelName", "Secret Point Motel"); expectedHotel2.put("Rating", 4); - HashMap address = new LinkedHashMap<>(); + HashMap address = new HashMap<>(); address.put("City", "New York"); expectedHotel2.put("Address", address); - HashMap rooms = new LinkedHashMap<>(); + HashMap rooms = new HashMap<>(); rooms.put("Type", "Budget Room"); - HashMap rooms2 = new LinkedHashMap<>(); + HashMap rooms2 = new HashMap<>(); rooms2.put("Type", "Budget Room"); expectedHotel2.put("Rooms", Arrays.asList(rooms, rooms2)); @@ -700,33 +699,34 @@ private List> getSearchResults(PagedIterableBase extractAndTransformSingleResult(SearchResult result) { - return dropUnnecessaryFields(convertLinkedHashMapToMap( + return dropUnnecessaryFields(convertHashMapToMap( (result.getDocument()))); } /** - * Convert a Linked HashMap object to Map object + * Convert a HashMap object to Map object * - * @param linkedMapObject object to convert + * @param mapObject object to convert * @return {@link Map}{@code <}{@link String}{@code ,}{@link Object}{@code >} */ - private static Map convertLinkedHashMapToMap(Object linkedMapObject) { + private static Map convertHashMapToMap(Object mapObject) { /** This SuppressWarnings is for the checkstyle it is used because api return type can be anything and therefore is an Object - in our case we know and we use it only when the return type is LinkedHashMap + in our case we know and we use it only when the return type is LinkedHashMap. + The object is converted into HashMap (which LinkedHashMap extends) **/ @SuppressWarnings(value = "unchecked") - LinkedHashMap linkedMap = (LinkedHashMap) linkedMapObject; + HashMap map = (HashMap) mapObject; - Set> entries = linkedMap.entrySet(); + Set> entries = map.entrySet(); Map convertedMap = new HashMap<>(); for (Map.Entry entry : entries) { Object value = entry.getValue(); - if (value instanceof LinkedHashMap) { - value = convertLinkedHashMapToMap(entry.getValue()); + if (value instanceof HashMap) { + value = convertHashMapToMap(entry.getValue()); } if (value instanceof ArrayList) { value = convertArray((ArrayList) value); @@ -748,8 +748,8 @@ private static Map convertLinkedHashMapToMap(Object linkedMapObj private static ArrayList convertArray(ArrayList array) { ArrayList convertedArray = new ArrayList<>(); for (Object arrayValue : array) { - if (arrayValue instanceof LinkedHashMap) { - convertedArray.add(convertLinkedHashMapToMap(arrayValue)); + if (arrayValue instanceof HashMap) { + convertedArray.add(convertHashMapToMap(arrayValue)); } else { convertedArray.add(arrayValue); }