*/
package org.opendaylight.yangtools.yang.data.impl.schema;
-import com.google.common.base.Preconditions;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
/**
- * Client allocated result holder for {@link ImmutableNormalizedNodeStreamWriter}.
- * which produces instance of NormalizedNode.
+ * Client allocated result holder for {@link ImmutableNormalizedNodeStreamWriter} which produces instance
+ * of NormalizedNode.
*
- * Client may supply result holder to {@link ImmutableNormalizedNodeStreamWriter}
- * which will be once updated, when result is available.
- *
- * This is intended for using {@link ImmutableNormalizedNodeStreamWriter}
- * without supplying builder, so instantiated writer will select
- * correct builder based on first event and sets resulting
- * {@link NormalizedNode} when end event is invoked for node.
+ * <p>
+ * Client may supply result holder to {@link ImmutableNormalizedNodeStreamWriter} which will be once updated when
+ * the result is available.
*
+ * <p>
+ * This is intended for using {@link ImmutableNormalizedNodeStreamWriter} without supplying builder, so instantiated
+ * writer will select correct builder based on first event and sets resulting {@link NormalizedNode} when end event is
+ * invoked for node.
*/
public class NormalizedNodeResult {
-
private boolean finished = false;
private NormalizedNode<?,?> result;
}
void setResult(final NormalizedNode<?, ?> result) {
- Preconditions.checkState(!this.finished, "Result was already set.");
+ if (finished) {
+ throw new ResultAlreadySetException("Normalized Node result was already set.", this.result);
+ }
this.finished = true;
this.result = result;
}
public boolean isFinished() {
return finished;
}
-
}