TrackMe { public synchronized TrackMe trySet(@NonNull QueryParams key, int value) { return trySet(key, String.valueOf(value)); } TrackMe();  TrackMe(TrackMe trackMe); TrackMe putAll(@NonNull TrackMe trackMe); synchronized TrackMe set(@NonNull String key, String value); @Nullable synchronized String get(@NonNull String queryParams); synchronized TrackMe set(@NonNull QueryParams key, String value); synchronized TrackMe set(@NonNull QueryParams key, int value); synchronized TrackMe set(@NonNull QueryParams key, float value); synchronized TrackMe set(@NonNull QueryParams key, long value); synchronized boolean has(@NonNull QueryParams queryParams); synchronized TrackMe trySet(@NonNull QueryParams key, int value); synchronized TrackMe trySet(@NonNull QueryParams key, float value); synchronized TrackMe trySet(@NonNull QueryParams key, long value); synchronized TrackMe trySet(@NonNull QueryParams key, String value); synchronized Map<String, String> toMap(); synchronized String get(@NonNull QueryParams queryParams); synchronized boolean isEmpty();  }
@Test public void testTrySet() throws Exception { TrackMe trackMe = new TrackMe(); trackMe.trySet(QueryParams.HOURS, "A"); trackMe.trySet(QueryParams.HOURS, "B"); assertEquals("A", trackMe.get(QueryParams.HOURS)); trackMe = new TrackMe(); trackMe.trySet(QueryParams.HOURS, 1f); trackMe.trySet(QueryParams.HOURS, 2f); assertEquals(String.valueOf(1f), trackMe.get(QueryParams.HOURS)); trackMe = new TrackMe(); trackMe.trySet(QueryParams.HOURS, 1L); trackMe.trySet(QueryParams.HOURS, 2L); assertEquals(String.valueOf(1L), trackMe.get(QueryParams.HOURS)); trackMe = new TrackMe(); trackMe.trySet(QueryParams.HOURS, 1); trackMe.trySet(QueryParams.HOURS, 2); assertEquals(String.valueOf(1), trackMe.get(QueryParams.HOURS)); trackMe = new TrackMe(); trackMe.trySet(QueryParams.HOURS, "A"); trackMe.trySet(QueryParams.HOURS, null); assertNotNull(trackMe.get(QueryParams.HOURS)); }