[ONOS-3880, 3881] Change to static import for lesser indentation.
Change-Id: I93a39f9b0ccd019ace5900bf8ba68f7d60f228a0
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BaseFileListener.java b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BaseFileListener.java
index f53a767..368f2af 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BaseFileListener.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BaseFileListener.java
@@ -19,14 +19,17 @@
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangSubModule;
-import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
+
+import static org.onosproject.yangutils.parser.ParsableDataType.YANGBASE_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsEmpty;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
@@ -49,9 +52,8 @@
}
/**
- * It is called when parser receives an input matching the grammar
- * rule (yangfile), perform validations and update the data model
- * tree.
+ * It is called when parser receives an input matching the grammar rule
+ * (yangfile), perform validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
@@ -59,8 +61,7 @@
public static void processYangFileEntry(TreeWalkListener listener, GeneratedYangParser.YangfileContext ctx) {
// Check if stack is empty.
- ListenerValidation.checkStackIsEmpty(listener, ListenerErrorType.INVALID_HOLDER,
- ParsableDataType.YANGBASE_DATA, "", ListenerErrorLocation.ENTRY);
+ checkStackIsEmpty(listener, INVALID_HOLDER, YANGBASE_DATA, "", ENTRY);
}
@@ -74,23 +75,17 @@
public static void processYangFileExit(TreeWalkListener listener, GeneratedYangParser.YangfileContext ctx) {
// Check for stack to be non empty.
- ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
- ParsableDataType.YANGBASE_DATA, "", ListenerErrorLocation.EXIT);
+ checkStackIsNotEmpty(listener, MISSING_HOLDER, YANGBASE_DATA, "", EXIT);
// Data Model tree root node is set.
if (listener.getParsedDataStack().peek() instanceof YangModule
- | listener.getParsedDataStack().peek() instanceof YangSubModule) {
+ || listener.getParsedDataStack().peek() instanceof YangSubModule) {
listener.setRootNode((YangNode) listener.getParsedDataStack().pop());
} else {
- throw new ParserException(
- ListenerErrorMessageConstruction
- .constructListenerErrorMessage(ListenerErrorType.INVALID_CHILD,
- ParsableDataType.YANGBASE_DATA, "",
- ListenerErrorLocation.EXIT));
+ throw new ParserException(constructListenerErrorMessage(INVALID_CHILD, YANGBASE_DATA, "", EXIT));
}
// Check if stack is empty.
- ListenerValidation.checkStackIsEmpty(listener, ListenerErrorType.INVALID_HOLDER,
- ParsableDataType.YANGBASE_DATA, "", ListenerErrorLocation.EXIT);
+ checkStackIsEmpty(listener, INVALID_HOLDER, YANGBASE_DATA, "", EXIT);
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BelongsToListener.java b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BelongsToListener.java
index c8266dc..aec6562 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BelongsToListener.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BelongsToListener.java
@@ -19,14 +19,16 @@
import org.onosproject.yangutils.datamodel.YangBelongsTo;
import org.onosproject.yangutils.datamodel.YangSubModule;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
+
+import static org.onosproject.yangutils.parser.ParsableDataType.BELONGS_TO_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
@@ -52,8 +54,9 @@
*/
/**
- * Implements listener based call back function corresponding to the "belongs to"
- * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020.
+ * Implements listener based call back function corresponding to the
+ * "belongs to" rule defined in ANTLR grammar file for corresponding ABNF rule
+ * in RFC 6020.
*/
public final class BelongsToListener {
@@ -64,9 +67,8 @@
}
/**
- * It is called when parser receives an input matching the grammar
- * rule (belongsto), perform validations and update the data model
- * tree.
+ * It is called when parser receives an input matching the grammar rule
+ * (belongsto), perform validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
@@ -75,10 +77,8 @@
GeneratedYangParser.BelongstoStatementContext ctx) {
// Check for stack to be non empty.
- ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
- ParsableDataType.BELONGS_TO_DATA,
- String.valueOf(ctx.IDENTIFIER().getText()),
- ListenerErrorLocation.ENTRY);
+ checkStackIsNotEmpty(listener, MISSING_HOLDER, BELONGS_TO_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
+ ENTRY);
YangBelongsTo belongstoNode = new YangBelongsTo();
belongstoNode.setBelongsToModuleName(String.valueOf(ctx.IDENTIFIER().getText()));
@@ -98,20 +98,16 @@
GeneratedYangParser.BelongstoStatementContext ctx) {
// Check for stack to be non empty.
- ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
- ParsableDataType.BELONGS_TO_DATA,
- String.valueOf(ctx.IDENTIFIER().getText()),
- ListenerErrorLocation.EXIT);
+ checkStackIsNotEmpty(listener, MISSING_HOLDER, BELONGS_TO_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
+ EXIT);
Parsable tmpBelongstoNode = listener.getParsedDataStack().peek();
if (tmpBelongstoNode instanceof YangBelongsTo) {
listener.getParsedDataStack().pop();
// Check for stack to be empty.
- ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
- ParsableDataType.BELONGS_TO_DATA,
- String.valueOf(ctx.IDENTIFIER().getText()),
- ListenerErrorLocation.EXIT);
+ checkStackIsNotEmpty(listener, MISSING_HOLDER, BELONGS_TO_DATA,
+ String.valueOf(ctx.IDENTIFIER().getText()), EXIT);
Parsable tmpNode = listener.getParsedDataStack().peek();
switch (tmpNode.getParsableDataType()) {
@@ -121,22 +117,13 @@
break;
}
default:
- throw new ParserException(
- ListenerErrorMessageConstruction
- .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
- ParsableDataType.BELONGS_TO_DATA,
- String.valueOf(ctx.IDENTIFIER()
- .getText()),
- ListenerErrorLocation.EXIT));
+ throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, BELONGS_TO_DATA,
+ String.valueOf(ctx.IDENTIFIER().getText()),
+ EXIT));
}
} else {
- throw new ParserException(
- ListenerErrorMessageConstruction
- .constructListenerErrorMessage(ListenerErrorType.MISSING_CURRENT_HOLDER,
- ParsableDataType.BELONGS_TO_DATA,
- String.valueOf(ctx.IDENTIFIER()
- .getText()),
- ListenerErrorLocation.EXIT));
+ throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, BELONGS_TO_DATA,
+ String.valueOf(ctx.IDENTIFIER().getText()), EXIT));
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ContactListener.java b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ContactListener.java
index 48174b5..aed2b5e 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ContactListener.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ContactListener.java
@@ -19,14 +19,16 @@
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangSubModule;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
+
+import static org.onosproject.yangutils.parser.ParsableDataType.CONTACT_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
@@ -81,9 +83,8 @@
}
/**
- * It is called when parser receives an input matching the grammar
- * rule (contact), perform validations and update the data model
- * tree.
+ * It is called when parser receives an input matching the grammar rule
+ * (contact), perform validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
@@ -91,9 +92,7 @@
public static void processContactEntry(TreeWalkListener listener, GeneratedYangParser.ContactStatementContext ctx) {
// Check for stack to be non empty.
- ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
- ParsableDataType.CONTACT_DATA,
- String.valueOf(ctx.string().getText()), ListenerErrorLocation.ENTRY);
+ checkStackIsNotEmpty(listener, MISSING_HOLDER, CONTACT_DATA, String.valueOf(ctx.string().getText()), ENTRY);
// Obtain the node of the stack.
Parsable tmpNode = listener.getParsedDataStack().peek();
@@ -109,12 +108,8 @@
break;
}
default:
- throw new ParserException(
- ListenerErrorMessageConstruction
- .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
- ParsableDataType.CONTACT_DATA,
- String.valueOf(ctx.string().getText()),
- ListenerErrorLocation.ENTRY));
+ throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, CONTACT_DATA,
+ String.valueOf(ctx.string().getText()), ENTRY));
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ImportListener.java b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ImportListener.java
index 4740699..e47f466 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ImportListener.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ImportListener.java
@@ -20,14 +20,16 @@
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangSubModule;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
+
+import static org.onosproject.yangutils.parser.ParsableDataType.IMPORT_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
@@ -64,9 +66,8 @@
}
/**
- * It is called when parser receives an input matching the grammar
- * rule (import), perform validations and update the data model
- * tree.
+ * It is called when parser receives an input matching the grammar rule
+ * (import), perform validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
@@ -74,10 +75,7 @@
public static void processImportEntry(TreeWalkListener listener, GeneratedYangParser.ImportStatementContext ctx) {
// Check for stack to be non empty.
- ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
- ParsableDataType.IMPORT_DATA,
- String.valueOf(ctx.IDENTIFIER().getText()),
- ListenerErrorLocation.ENTRY);
+ checkStackIsNotEmpty(listener, MISSING_HOLDER, IMPORT_DATA, String.valueOf(ctx.IDENTIFIER().getText()), ENTRY);
YangImport importNode = new YangImport();
importNode.setModuleName(String.valueOf(ctx.IDENTIFIER().getText()));
@@ -96,20 +94,15 @@
public static void processImportExit(TreeWalkListener listener, GeneratedYangParser.ImportStatementContext ctx) {
// Check for stack to be non empty.
- ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
- ParsableDataType.IMPORT_DATA,
- String.valueOf(ctx.IDENTIFIER().getText()),
- ListenerErrorLocation.EXIT);
+ checkStackIsNotEmpty(listener, MISSING_HOLDER, IMPORT_DATA, String.valueOf(ctx.IDENTIFIER().getText()), EXIT);
Parsable tmpImportNode = listener.getParsedDataStack().peek();
if (tmpImportNode instanceof YangImport) {
listener.getParsedDataStack().pop();
// Check for stack to be non empty.
- ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
- ParsableDataType.IMPORT_DATA,
- String.valueOf(ctx.IDENTIFIER().getText()),
- ListenerErrorLocation.EXIT);
+ checkStackIsNotEmpty(listener, MISSING_HOLDER, IMPORT_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
+ EXIT);
Parsable tmpNode = listener.getParsedDataStack().peek();
switch (tmpNode.getParsableDataType()) {
@@ -124,22 +117,13 @@
break;
}
default:
- throw new ParserException(
- ListenerErrorMessageConstruction
- .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
- ParsableDataType.IMPORT_DATA,
- String.valueOf(ctx.IDENTIFIER()
- .getText()),
- ListenerErrorLocation.EXIT));
+ throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, IMPORT_DATA,
+ String.valueOf(ctx.IDENTIFIER().getText()),
+ EXIT));
}
} else {
- throw new ParserException(
- ListenerErrorMessageConstruction
- .constructListenerErrorMessage(ListenerErrorType.MISSING_CURRENT_HOLDER,
- ParsableDataType.IMPORT_DATA, String
- .valueOf(ctx.IDENTIFIER()
- .getText()),
- ListenerErrorLocation.EXIT));
+ throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, IMPORT_DATA,
+ String.valueOf(ctx.IDENTIFIER().getText()), EXIT));
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/IncludeListener.java b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/IncludeListener.java
index c4678b8..024d811 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/IncludeListener.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/IncludeListener.java
@@ -20,14 +20,16 @@
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangSubModule;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
+
+import static org.onosproject.yangutils.parser.ParsableDataType.INCLUDE_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
@@ -63,9 +65,8 @@
}
/**
- * It is called when parser receives an input matching the grammar
- * rule (include), perform validations and update the data model
- * tree.
+ * It is called when parser receives an input matching the grammar rule
+ * (include), perform validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
@@ -73,10 +74,8 @@
public static void processIncludeEntry(TreeWalkListener listener, GeneratedYangParser.IncludeStatementContext ctx) {
// Check for stack to be non empty.
- ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
- ParsableDataType.INCLUDE_DATA,
- String.valueOf(ctx.IDENTIFIER().getText()),
- ListenerErrorLocation.ENTRY);
+ checkStackIsNotEmpty(listener, MISSING_HOLDER, INCLUDE_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
+ ENTRY);
YangInclude includeNode = new YangInclude();
includeNode.setSubModuleName(String.valueOf(ctx.IDENTIFIER().getText()));
@@ -94,20 +93,15 @@
public static void processIncludeExit(TreeWalkListener listener, GeneratedYangParser.IncludeStatementContext ctx) {
// Check for stack to be non empty.
- ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
- ParsableDataType.INCLUDE_DATA,
- String.valueOf(ctx.IDENTIFIER().getText()),
- ListenerErrorLocation.EXIT);
+ checkStackIsNotEmpty(listener, MISSING_HOLDER, INCLUDE_DATA, String.valueOf(ctx.IDENTIFIER().getText()), EXIT);
Parsable tmpIncludeNode = listener.getParsedDataStack().peek();
if (tmpIncludeNode instanceof YangInclude) {
listener.getParsedDataStack().pop();
// Check for stack to be non empty.
- ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
- ParsableDataType.INCLUDE_DATA,
- String.valueOf(ctx.IDENTIFIER().getText()),
- ListenerErrorLocation.EXIT);
+ checkStackIsNotEmpty(listener, MISSING_HOLDER, INCLUDE_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
+ EXIT);
Parsable tmpNode = listener.getParsedDataStack().peek();
switch (tmpNode.getParsableDataType()) {
@@ -122,22 +116,13 @@
break;
}
default:
- throw new ParserException(
- ListenerErrorMessageConstruction
- .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
- ParsableDataType.INCLUDE_DATA,
- String.valueOf(ctx.IDENTIFIER()
- .getText()),
- ListenerErrorLocation.EXIT));
+ throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, INCLUDE_DATA,
+ String.valueOf(ctx.IDENTIFIER().getText()),
+ EXIT));
}
} else {
- throw new ParserException(
- ListenerErrorMessageConstruction
- .constructListenerErrorMessage(ListenerErrorType.MISSING_CURRENT_HOLDER,
- ParsableDataType.INCLUDE_DATA, String
- .valueOf(ctx.IDENTIFIER()
- .getText()),
- ListenerErrorLocation.EXIT));
+ throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, INCLUDE_DATA,
+ String.valueOf(ctx.IDENTIFIER().getText()), EXIT));
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java
index cf6309a..2bc8d00 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java
@@ -17,14 +17,17 @@
package org.onosproject.yangutils.parser.impl.listeners;
import org.onosproject.yangutils.datamodel.YangModule;
-import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
+
+import static org.onosproject.yangutils.parser.ParsableDataType.MODULE_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsEmpty;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
@@ -57,9 +60,8 @@
}
/**
- * It is called when parser receives an input matching the grammar
- * rule (module), perform validations and update the data model
- * tree.
+ * It is called when parser receives an input matching the grammar rule
+ * (module), perform validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
@@ -67,9 +69,7 @@
public static void processModuleEntry(TreeWalkListener listener, GeneratedYangParser.ModuleStatementContext ctx) {
// Check if stack is empty.
- ListenerValidation
- .checkStackIsEmpty(listener, ListenerErrorType.INVALID_HOLDER, ParsableDataType.MODULE_DATA,
- String.valueOf(ctx.IDENTIFIER().getText()), ListenerErrorLocation.ENTRY);
+ checkStackIsEmpty(listener, INVALID_HOLDER, MODULE_DATA, String.valueOf(ctx.IDENTIFIER().getText()), ENTRY);
YangModule yangModule = new YangModule();
yangModule.setName(ctx.IDENTIFIER().getText());
@@ -87,19 +87,11 @@
public static void processModuleExit(TreeWalkListener listener, GeneratedYangParser.ModuleStatementContext ctx) {
// Check for stack to be non empty.
- ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
- ParsableDataType.MODULE_DATA,
- String.valueOf(ctx.IDENTIFIER().getText()),
- ListenerErrorLocation.EXIT);
+ checkStackIsNotEmpty(listener, MISSING_HOLDER, MODULE_DATA, String.valueOf(ctx.IDENTIFIER().getText()), EXIT);
if (!(listener.getParsedDataStack().peek() instanceof YangModule)) {
- throw new ParserException(
- ListenerErrorMessageConstruction
- .constructListenerErrorMessage(ListenerErrorType.MISSING_CURRENT_HOLDER,
- ParsableDataType.MODULE_DATA, String
- .valueOf(ctx.IDENTIFIER()
- .getText()),
- ListenerErrorLocation.EXIT));
+ throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, MODULE_DATA,
+ String.valueOf(ctx.IDENTIFIER().getText()), EXIT));
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/NamespaceListener.java b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/NamespaceListener.java
index 8386788..db53363 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/NamespaceListener.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/NamespaceListener.java
@@ -19,17 +19,19 @@
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangNameSpace;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
import java.net.URI;
+import static org.onosproject.yangutils.parser.ParsableDataType.NAMESPACE_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
+
/*
* Reference: RFC6020 and YANG ANTLR Grammar
*
@@ -65,9 +67,8 @@
}
/**
- * It is called when parser receives an input matching the grammar
- * rule (namespace), perform validations and update the data model
- * tree.
+ * It is called when parser receives an input matching the grammar rule
+ * (namespace), perform validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
@@ -76,9 +77,7 @@
GeneratedYangParser.NamespaceStatementContext ctx) {
// Check for stack to be non empty.
- ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
- ParsableDataType.NAMESPACE_DATA,
- String.valueOf(ctx.string().getText()), ListenerErrorLocation.ENTRY);
+ checkStackIsNotEmpty(listener, MISSING_HOLDER, NAMESPACE_DATA, String.valueOf(ctx.string().getText()), ENTRY);
if (!validateUriValue(String.valueOf(ctx.string().getText()))) {
ParserException parserException = new ParserException("Invalid namespace URI");
@@ -98,12 +97,8 @@
break;
}
default:
- throw new ParserException(
- ListenerErrorMessageConstruction
- .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
- ParsableDataType.NAMESPACE_DATA,
- String.valueOf(ctx.string().getText()),
- ListenerErrorLocation.ENTRY));
+ throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, NAMESPACE_DATA,
+ String.valueOf(ctx.string().getText()), ENTRY));
}
}
@@ -123,4 +118,4 @@
}
return true;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/OrganizationListener.java b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/OrganizationListener.java
index edae08e..7260c1c 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/OrganizationListener.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/OrganizationListener.java
@@ -19,14 +19,16 @@
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangSubModule;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
+
+import static org.onosproject.yangutils.parser.ParsableDataType.ORGANIZATION_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
@@ -70,8 +72,9 @@
*/
/**
- * Implements listener based call back function corresponding to the "organization"
- * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020.
+ * Implements listener based call back function corresponding to the
+ * "organization" rule defined in ANTLR grammar file for corresponding ABNF rule
+ * in RFC 6020.
*/
public final class OrganizationListener {
@@ -82,9 +85,8 @@
}
/**
- * It is called when parser receives an input matching the grammar
- * rule (organization), perform validations and update the data model
- * tree.
+ * It is called when parser receives an input matching the grammar rule
+ * (organization), perform validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
@@ -93,9 +95,8 @@
GeneratedYangParser.OrganizationStatementContext ctx) {
// Check for stack to be non empty.
- ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
- ParsableDataType.ORGANIZATION_DATA,
- String.valueOf(ctx.string().getText()), ListenerErrorLocation.ENTRY);
+ checkStackIsNotEmpty(listener, MISSING_HOLDER, ORGANIZATION_DATA, String.valueOf(ctx.string().getText()),
+ ENTRY);
// Obtain the node of the stack.
Parsable tmpNode = listener.getParsedDataStack().peek();
@@ -111,12 +112,8 @@
break;
}
default:
- throw new ParserException(
- ListenerErrorMessageConstruction
- .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
- ParsableDataType.ORGANIZATION_DATA,
- String.valueOf(ctx.string().getText()),
- ListenerErrorLocation.ENTRY));
+ throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, ORGANIZATION_DATA,
+ String.valueOf(ctx.string().getText()), ENTRY));
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/PrefixListener.java b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/PrefixListener.java
index 26bc82c..774af7c 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/PrefixListener.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/PrefixListener.java
@@ -20,14 +20,16 @@
import org.onosproject.yangutils.datamodel.YangImport;
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
+
+import static org.onosproject.yangutils.parser.ParsableDataType.PREFIX_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
@@ -65,9 +67,8 @@
}
/**
- * It is called when parser receives an input matching the grammar
- * rule (prefix),perform validations and update the data model
- * tree.
+ * It is called when parser receives an input matching the grammar rule
+ * (prefix),perform validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
@@ -75,10 +76,7 @@
public static void processPrefixEntry(TreeWalkListener listener, GeneratedYangParser.PrefixStatementContext ctx) {
// Check for stack to be non empty.
- ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
- ParsableDataType.PREFIX_DATA,
- String.valueOf(ctx.IDENTIFIER().getText()),
- ListenerErrorLocation.ENTRY);
+ checkStackIsNotEmpty(listener, MISSING_HOLDER, PREFIX_DATA, String.valueOf(ctx.IDENTIFIER().getText()), ENTRY);
// Obtain the node of the stack.
Parsable tmpNode = listener.getParsedDataStack().peek();
@@ -99,13 +97,8 @@
break;
}
default:
- throw new ParserException(
- ListenerErrorMessageConstruction
- .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
- ParsableDataType.PREFIX_DATA, String
- .valueOf(ctx.IDENTIFIER()
- .getText()),
- ListenerErrorLocation.ENTRY));
+ throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, PREFIX_DATA,
+ String.valueOf(ctx.IDENTIFIER().getText()), ENTRY));
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RevisionDateListener.java b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RevisionDateListener.java
index 3f60aef..8cd6d67 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RevisionDateListener.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RevisionDateListener.java
@@ -19,14 +19,16 @@
import org.onosproject.yangutils.datamodel.YangImport;
import org.onosproject.yangutils.datamodel.YangInclude;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
+
+import static org.onosproject.yangutils.parser.ParsableDataType.REVISION_DATE_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
@@ -57,8 +59,9 @@
*/
/**
- * Implements listener based call back function corresponding to the "revision date"
- * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020.
+ * Implements listener based call back function corresponding to the
+ * "revision date" rule defined in ANTLR grammar file for corresponding ABNF
+ * rule in RFC 6020.
*/
public final class RevisionDateListener {
@@ -69,9 +72,8 @@
}
/**
- * It is called when parser receives an input matching the grammar
- * rule (revision date),perform validations and update the data model
- * tree.
+ * It is called when parser receives an input matching the grammar rule
+ * (revision date),perform validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
@@ -80,10 +82,8 @@
GeneratedYangParser.RevisionDateStatementContext ctx) {
// Check for stack to be non empty.
- ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
- ParsableDataType.REVISION_DATE_DATA,
- String.valueOf(ctx.DATE_ARG().getText()),
- ListenerErrorLocation.ENTRY);
+ checkStackIsNotEmpty(listener, MISSING_HOLDER, REVISION_DATE_DATA, String.valueOf(ctx.DATE_ARG().getText()),
+ ENTRY);
// Obtain the node of the stack.
Parsable tmpNode = listener.getParsedDataStack().peek();
@@ -99,13 +99,9 @@
break;
}
default:
- throw new ParserException(
- ListenerErrorMessageConstruction
- .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
- ParsableDataType.REVISION_DATE_DATA,
- String.valueOf(ctx.DATE_ARG().getText()),
- ListenerErrorLocation.ENTRY));
+ throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, REVISION_DATE_DATA,
+ String.valueOf(ctx.DATE_ARG().getText()), ENTRY));
}
}
// TODO Implement the DATE_ARG validation as per RFC 6020.
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListener.java b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListener.java
index 0da2f01..7904656 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListener.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListener.java
@@ -20,14 +20,16 @@
import org.onosproject.yangutils.datamodel.YangRevision;
import org.onosproject.yangutils.datamodel.YangSubModule;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
+
+import static org.onosproject.yangutils.parser.ParsableDataType.REVISION_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
@@ -69,16 +71,21 @@
private RevisionListener() {
}
+ /**
+ * It is called when parser receives an input matching the grammar rule
+ * (revision),perform validations and update the data model tree.
+ *
+ * @param listener Listener's object.
+ * @param ctx context object of the grammar rule.
+ */
public static void processRevisionEntry(TreeWalkListener listener,
GeneratedYangParser.RevisionStatementContext ctx) {
// Check for stack to be non empty.
- ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
- ParsableDataType.REVISION_DATA,
- String.valueOf(ctx.DATE_ARG().getText()),
- ListenerErrorLocation.ENTRY);
+ checkStackIsNotEmpty(listener, MISSING_HOLDER, REVISION_DATA, String.valueOf(ctx.DATE_ARG().getText()), ENTRY);
- // Validate for reverse chronological order of revision & for revision value.
+ // Validate for reverse chronological order of revision & for revision
+ // value.
if (!validateRevision(listener, ctx)) {
return;
// TODO to be implemented.
@@ -97,23 +104,19 @@
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
*/
- public static void processRevisionExit(TreeWalkListener listener,
- GeneratedYangParser.RevisionStatementContext ctx) {
+ public static void processRevisionExit(TreeWalkListener listener, GeneratedYangParser.RevisionStatementContext
+ ctx) {
// Check for stack to be non empty.
- ListenerValidation
- .checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, ParsableDataType.REVISION_DATA,
- String.valueOf(ctx.DATE_ARG().getText()), ListenerErrorLocation.EXIT);
+ checkStackIsNotEmpty(listener, MISSING_HOLDER, REVISION_DATA, String.valueOf(ctx.DATE_ARG().getText()), EXIT);
Parsable tmpRevisionNode = listener.getParsedDataStack().peek();
if (tmpRevisionNode instanceof YangRevision) {
listener.getParsedDataStack().pop();
// Check for stack to be non empty.
- ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
- ParsableDataType.REVISION_DATA,
- String.valueOf(ctx.DATE_ARG().getText()),
- ListenerErrorLocation.EXIT);
+ checkStackIsNotEmpty(listener, MISSING_HOLDER, REVISION_DATA, String.valueOf(ctx.DATE_ARG().getText()),
+ EXIT);
Parsable tmpNode = listener.getParsedDataStack().peek();
switch (tmpNode.getParsableDataType()) {
@@ -128,22 +131,13 @@
break;
}
default:
- throw new ParserException(
- ListenerErrorMessageConstruction
- .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
- ParsableDataType.REVISION_DATA,
- String.valueOf(ctx.DATE_ARG()
- .getText()),
- ListenerErrorLocation.EXIT));
+ throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, REVISION_DATA,
+ String.valueOf(ctx.DATE_ARG().getText()),
+ EXIT));
}
} else {
- throw new ParserException(
- ListenerErrorMessageConstruction
- .constructListenerErrorMessage(ListenerErrorType.MISSING_CURRENT_HOLDER,
- ParsableDataType.REVISION_DATA, String
- .valueOf(ctx.DATE_ARG()
- .getText()),
- ListenerErrorLocation.EXIT));
+ throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, REVISION_DATA,
+ String.valueOf(ctx.DATE_ARG().getText()), EXIT));
}
}
@@ -159,4 +153,4 @@
// TODO to be implemented
return true;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListener.java b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListener.java
index 3f6fc40..42c753c 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListener.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListener.java
@@ -17,14 +17,17 @@
package org.onosproject.yangutils.parser.impl.listeners;
import org.onosproject.yangutils.datamodel.YangSubModule;
-import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
+
+import static org.onosproject.yangutils.parser.ParsableDataType.SUB_MODULE_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsEmpty;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
@@ -58,9 +61,8 @@
}
/**
- * It is called when parser receives an input matching the grammar
- * rule (sub module), perform validations and update the data model
- * tree.
+ * It is called when parser receives an input matching the grammar rule (sub
+ * module), perform validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
@@ -69,9 +71,8 @@
GeneratedYangParser.SubModuleStatementContext ctx) {
// Check if stack is empty.
- ListenerValidation
- .checkStackIsEmpty(listener, ListenerErrorType.INVALID_HOLDER, ParsableDataType.SUB_MODULE_DATA,
- String.valueOf(ctx.IDENTIFIER().getText()), ListenerErrorLocation.ENTRY);
+ checkStackIsEmpty(listener, INVALID_HOLDER, SUB_MODULE_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
+ ENTRY);
YangSubModule yangSubModule = new YangSubModule();
yangSubModule.setName(ctx.IDENTIFIER().getText());
@@ -90,19 +91,12 @@
GeneratedYangParser.SubModuleStatementContext ctx) {
// Check for stack to be non empty.
- ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
- ParsableDataType.SUB_MODULE_DATA,
- String.valueOf(ctx.IDENTIFIER().getText()),
- ListenerErrorLocation.EXIT);
+ checkStackIsNotEmpty(listener, MISSING_HOLDER, SUB_MODULE_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
+ EXIT);
if (!(listener.getParsedDataStack().peek() instanceof YangSubModule)) {
- throw new ParserException(
- ListenerErrorMessageConstruction
- .constructListenerErrorMessage(ListenerErrorType.MISSING_CURRENT_HOLDER,
- ParsableDataType.SUB_MODULE_DATA,
- String.valueOf(ctx.IDENTIFIER()
- .getText()),
- ListenerErrorLocation.EXIT));
+ throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, SUB_MODULE_DATA,
+ String.valueOf(ctx.IDENTIFIER().getText()), EXIT));
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/VersionListener.java b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/VersionListener.java
index ae9389f..f9d904d 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/VersionListener.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/VersionListener.java
@@ -19,14 +19,16 @@
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangSubModule;
import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
+
+import static org.onosproject.yangutils.parser.ParsableDataType.VERSION_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
@@ -73,9 +75,8 @@
}
/**
- * It is called when parser receives an input matching the grammar
- * rule (version), perform validations and update the data model
- * tree.
+ * It is called when parser receives an input matching the grammar rule
+ * (version), perform validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
@@ -84,9 +85,7 @@
GeneratedYangParser.YangVersionStatementContext ctx) {
// Check for stack to be non empty.
- ListenerValidation
- .checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER, ParsableDataType.VERSION_DATA,
- String.valueOf(ctx.INTEGER().getText()), ListenerErrorLocation.ENTRY);
+ checkStackIsNotEmpty(listener, MISSING_HOLDER, VERSION_DATA, String.valueOf(ctx.INTEGER().getText()), ENTRY);
Integer version = Integer.valueOf(ctx.INTEGER().getText());
if (!isVersionValid(version)) {
@@ -110,10 +109,8 @@
break;
}
default:
- throw new ParserException(ListenerErrorMessageConstruction.
- constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
- ParsableDataType.VERSION_DATA, String.valueOf(ctx.INTEGER().getText()),
- ListenerErrorLocation.ENTRY));
+ throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, VERSION_DATA,
+ String.valueOf(ctx.INTEGER().getText()), ENTRY));
}
}
@@ -126,4 +123,4 @@
private static boolean isVersionValid(Integer version) {
return version == 1;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerErrorMessageConstruction.java b/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerErrorMessageConstruction.java
index 1de8f44..1ef25e3 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerErrorMessageConstruction.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerErrorMessageConstruction.java
@@ -18,6 +18,10 @@
import org.onosproject.yangutils.parser.ParsableDataType;
+import static org.onosproject.yangutils.parser.ParsableDataType.getParsableDataType;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.getErrorLocationMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.getErrorType;
+
/**
* It's a utility to help construct detailed error message.
*/
@@ -30,13 +34,15 @@
}
/**
- * Constructs message for error with extended information and returns the same.
+ * Constructs message for error with extended information and returns the
+ * same.
*
- * @param errorType error type needs to be set in error message.
- * @param parsableDataType type of parsable data in which error occurred.
- * @param parsableDataTypeName identifier/string of parsable data type in which error occurred.
- * @param errorLocation location where error occurred.
- * @param extendedErrorInformation extended error information.
+ * @param errorType error type needs to be set in error message.
+ * @param parsableDataType type of parsable data in which error occurred.
+ * @param parsableDataTypeName identifier/string of parsable data type in
+ * which error occurred.
+ * @param errorLocation location where error occurred.
+ * @param extendedErrorInformation extended error information.
* @return constructed error message.
*/
public static String constructExtendedListenerErrorMessage(ListenerErrorType errorType,
@@ -46,16 +52,21 @@
String extendedErrorInformation) {
String newErrorMessage;
newErrorMessage = constructListenerErrorMessage(errorType, parsableDataType, parsableDataTypeName,
- errorLocation) + "\n" + "Error Information: " + extendedErrorInformation;
+ errorLocation)
+ + "\n"
+ + "Error Information: "
+ + extendedErrorInformation;
return newErrorMessage;
}
/**
- * Constructs message for error during listener based tree walk and returns the same.
+ * Constructs message for error during listener based tree walk and returns
+ * the same.
*
* @param errorType error type needs to be set in error message.
* @param parsableDataType type of parsable data in which error occurred.
- * @param parsableDataTypeName identifier/string of parsable data type in which error occurred.
+ * @param parsableDataTypeName identifier/string of parsable data type in
+ * which error occurred.
* @param errorLocation location where error occurred.
* @return constructed error message.
*/
@@ -66,9 +77,8 @@
String errorMessage;
- errorMessage = "Internal parser error detected: " + ListenerErrorType.getErrorType(errorType) + " "
- + ParsableDataType.getParsableDataType(parsableDataType);
-
+ errorMessage = "Internal parser error detected: " + getErrorType(errorType) + " "
+ + getParsableDataType(parsableDataType);
if (!parsableDataTypeName.isEmpty()) {
errorMessage = errorMessage + " \"" + parsableDataTypeName + "\" ";
@@ -76,7 +86,7 @@
errorMessage = errorMessage + " ";
}
- errorMessage = errorMessage + ListenerErrorLocation.getErrorLocationMessage(errorLocation) + " processing.";
+ errorMessage = errorMessage + getErrorLocationMessage(errorLocation) + " processing.";
return errorMessage;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerValidation.java b/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerValidation.java
index 4399cc5..226a530 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerValidation.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerValidation.java
@@ -19,6 +19,7 @@
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
/**
* It's a utility to carry out listener validation.
@@ -37,19 +38,21 @@
* @param listener Listener's object.
* @param errorType error type needs to be set in error message.
* @param parsableDataType type of parsable data in which error occurred.
- * @param parsableDataTypeName name of parsable data type in which error occurred.
+ * @param parsableDataTypeName name of parsable data type in which error
+ * occurred.
* @param errorLocation location where error occurred.
*/
public static void checkStackIsNotEmpty(TreeWalkListener listener, ListenerErrorType errorType,
- ParsableDataType parsableDataType, String parsableDataTypeName,
- ListenerErrorLocation errorLocation) {
+ ParsableDataType parsableDataType, String parsableDataTypeName,
+ ListenerErrorLocation errorLocation) {
if (listener.getParsedDataStack().empty()) {
/*
- * If stack is empty it indicates error condition, value of parsableDataTypeName will be null in case there
- * is no name attached to parsable data type.
+ * If stack is empty it indicates error condition, value of
+ * parsableDataTypeName will be null in case there is no name
+ * attached to parsable data type.
*/
- String message = ListenerErrorMessageConstruction.constructListenerErrorMessage(errorType, parsableDataType,
- parsableDataTypeName, errorLocation);
+ String message = constructListenerErrorMessage(errorType, parsableDataType, parsableDataTypeName,
+ errorLocation);
throw new ParserException(message);
}
}
@@ -60,22 +63,24 @@
* @param listener Listener's object.
* @param errorType error type needs to be set in error message.
* @param parsableDataType type of parsable data in which error occurred.
- * @param parsableDataTypeName name of parsable data type in which error occurred.
+ * @param parsableDataTypeName name of parsable data type in which error
+ * occurred.
* @param errorLocation location where error occurred.
*/
public static void checkStackIsEmpty(TreeWalkListener listener, ListenerErrorType errorType,
- ParsableDataType parsableDataType, String parsableDataTypeName,
- ListenerErrorLocation errorLocation) {
+ ParsableDataType parsableDataType, String parsableDataTypeName,
+ ListenerErrorLocation errorLocation) {
if (!listener.getParsedDataStack().empty()) {
/*
- * If stack is empty it indicates error condition, value of parsableDataTypeName will be null in case there
- * is no name attached to parsable data type.
+ * If stack is empty it indicates error condition, value of
+ * parsableDataTypeName will be null in case there is no name
+ * attached to parsable data type.
*/
- String message = ListenerErrorMessageConstruction.constructListenerErrorMessage(errorType, parsableDataType,
- parsableDataTypeName, errorLocation);
+ String message = constructListenerErrorMessage(errorType, parsableDataType, parsableDataTypeName,
+ errorLocation);
throw new ParserException(message);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/onosproject/yangutils/parser/parseutils/ListenerErrorMessageConstructionTest.java b/src/test/java/org/onosproject/yangutils/parser/parseutils/ListenerErrorMessageConstructionTest.java
index 7cbc7f6..0c1473e 100644
--- a/src/test/java/org/onosproject/yangutils/parser/parseutils/ListenerErrorMessageConstructionTest.java
+++ b/src/test/java/org/onosproject/yangutils/parser/parseutils/ListenerErrorMessageConstructionTest.java
@@ -17,13 +17,14 @@
package org.onosproject.yangutils.parser.parseutils;
import org.junit.Test;
-import org.onosproject.yangutils.parser.ParsableDataType;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
+import static org.onosproject.yangutils.parser.ParsableDataType.CONTACT_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
/**
* Test case for testing listener error message construction util.
@@ -37,9 +38,7 @@
public void checkErrorMsgConstructionWithName() {
// Create an test error message
- String testErrorMessage = ListenerErrorMessageConstruction
- .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, ParsableDataType.CONTACT_DATA,
- "Test Instance", ListenerErrorLocation.ENTRY);
+ String testErrorMessage = constructListenerErrorMessage(INVALID_HOLDER, CONTACT_DATA, "Test Instance", ENTRY);
// Check message.
assertThat(testErrorMessage, is("Internal parser error detected: Invalid holder for contact "
@@ -53,9 +52,7 @@
public void checkErrorMsgConstructionWithoutName() {
// Create an test error message
- String testErrorMessage = ListenerErrorMessageConstruction
- .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, ParsableDataType.CONTACT_DATA,
- "Test Instance", ListenerErrorLocation.ENTRY);
+ String testErrorMessage = constructListenerErrorMessage(INVALID_HOLDER, CONTACT_DATA, "Test Instance", ENTRY);
// Check message.
assertThat(testErrorMessage,
@@ -64,16 +61,16 @@
}
/**
- * Checks for extended error message construction with parsable data type name.
+ * Checks for extended error message construction with parsable data type
+ * name.
*/
@Test
public void checkExtendedErrorMsgConstructionWithName() {
// Create an test error message
- String testErrorMessage = ListenerErrorMessageConstruction
- .constructExtendedListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
- ParsableDataType.CONTACT_DATA, "Test Instance",
- ListenerErrorLocation.ENTRY, "Extended Information");
+ String testErrorMessage = constructExtendedListenerErrorMessage(INVALID_HOLDER, CONTACT_DATA,
+ "Test Instance", ENTRY,
+ "Extended Information");
// Check message.
assertThat(testErrorMessage,
@@ -82,19 +79,18 @@
}
/**
- * Checks for extended error message construction without parsable data type name.
+ * Checks for extended error message construction without parsable data type
+ * name.
*/
@Test
public void checkExtendedErrorMsgConstructionWithoutName() {
// Create an test error message
- String testErrorMessage = ListenerErrorMessageConstruction
- .constructExtendedListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
- ParsableDataType.CONTACT_DATA, "",
- ListenerErrorLocation.ENTRY, "Extended Information");
+ String testErrorMessage = constructExtendedListenerErrorMessage(INVALID_HOLDER, CONTACT_DATA, "", ENTRY,
+ "Extended Information");
// Check message.
assertThat(testErrorMessage, is("Internal parser error detected: Invalid holder for contact"
+ " before processing.\n" + "Error Information: Extended Information"));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/onosproject/yangutils/parser/parseutils/ListenerValidationTest.java b/src/test/java/org/onosproject/yangutils/parser/parseutils/ListenerValidationTest.java
index 85eb48d..d39b0ae 100644
--- a/src/test/java/org/onosproject/yangutils/parser/parseutils/ListenerValidationTest.java
+++ b/src/test/java/org/onosproject/yangutils/parser/parseutils/ListenerValidationTest.java
@@ -20,13 +20,15 @@
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onosproject.yangutils.datamodel.YangRevision;
-import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
+
+import static org.onosproject.yangutils.parser.ParsableDataType.YANGBASE_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsEmpty;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
/**
* Test case for testing listener validation util.
@@ -43,9 +45,7 @@
@Test
public void validateStackIsNotEmptyForEmptyStack() {
- String expectedError = ListenerErrorMessageConstruction
- .constructListenerErrorMessage(ListenerErrorType.MISSING_HOLDER, ParsableDataType.YANGBASE_DATA, "",
- ListenerErrorLocation.EXIT);
+ String expectedError = constructListenerErrorMessage(MISSING_HOLDER, YANGBASE_DATA, "", EXIT);
// Get the exception occurred during parsing.
thrown.expect(ParserException.class);
@@ -54,13 +54,12 @@
// Create test walker and assign test error to it.
TreeWalkListener testWalker = new TreeWalkListener();
- ListenerValidation.checkStackIsNotEmpty(testWalker, ListenerErrorType.MISSING_HOLDER,
- ParsableDataType.YANGBASE_DATA, "", ListenerErrorLocation.EXIT);
+ checkStackIsNotEmpty(testWalker, MISSING_HOLDER, YANGBASE_DATA, "", EXIT);
}
/**
- * Checks if there is no exception in case parsable stack is not empty while validating
- * for not empty scenario.
+ * Checks if there is no exception in case parsable stack is not empty while
+ * validating for not empty scenario.
*/
@Test
public void validateStackIsNotEmptyForNonEmptyStack() {
@@ -72,8 +71,7 @@
YangRevision tmpNode = new YangRevision();
testWalker.getParsedDataStack().push(tmpNode);
- ListenerValidation.checkStackIsNotEmpty(testWalker, ListenerErrorType.MISSING_HOLDER,
- ParsableDataType.YANGBASE_DATA, "", ListenerErrorLocation.EXIT);
+ checkStackIsNotEmpty(testWalker, MISSING_HOLDER, YANGBASE_DATA, "", EXIT);
}
/**
@@ -83,9 +81,7 @@
@Test
public void validateStackIsEmptyForNonEmptyStack() {
- String expectedError = ListenerErrorMessageConstruction
- .constructListenerErrorMessage(ListenerErrorType.MISSING_HOLDER, ParsableDataType.YANGBASE_DATA, "",
- ListenerErrorLocation.EXIT);
+ String expectedError = constructListenerErrorMessage(MISSING_HOLDER, YANGBASE_DATA, "", EXIT);
// Get the exception occurred during parsing.
thrown.expect(ParserException.class);
@@ -98,13 +94,12 @@
YangRevision tmpNode = new YangRevision();
testWalker.getParsedDataStack().push(tmpNode);
- ListenerValidation.checkStackIsEmpty(testWalker, ListenerErrorType.MISSING_HOLDER,
- ParsableDataType.YANGBASE_DATA, "", ListenerErrorLocation.EXIT);
+ checkStackIsEmpty(testWalker, MISSING_HOLDER, YANGBASE_DATA, "", EXIT);
}
/**
- * Checks if there is no exception in case parsable stack is empty while validating
- * for empty scenario.
+ * Checks if there is no exception in case parsable stack is empty while
+ * validating for empty scenario.
*/
@Test
public void validateStackIsEmptyForEmptyStack() {
@@ -112,7 +107,6 @@
// Create test walker and assign test error to it.
TreeWalkListener testWalker = new TreeWalkListener();
- ListenerValidation.checkStackIsEmpty(testWalker, ListenerErrorType.MISSING_HOLDER,
- ParsableDataType.YANGBASE_DATA, "", ListenerErrorLocation.EXIT);
+ checkStackIsEmpty(testWalker, MISSING_HOLDER, YANGBASE_DATA, "", EXIT);
}
-}
\ No newline at end of file
+}