當前位置: 首頁>>代碼示例>>Java>>正文


Java LinkedTreeMap.put方法代碼示例

本文整理匯總了Java中com.google.gson.internal.LinkedTreeMap.put方法的典型用法代碼示例。如果您正苦於以下問題:Java LinkedTreeMap.put方法的具體用法?Java LinkedTreeMap.put怎麽用?Java LinkedTreeMap.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.gson.internal.LinkedTreeMap的用法示例。


在下文中一共展示了LinkedTreeMap.put方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadHospitals

import com.google.gson.internal.LinkedTreeMap; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public static void loadHospitals() {
  String filename = "geography/healthcare_facilities.json";

  try {
    String json = Utilities.readResource(filename);
    Gson g = new Gson();
    HashMap<String, LinkedTreeMap> gson = g.fromJson(json, HashMap.class);
    for (Entry<String, LinkedTreeMap> entry : gson.entrySet()) {
      LinkedTreeMap value = entry.getValue();
      String resourceID = UUID.randomUUID().toString();
      value.put("resourceID", resourceID);
      Hospital h = new Hospital(value);
      hospitalList.add(h);
    }
  } catch (Exception e) {
    System.err.println("ERROR: unable to load json: " + filename);
    e.printStackTrace();
    throw new ExceptionInInitializerError(e);
  }
}
 
開發者ID:synthetichealth,項目名稱:synthea_java,代碼行數:22,代碼來源:Hospital.java

示例2: deserializesMapsDueToTypeErasure

import com.google.gson.internal.LinkedTreeMap; //導入方法依賴的package包/類
@Test
@SuppressWarnings("unchecked")
public void deserializesMapsDueToTypeErasure() {
    List<TextAnnotation> initialValue = Collections.singletonList(anno("n", "t"));
    Class<List<TextAnnotation>> valueType = (Class<List<TextAnnotation>>) 
                                            initialValue.getClass();
    List<TextAnnotation> readValue = writeThenRead(initialValue, valueType);
    
    assertThat(readValue, is(not(initialValue)));
    
    LinkedTreeMap<String, LinkedTreeMap<String, String>> deserialized =
            new LinkedTreeMap<>();
    LinkedTreeMap<String, String> deserializedAnno =
            new LinkedTreeMap<>();
    deserializedAnno.put("fst", "n");
    deserializedAnno.put("snd", "t");
    deserialized.put("wrappedValue", deserializedAnno);
    
    assertThat(readValue, is(Collections.singletonList(deserialized)));  // (*)
}
 
開發者ID:openmicroscopy,項目名稱:omero-ms-queue,代碼行數:21,代碼來源:TextAnnotationListTest.java

示例3: deserializesMapsDueToTypeErasure

import com.google.gson.internal.LinkedTreeMap; //導入方法依賴的package包/類
@Test
@SuppressWarnings("unchecked")
public void deserializesMapsDueToTypeErasure() {
    List<PositiveN> initialValue = Collections.singletonList(posN(1));
    Class<List<PositiveN>> valueType = (Class<List<PositiveN>>) 
                                            initialValue.getClass();
    List<PositiveN> readValue = writeThenRead(initialValue, valueType);
    
    assertThat(readValue, is(not(initialValue)));
    
    LinkedTreeMap<String, Double> deserialized =
            new LinkedTreeMap<>();
    deserialized.put("wrappedValue", 1.0);
    
    assertThat(readValue, is(Collections.singletonList(deserialized)));  // (*)
}
 
開發者ID:openmicroscopy,項目名稱:omero-ms-queue,代碼行數:17,代碼來源:PositiveNListTest.java

示例4: convertListTest

import com.google.gson.internal.LinkedTreeMap; //導入方法依賴的package包/類
@Test
public void convertListTest(){

    listConverter.setListClass(Attachment.class);
    
    Class type = List.class;
    List value = new ArrayList();
    
    LinkedTreeMap ltm = new LinkedTreeMap();
    ltm.put("id","id0001");
    ltm.put("url","http://test.com");
    ltm.put("filename","filename.txt");
    ltm.put("size","10");
    ltm.put("type","image/jpeg");
    
    Map<String,Thumbnail> thumbnails = new HashedMap<>();
    Thumbnail tmb = new Thumbnail();
    
    tmb.setName("Thumbnail");
    tmb.setUrl("http:example.com");
    tmb.setWidth(Float.valueOf(10));
    tmb.setHeight(Float.valueOf(10));
    
    thumbnails.put("small", tmb);
            
    ltm.put("thumbnails",thumbnails);
    
    value.add(0, ltm);
    
    List<Attachment> list = (List<Attachment>) listConverter.convert(type, value);
    assertNotNull(list);
    assertNotNull(list.get(0).getId());
    assertNotNull(list.get(0).getFilename());
    assertNotNull(list.get(0).getSize());
    assertNotNull(list.get(0).getType());
    assertNotNull(list.get(0).getUrl());
    assertNotNull(list.get(0).getThumbnails());        
    
}
 
開發者ID:Sybit-Education,項目名稱:airtable.java,代碼行數:40,代碼來源:CustomObjectMapperTest.java

示例5: deserializesMapDueToTypeErasure

import com.google.gson.internal.LinkedTreeMap; //導入方法依賴的package包/類
@Test
@SuppressWarnings("unchecked")
public void deserializesMapDueToTypeErasure() {
    PositiveN one = positiveInt("1").getRight();
    Optional<PositiveN> initialValue = Optional.of(one);
    Class<Optional<PositiveN>> valueType = (Class<Optional<PositiveN>>) 
                                            initialValue.getClass(); 
    Optional<PositiveN> readValue = writeThenRead(initialValue, valueType);
    
    assertThat(readValue, is(not(initialValue)));
    
    LinkedTreeMap<String, Double> deserialized = new LinkedTreeMap<>();
    deserialized.put("wrappedValue", 1.0);
    assertThat(readValue, is(Optional.of(deserialized)));  // (*)
}
 
開發者ID:openmicroscopy,項目名稱:omero-ms-queue,代碼行數:16,代碼來源:OptionalPositiveNTest.java

示例6: MapToHasSetTest

import com.google.gson.internal.LinkedTreeMap; //導入方法依賴的package包/類
@Test(timeout = 1000)
@Category({UnitTest.class})
public void MapToHasSetTest() {
    Assert.assertTrue(HashMapHelper.mapToHashSet("", null).size() == 0);

    LinkedTreeMap linkedTreeMap = new LinkedTreeMap();
    linkedTreeMap.put("mapLevel3", "string value");
    HashMap table = new HashMap<String, Object>() {
        {
            put("aString", "string value");
            put("aBool", true);
            put("aNumber", 12.3);
            put("map1Level1", new HashMap<String, String>() {{
                put("aString", "string value");
            }});
            put("map2Level1", new HashMap<String, Object>() {{
                put("map2Level2-1", new HashMap<String, Object>() {
                    {
                        put("aString", "string value");
                    }
                });
                put("map2Level2-2", linkedTreeMap);
            }});
        }
    };

    HashSet<String> set = HashMapHelper.mapToHashSet("Tags", table);

    List<String> expectedList = Arrays.asList(
        "Tags.aString",
        "Tags.aBool",
        "Tags.aNumber",
        "Tags.map1Level1.aString",
        "Tags.map2Level1.map2Level2-1.aString",
        "Tags.map2Level1.map2Level2-2.mapLevel3"
    );
    Assert.assertTrue(set.containsAll(expectedList));
    Assert.assertTrue(expectedList.containsAll(set));
}
 
開發者ID:Azure,項目名稱:iothub-manager-java,代碼行數:40,代碼來源:HashMapHelperTest.java

示例7: read

import com.google.gson.internal.LinkedTreeMap; //導入方法依賴的package包/類
public Object read(JsonReader jsonreader)
{
    JsonToken jsontoken = jsonreader.peek();
    switch (h.a[jsontoken.ordinal()])
    {
    default:
        throw new IllegalStateException();

    case 1: // '\001'
        ArrayList arraylist = new ArrayList();
        jsonreader.beginArray();
        for (; jsonreader.hasNext(); arraylist.add(read(jsonreader))) { }
        jsonreader.endArray();
        return arraylist;

    case 2: // '\002'
        LinkedTreeMap linkedtreemap = new LinkedTreeMap();
        jsonreader.beginObject();
        for (; jsonreader.hasNext(); linkedtreemap.put(jsonreader.nextName(), read(jsonreader))) { }
        jsonreader.endObject();
        return linkedtreemap;

    case 3: // '\003'
        return jsonreader.nextString();

    case 4: // '\004'
        return Double.valueOf(jsonreader.nextDouble());

    case 5: // '\005'
        return Boolean.valueOf(jsonreader.nextBoolean());

    case 6: // '\006'
        jsonreader.nextNull();
        return null;
    }
}
 
開發者ID:vishnudevk,項目名稱:MiBandDecompiled,代碼行數:37,代碼來源:ObjectTypeAdapter.java

示例8: getVolume

import com.google.gson.internal.LinkedTreeMap; //導入方法依賴的package包/類
/**
 * Get volume of player
 * @param callback Callback for the request
 * @return ResponseFuture
 */
public Call getVolume(Callback callback) {
    RpcRequest request;
    if(Version.compare(mVersion, ZERO_VERSION)) {
        request = new RpcRequest(VOLUME, RequestId.GET_VOLUME);
    } else {
        RpcResponse response = new RpcResponse();
        LinkedTreeMap<String, Object> map = new LinkedTreeMap<String, Object>();
        map.put(VOLUME, 1);
        response.result = map;
        callback.onCompleted(null, response);
        return null;
    }
    return request(request, callback);
}
 
開發者ID:se-bastiaan,項目名稱:ButterRemote-Android,代碼行數:20,代碼來源:PopcornTimeRpcClient.java

示例9: convertMapTest

import com.google.gson.internal.LinkedTreeMap; //導入方法依賴的package包/類
@Test
public void convertMapTest(){

    mapConverter.setMapClass(Thumbnail.class);
    
    Class type = Map.class;
    
    LinkedTreeMap<String, Object> value = new LinkedTreeMap<>();
    LinkedTreeMap<String, Object> innerMap = new LinkedTreeMap<>();
    
    innerMap.put("url","http://example.com");
    value.put("small",innerMap);    
    
    
    Map<String,Thumbnail> thumb = (Map<String,Thumbnail>) mapConverter.convert(type,value);
    System.out.println(thumb);
    assertNotNull(thumb);
    assertNotNull(thumb.get("small"));
    assertNotNull(thumb.get("small").getUrl());
    
    
    
}
 
開發者ID:Sybit-Education,項目名稱:airtable.java,代碼行數:24,代碼來源:CustomObjectMapperTest.java


注:本文中的com.google.gson.internal.LinkedTreeMap.put方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。