Change-Id: I53006edaa2963e50ff8366c76d2e67778499b345
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
Signed-off-by: Robert Varga <rovarga@cisco.com>
package org.opendaylight.yangtools.yang.common;
import static org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil.getRevisionFormat;
package org.opendaylight.yangtools.yang.common;
import static org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil.getRevisionFormat;
+
+import com.google.common.base.Preconditions;
import java.io.Serializable;
import java.net.URI;
import java.net.URISyntaxException;
import java.io.Serializable;
import java.net.URI;
import java.net.URISyntaxException;
* @return Instance of QName
*/
public static QName create(final QNameModule qnameModule, final String localName) {
* @return Instance of QName
*/
public static QName create(final QNameModule qnameModule, final String localName) {
- if (qnameModule == null) {
- throw new NullPointerException("module may not be null");
- }
- return new QName(qnameModule, localName);
+ return new QName(Preconditions.checkNotNull(qnameModule,"module may not be null"), localName);
*/
public interface NormalizedNodeStreamAttributeWriter extends NormalizedNodeStreamWriter {
*/
public interface NormalizedNodeStreamAttributeWriter extends NormalizedNodeStreamWriter {
- void leafNode(YangInstanceIdentifier.NodeIdentifier name, Object value, Map<QName, String> attributes) throws IOException, IllegalArgumentException;
+ void leafNode(YangInstanceIdentifier.NodeIdentifier name, Object value, Map<QName, String> attributes) throws IOException;
- void leafSetEntryNode(Object value, Map<QName, String> attributes) throws IOException, IllegalArgumentException;
+ void leafSetEntryNode(Object value, Map<QName, String> attributes) throws IOException;
- void startContainerNode(YangInstanceIdentifier.NodeIdentifier name, int childSizeHint, Map<QName, String> attributes) throws IOException, IllegalArgumentException;
+ void startContainerNode(YangInstanceIdentifier.NodeIdentifier name, int childSizeHint, Map<QName, String> attributes) throws IOException;
- void startUnkeyedListItem(YangInstanceIdentifier.NodeIdentifier name, int childSizeHint, Map<QName, String> attributes) throws IOException, IllegalStateException;
+ void startUnkeyedListItem(YangInstanceIdentifier.NodeIdentifier name, int childSizeHint, Map<QName, String> attributes) throws IOException;
- void startMapEntryNode(YangInstanceIdentifier.NodeIdentifierWithPredicates identifier, int childSizeHint, Map<QName, String> attributes) throws IOException, IllegalArgumentException;
+ void startMapEntryNode(YangInstanceIdentifier.NodeIdentifierWithPredicates identifier, int childSizeHint, Map<QName, String> attributes) throws IOException;
import java.io.Closeable;
import java.io.Flushable;
import java.io.IOException;
import java.io.Closeable;
import java.io.Flushable;
import java.io.IOException;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
* <code>choice</code> <code>unkeyed list</code> node.
* @throws IOException if an underlying IO error occurs
*/
* <code>choice</code> <code>unkeyed list</code> node.
* @throws IOException if an underlying IO error occurs
*/
- void leafNode(NodeIdentifier name, Object value) throws IOException, IllegalArgumentException;
+ void leafNode(NodeIdentifier name, Object value) throws IOException;
* <code>choice</code> <code>unkeyed list</code> node.
* @throws IOException if an underlying IO error occurs
*/
* <code>choice</code> <code>unkeyed list</code> node.
* @throws IOException if an underlying IO error occurs
*/
- void startLeafSet(NodeIdentifier name, int childSizeHint) throws IOException, IllegalArgumentException;
+ void startLeafSet(NodeIdentifier name, int childSizeHint) throws IOException;
/**
* Emits a leaf set entry node
/**
* Emits a leaf set entry node
* If node was emitted outside <code>leaf set</code> node.
* @throws IOException if an underlying IO error occurs
*/
* If node was emitted outside <code>leaf set</code> node.
* @throws IOException if an underlying IO error occurs
*/
- void leafSetEntryNode(Object value) throws IOException, IllegalArgumentException;
+ void leafSetEntryNode(Object value) throws IOException;
* <code>choice</code> <code>unkeyed list</code> node.
* @throws IOException if an underlying IO error occurs
*/
* <code>choice</code> <code>unkeyed list</code> node.
* @throws IOException if an underlying IO error occurs
*/
- void startContainerNode(NodeIdentifier name, int childSizeHint) throws IOException, IllegalArgumentException;
+ void startContainerNode(NodeIdentifier name, int childSizeHint) throws IOException;
* <code>choice</code> <code>unkeyed list</code> node.
* @throws IOException if an underlying IO error occurs
*/
* <code>choice</code> <code>unkeyed list</code> node.
* @throws IOException if an underlying IO error occurs
*/
- void startUnkeyedList(NodeIdentifier name, int childSizeHint) throws IOException, IllegalArgumentException;
+ void startUnkeyedList(NodeIdentifier name, int childSizeHint) throws IOException;
/**
* Emits start of new unkeyed list item.
/**
* Emits start of new unkeyed list item.
* If node was emitted outside <code>unkeyed list</code> node.
* @throws IOException if an underlying IO error occurs
*/
* If node was emitted outside <code>unkeyed list</code> node.
* @throws IOException if an underlying IO error occurs
*/
- void startUnkeyedListItem(NodeIdentifier name, int childSizeHint) throws IOException, IllegalStateException;
+ void startUnkeyedListItem(NodeIdentifier name, int childSizeHint) throws IOException;
* <code>choice</code> <code>unkeyed list</code> node.
* @throws IOException if an underlying IO error occurs
*/
* <code>choice</code> <code>unkeyed list</code> node.
* @throws IOException if an underlying IO error occurs
*/
- void startMapNode(NodeIdentifier name, int childSizeHint) throws IOException, IllegalArgumentException;
+ void startMapNode(NodeIdentifier name, int childSizeHint) throws IOException;
* If node was emitted outside <code>map entry</code> node.
* @throws IOException if an underlying IO error occurs
*/
* If node was emitted outside <code>map entry</code> node.
* @throws IOException if an underlying IO error occurs
*/
- void startMapEntryNode(NodeIdentifierWithPredicates identifier, int childSizeHint) throws IOException, IllegalArgumentException;
+ void startMapEntryNode(NodeIdentifierWithPredicates identifier, int childSizeHint) throws IOException;
* <code>choice</code> <code>unkeyed list</code> node.
* @throws IOException if an underlying IO error occurs
*/
* <code>choice</code> <code>unkeyed list</code> node.
* @throws IOException if an underlying IO error occurs
*/
- void startOrderedMapNode(NodeIdentifier name, int childSizeHint) throws IOException, IllegalArgumentException;
+ void startOrderedMapNode(NodeIdentifier name, int childSizeHint) throws IOException;
* <code>choice</code> <code>unkeyed list</code> node.
* @throws IOException if an underlying IO error occurs
*/
* <code>choice</code> <code>unkeyed list</code> node.
* @throws IOException if an underlying IO error occurs
*/
- void startChoiceNode(NodeIdentifier name, int childSizeHint) throws IOException, IllegalArgumentException;
+ void startChoiceNode(NodeIdentifier name, int childSizeHint) throws IOException;
/**
* Emits start of augmentation node.
/**
* Emits start of augmentation node.
* If augmentation is invalid in current context.
* @throws IOException if an underlying IO error occurs
*/
* If augmentation is invalid in current context.
* @throws IOException if an underlying IO error occurs
*/
- void startAugmentationNode(AugmentationIdentifier identifier) throws IOException, IllegalArgumentException;
+ void startAugmentationNode(AugmentationIdentifier identifier) throws IOException;
/**
* Emits anyxml node event.
/**
* Emits anyxml node event.
* <code>choice</code> <code>unkeyed list</code> node.
* @throws IOException if an underlying IO error occurs
*/
* <code>choice</code> <code>unkeyed list</code> node.
* @throws IOException if an underlying IO error occurs
*/
- void anyxmlNode(NodeIdentifier name, Object value) throws IOException, IllegalArgumentException;
+ void anyxmlNode(NodeIdentifier name, Object value) throws IOException;
/**
* Emits end event for node.
/**
* Emits end event for node.
* @throws IllegalStateException If there is no start* event to be closed.
* @throws IOException if an underlying IO error occurs
*/
* @throws IllegalStateException If there is no start* event to be closed.
* @throws IOException if an underlying IO error occurs
*/
- void endNode() throws IOException, IllegalStateException;
+ void endNode() throws IOException;
@Override
void close() throws IOException;
@Override
void close() throws IOException;
* @throws IOException when the writer reports it
*/
protected final boolean writeChildren(final Iterable<? extends NormalizedNode<?, ?>> children) throws IOException {
* @throws IOException when the writer reports it
*/
protected final boolean writeChildren(final Iterable<? extends NormalizedNode<?, ?>> children) throws IOException {
- for (NormalizedNode<?, ?> child : children) {
+ for (final NormalizedNode<?, ?> child : children) {
@Override
protected boolean writeMapEntryNode(final MapEntryNode node) throws IOException {
@Override
protected boolean writeMapEntryNode(final MapEntryNode node) throws IOException {
- final NormalizedNodeStreamWriter writer = getWriter();
- if(writer instanceof NormalizedNodeStreamAttributeWriter) {
- ((NormalizedNodeStreamAttributeWriter) writer).startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue()), node.getAttributes());
+ final NormalizedNodeStreamWriter nnWriter = getWriter();
+ if(nnWriter instanceof NormalizedNodeStreamAttributeWriter) {
+ ((NormalizedNodeStreamAttributeWriter) nnWriter).startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue()), node.getAttributes());
- writer.startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue()));
+ nnWriter.startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue()));
}
final Set<QName> qnames = node.getIdentifier().getKeyValues().keySet();
// Write out all the key children
}
final Set<QName> qnames = node.getIdentifier().getKeyValues().keySet();
// Write out all the key children
- for (QName qname : qnames) {
+ for (final QName qname : qnames) {
final Optional<? extends NormalizedNode<?, ?>> child = node.getChild(new NodeIdentifier(qname));
if (child.isPresent()) {
write(child.get());
final Optional<? extends NormalizedNode<?, ?>> child = node.getChild(new NodeIdentifier(qname));
if (child.isPresent()) {
write(child.get());