76b28e93aaad9a7775068b3a37e383cdf9738ac1
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / NormalizedNodeResult.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.data.impl.schema;
9
10 import com.google.common.base.Preconditions;
11 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
12
13 /**
14  * Client allocated result holder for {@link ImmutableNormalizedNodeStreamWriter}.
15  * which produces instance of NormalizedNode.
16  *
17  * Client may supply result holder to {@link ImmutableNormalizedNodeStreamWriter}
18  * which will be once updated, when result is available.
19  *
20  * This is intended for using {@link ImmutableNormalizedNodeStreamWriter}
21  * without supplying builder, so instantiated writer will select
22  * correct builder based on first event and sets resulting
23  *  {@link NormalizedNode} when end event is invoked for node.
24  *
25  */
26 public class NormalizedNodeResult {
27
28     private boolean finished = false;
29     private NormalizedNode<?,?> result;
30
31     public NormalizedNode<?, ?> getResult() {
32         return result;
33     }
34
35     void setResult(final NormalizedNode<?, ?> result) {
36         Preconditions.checkState(!this.finished, "Result was already set.");
37         this.finished = true;
38         this.result = result;
39     }
40
41     public boolean isFinished() {
42         return finished;
43     }
44
45 }