void (int nameId) { int single = singularMapping.get(nameId); int[] multi = multiMapping.get(nameId); if (single != NULL_NAME_ID && multi != null) { throw new AssertionError("both single- and multi- entries present"); } else if (multi == null) { // nothing } else if (multi.length == 2) { if (multi[0] == 0 || multi[1] == 0) { throw new AssertionError("zero non-free entry"); } if (multi[0] == multi[1]) { throw new AssertionError("duplicate multi entries"); } } else if (multi.length == 0 || multi[0] <= 0 || multi[0] + 1 > multi.length) { throw new AssertionError("incorrect multi entries number"); } else { IntArraySet set = new IntArraySet(); for (int i = 1, len = multi[0]; i < multi.length; i++) { if (i <= len) { if (multi[i] == 0) { throw new AssertionError("zero non-free entry"); } if (!set.add(multi[i])) { throw new AssertionError("duplicate entries"); } } else if (multi[i] != 0) { throw new AssertionError("non-zero free entry"); } } } }