/** * Creates a new property value list containing no elements. * * @return empty property value list */ public static PropertyValueList createEmptyList() { return new PropertyValueList(new byte[0]); }
/** * Creates a Property value list from a collection of property values. * * @param propertyValues property values * * @return property value list containing the given properties */ public static PropertyValueList fromPropertyValues( Collection<PropertyValue> propertyValues) throws IOException { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); DataOutputStream outputStream = new DataOutputStream(byteStream); DataOutputView outputView = new DataOutputViewStreamWrapper(outputStream); for (PropertyValue propertyValue : propertyValues) { propertyValue.write(outputView); } outputStream.flush(); return new PropertyValueList(byteStream.toByteArray()); }
@Test public void testEmptyIterator() throws Exception { PropertyValueList p = new PropertyValueList(); List<PropertyValue> expected = Lists.newArrayList(p); assertEquals(0, expected.size()); } }