SimpleSerialization implements Serialization { public static boolean isStringCollection(Collection<?> obj) { if (obj.isEmpty()) { return false; } for (Object v : obj) { if (v == null) { continue; } if (!(v instanceof String)) { return false; } } return true; }  static boolean isStringCollection(Collection<?> obj); static boolean isStringMap(Map<?, ?> obj); @Override byte[] serialize(Object obj); @Override T deserialize(byte[] bytes, Class<T> clz); @Override byte[] serializeMulti(Object[] data); @Override Object[] deserializeMulti(byte[] data, Class<?>[] classes); @Override int getSerializationNumber();  }
@Test public void testArray() throws Exception { assertTrue(SimpleSerialization.isStringCollection(Arrays.asList("1", "2", "3"))); assertFalse(SimpleSerialization.isStringCollection(Arrays.asList("1", 1, "3"))); assertTrue(SimpleSerialization.isStringCollection(Sets.newHashSet("1", "2", "3"))); assertFalse(SimpleSerialization.isStringCollection(Sets.newHashSet("1", 1, "3"))); List<String> sList = new ArrayList<>(); for (int i = 0; i < 10; i++) { sList.add("testString" + i); } String[] sArray = new String[sList.size()]; sArray = sList.toArray(sArray); verify(sList); verify(new HashSet<>(sList)); verify(sArray); }