LinearId implements Id { @Override public LinearId extend(String tail) { int n = getCount(); if (n <= 0) { return new LinearId(new String[]{tail}, aggregator_, null); } String[] ids = Arrays.copyOf(data_, n + 1); ids[n] = tail; return new LinearId(ids, aggregator_, null); } LinearId();  LinearId(String id);  LinearId(String parent, String tail);  LinearId(String... id);  LinearId(String[] ids, IdAggregator aggregator); private  LinearId(String[] ids, IdAggregator aggregator, Void private_constructor); @NonNull static LinearId of(@NonNull Id id); @Override String get(int index); @Override LinearId extend(String tail); @Override LinearId parent(); @Override int getCount(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); @Override String[] toArray();  }
@Test public void testExtend() { assertThat(empty.extend("other")).isEqualTo(new LinearId("other")); assertThat(single.extend("other")).isEqualTo(new LinearId("single", "other")); assertThat(dual.extend("other")).isEqualTo(new LinearId("hello", "world", "other")); }