DbSetId { @NonNull public Optional<DbSetId> parent() { return isRoot() ? Optional.<DbSetId>absent() : Optional.of(new DbSetId(Arrays.copyOf(dimValues, getLevel() - 1), dimColumns)); } private  DbSetId(@NonNull String[] dimValues, @NonNull String[] dimColumns); @NonNull static DbSetId root(@NonNull String... dimColumns); int getLevel(); @NonNull String getValue(int index); int getMaxLevel(); @NonNull String getColumn(int index); int getDepth(); boolean isSeries(); @NonNull DbSetId child(@NonNull String... dimValues); boolean isRoot(); @NonNull Optional<DbSetId> parent(); @NonNull String[] selectColumns(); @NonNull String[] filterColumns(); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode(); static final IConstraint<DbSetId> SERIES_CONSTRAINT; static final IConstraint<DbSetId> COLLECTION_CONSTRAINT; }
@Test public void testParent() { assertFalse(ID0.parent().isPresent()); assertTrue(ID1.parent().isPresent()); assertEquals(ID0, ID1.parent().get()); assertTrue(ID2.parent().isPresent()); assertEquals(ID1, ID2.parent().get()); }