+ public Collection<StatementContextBase<?, ?, ?>> substatements() {
+ return Collections.unmodifiableCollection(substatements.values());
+ }
+
+ /**
+ * @return collection of effective substatements
+ */
+ @Override
+ public Collection<StatementContextBase<?, ?, ?>> effectiveSubstatements() {
+ return Collections.unmodifiableCollection(effective);
+ }
+
+ public void removeStatementsFromEffectiveSubstatements(final Collection<StatementContextBase<?, ?, ?>> substatements) {
+ effective.removeAll(substatements);
+ }
+
+ public void removeStatementFromEffectiveSubstatements(final StatementDefinition refineSubstatementDef) {
+ Iterator<StatementContextBase<?, ?, ?>> iterator = effective.iterator();
+ while (iterator.hasNext()) {
+ StatementContextBase<?, ?, ?> next = iterator.next();
+ if (next.getPublicDefinition().equals(refineSubstatementDef)) {
+ iterator.remove();
+ }
+ }
+ }
+
+ /**
+ * adds effective statement to collection of substatements
+ *
+ * @throws IllegalStateException
+ * if added in declared phase
+ * @throws NullPointerException
+ * if statement parameter is null
+ *
+ * @param substatement substatement
+ */
+ public void addEffectiveSubstatement(final StatementContextBase<?, ?, ?> substatement) {
+
+ final ModelProcessingPhase inProgressPhase = getRoot().getSourceContext().getInProgressPhase();
+ Preconditions.checkState(inProgressPhase == ModelProcessingPhase.FULL_DECLARATION
+ || inProgressPhase == ModelProcessingPhase.EFFECTIVE_MODEL,
+ "Effective statement cannot be added in declared phase");
+
+ effective.add(Preconditions.checkNotNull(substatement,
+ "StatementContextBase effective substatement cannot be null"));
+ }
+
+ /**
+ * adds declared statement to collection of substatements
+ *
+ * @throws IllegalStateException
+ * if added in effective phase
+ * @throws NullPointerException
+ * if statement parameter is null
+ *
+ * @param substatement substatement
+ */
+ public void addDeclaredSubstatement(final StatementContextBase<?, ?, ?> substatement) {
+
+ final ModelProcessingPhase inProgressPhase = getRoot().getSourceContext().getInProgressPhase();
+ Preconditions.checkState(inProgressPhase != ModelProcessingPhase.EFFECTIVE_MODEL,
+ "Declared statement cannot be added in effective phase");
+
+ declared.add(Preconditions.checkNotNull(substatement,
+ "StatementContextBase declared substatement cannot be null"));