ContentRange implements Serializable { static ContentRange parse(String headerValue) { if (headerValue != null) { Matcher matcher = HEADER_PATTERN.matcher(headerValue); if (matcher.find()) { int offset = -1; int last = -1; int total = -1; String head = matcher.group(1); if (!"*".equals(head)) { offset = Integer.parseInt(matcher.group(2)); last = Integer.parseInt(matcher.group(3)); } String tail = matcher.group(4); if (!"*".equals(tail)) total = Integer.parseInt(tail); return new ContentRange(offset, last, total); } } return null; } ContentRange(int offset, int last, int total); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); int offset(); int last(); int total(); boolean isEmpty();  }
@Test public void nulls() throws Exception { assertThat(ContentRange.parse(null)).isNull(); assertThat(ContentRange.parse("awefss")).isNull(); assertThat(ContentRange.parse("items 1/")).isNull(); assertThat(ContentRange.parse("items 1/2")).isNull(); assertThat(ContentRange.parse("items1-3/2")).isNull(); assertThat(ContentRange.parse("items232dsf")).isNull(); }