private void assertSetConsistence(Collection<V> values, String type, boolean requireDefinitions, boolean prohibitRaw, ConsistencyCheckScope scope) { if (values == null) { return; } // This may be not be 100% correct but we can tolerate it now // if (values.isEmpty()) { // throw new // IllegalStateException("The "+type+" values set in "+this+" is not-null but it is empty"); // } for (V val : values) { if (scope.isThorough()) { if (val == null) { throw new IllegalStateException("Null value in the " + type + " values set in " + this); } if (val.getParent() != this) { throw new IllegalStateException("Wrong parent for " + val + " in " + type + " values set in " + this + ": " + val.getParent()); } } val.checkConsistenceInternal(this, requireDefinitions, prohibitRaw, scope); } }
public void checkConsistenceInternal(Itemable rootItem, boolean requireDefinitions, boolean prohibitRaw, ConsistencyCheckScope scope) { ItemPath path = getPath(); if (elementName == null) { throw new IllegalStateException("Item "+this+" has no name ("+path+" in "+rootItem+")"); } if (definition != null) { checkDefinition(definition); } else if (requireDefinitions && !isRaw()) { throw new IllegalStateException("No definition in item "+this+" ("+path+" in "+rootItem+")"); } for (V val: values) { if (prohibitRaw && val.isRaw()) { throw new IllegalStateException("Raw value "+val+" in item "+this+" ("+path+" in "+rootItem+")"); } if (val == null) { throw new IllegalStateException("Null value in item "+this+" ("+path+" in "+rootItem+")"); } if (val.getParent() == null) { throw new IllegalStateException("Null parent for value "+val+" in item "+this+" ("+path+" in "+rootItem+")"); } if (val.getParent() != this) { throw new IllegalStateException("Wrong parent for value "+val+" in item "+this+" ("+path+" in "+rootItem+"), "+ "bad parent: " + val.getParent()); } val.checkConsistenceInternal(rootItem, requireDefinitions, prohibitRaw, scope); } }