[ONOS-5141] [ONOS-5113] ProcessSubtreeFiltering generation defect fix
Change-Id: Ic245e52acca702fa501052f705e019ac7fe71613
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangAugment.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangAugment.java
index 0f5a8b6..57db582 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangAugment.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangAugment.java
@@ -18,6 +18,7 @@
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
+
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.datamodel.utils.Parsable;
import org.onosproject.yangutils.datamodel.utils.ResolvableStatus;
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangCase.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangCase.java
index 69b39da..a8b6354 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangCase.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangCase.java
@@ -19,6 +19,7 @@
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
+
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.datamodel.utils.Parsable;
import org.onosproject.yangutils.datamodel.utils.YangConstructType;
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java
index eeeeca0..a0316b7 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java
@@ -20,6 +20,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.datamodel.utils.Parsable;
import org.onosproject.yangutils.datamodel.utils.YangConstructType;
@@ -430,18 +431,20 @@
}
@Override
- public YangSchemaNodeContextInfo getChildSchema(YangSchemaNodeIdentifier dataNodeIdentifier) {
- // Returns null as there is no child to leaf.
- return null;
+ public YangSchemaNodeContextInfo getChildSchema(YangSchemaNodeIdentifier dataNodeIdentifier)
+ throws DataModelException {
+ throw new DataModelException("leaf cannot have any child schema nodes");
}
@Override
- public void isValueValid(String value) throws DataModelException {
+ public void isValueValid(String value)
+ throws DataModelException {
getDataType().isValidValue(value);
}
@Override
- public int getMandatoryChildCount() throws DataModelException {
+ public int getMandatoryChildCount()
+ throws DataModelException {
throw new DataModelException("Leaf can't have child.");
}
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java
index 4a7ea54..eedfe7b 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java
@@ -20,6 +20,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.datamodel.utils.Parsable;
import org.onosproject.yangutils.datamodel.utils.YangConstructType;
@@ -448,18 +449,20 @@
}
@Override
- public YangSchemaNodeContextInfo getChildSchema(YangSchemaNodeIdentifier dataNodeIdentifier) {
- // Returns null as there is no child to leaf list.
- return null;
+ public YangSchemaNodeContextInfo getChildSchema(YangSchemaNodeIdentifier dataNodeIdentifier)
+ throws DataModelException {
+ throw new DataModelException("leaf cannot have any child schema nodes");
}
@Override
- public void isValueValid(String value) throws DataModelException {
+ public void isValueValid(String value)
+ throws DataModelException {
getDataType().isValidValue(value);
}
@Override
- public int getMandatoryChildCount() throws DataModelException {
+ public int getMandatoryChildCount()
+ throws DataModelException {
throw new DataModelException("TODO");
}
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangNode.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangNode.java
index ba0fdf4..4dd6d68 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangNode.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangNode.java
@@ -323,7 +323,7 @@
* @param childSchemaMapHolder child schema map holder
*/
private void processAdditionOfSchemaNodeToMap(String name, String namespace, YangSchemaNode yangSchemaNode,
- YangNode childSchemaMapHolder) {
+ YangNode childSchemaMapHolder) {
// Addition of node to schema node map.
// Create YANG schema node identifier with child node name.
YangSchemaNodeIdentifier yangSchemaNodeIdentifier = new YangSchemaNodeIdentifier();
@@ -554,12 +554,19 @@
}
@Override
- public YangSchemaNodeContextInfo getChildSchema(YangSchemaNodeIdentifier dataNodeIdentifier) {
- return ysnContextInfoMap.get(dataNodeIdentifier);
+ public YangSchemaNodeContextInfo getChildSchema(YangSchemaNodeIdentifier dataNodeIdentifier)
+ throws DataModelException {
+ YangSchemaNodeContextInfo childSchemaContext = ysnContextInfoMap.get(dataNodeIdentifier);
+ if (childSchemaContext == null) {
+ throw new DataModelException("Requested " + dataNodeIdentifier.getName() + "is not child in "
+ + getName());
+ }
+ return childSchemaContext;
}
@Override
- public int getMandatoryChildCount() throws DataModelException {
+ public int getMandatoryChildCount()
+ throws DataModelException {
return mandatoryChildCount;
}
@@ -577,7 +584,7 @@
* @throws DataModelException a violation in data model rule
*/
public abstract void addToChildSchemaMap(YangSchemaNodeIdentifier schemaNodeIdentifier,
- YangSchemaNodeContextInfo yangSchemaNodeContextInfo)
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo)
throws DataModelException;
/**
@@ -601,7 +608,7 @@
* @param yangSchemaNode YANG schema node
*/
public abstract void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier,
- YangSchemaNode yangSchemaNode);
+ YangSchemaNode yangSchemaNode);
/**
* Returns default child map.
@@ -666,7 +673,8 @@
}
@Override
- public void isValueValid(String value) throws DataModelException {
+ public void isValueValid(String value)
+ throws DataModelException {
throw new DataModelException("Value validation asked for YANG node.");
}
}
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangSchemaNode.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangSchemaNode.java
index 4b527c0..f8fea06 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangSchemaNode.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangSchemaNode.java
@@ -17,6 +17,7 @@
package org.onosproject.yangutils.datamodel;
import java.util.Map;
+
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
/**
@@ -38,8 +39,10 @@
*
* @param dataNodeIdentifier YANG data node identifier
* @return YANG data node context information
+ * @throws DataModelException data model exception in searching the child
*/
- YangSchemaNodeContextInfo getChildSchema(YangSchemaNodeIdentifier dataNodeIdentifier);
+ YangSchemaNodeContextInfo getChildSchema(YangSchemaNodeIdentifier dataNodeIdentifier)
+ throws DataModelException;
/**
* Validates whether the leaf/leaf-list value is valid as per YANG. It is
@@ -48,7 +51,8 @@
* @param value value of leaf/leaf-list
* @throws DataModelException a violation in data model rule
*/
- void isValueValid(String value) throws DataModelException;
+ void isValueValid(String value)
+ throws DataModelException;
/**
* Returns count of mandatory child nodes, this is used by YMS to identify whether
@@ -57,7 +61,8 @@
* @return count of YANG schema nodes
* @throws DataModelException a violation in data model rule
*/
- int getMandatoryChildCount() throws DataModelException;
+ int getMandatoryChildCount()
+ throws DataModelException;
/**
* Returns map of default child nodes, this is used by YMS to identify whether
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/javadatamodel/HasJavaQualifiedTypeInfo.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/javadatamodel/HasJavaQualifiedTypeInfo.java
new file mode 100644
index 0000000..1eec1e2
--- /dev/null
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/javadatamodel/HasJavaQualifiedTypeInfo.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.yangutils.datamodel.javadatamodel;
+
+/**
+ * Represents the entity which contains the qualified type info of leaf / leaf-list.
+ */
+public interface HasJavaQualifiedTypeInfo {
+ /**
+ * Returns java qualified type info.
+ *
+ * @return java qualified type info
+ */
+ JavaQualifiedTypeInfo getJavaQualifiedTypeInfo();
+}
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/javadatamodel/YangJavaLeaf.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/javadatamodel/YangJavaLeaf.java
index d580091..5d43f14 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/javadatamodel/YangJavaLeaf.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/javadatamodel/YangJavaLeaf.java
@@ -21,7 +21,9 @@
/**
* Represent YANG java leaf.
*/
-public class YangJavaLeaf extends YangLeaf {
+public class YangJavaLeaf
+ extends YangLeaf
+ implements HasJavaQualifiedTypeInfo {
private static final long serialVersionUID = 208201617L;
@@ -32,6 +34,7 @@
*
* @return java qualified type info
*/
+ @Override
public JavaQualifiedTypeInfo getJavaQualifiedTypeInfo() {
return javaQualifiedTypeInfo;
}
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/javadatamodel/YangJavaLeafList.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/javadatamodel/YangJavaLeafList.java
index 01867da..fac2b84 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/javadatamodel/YangJavaLeafList.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/javadatamodel/YangJavaLeafList.java
@@ -21,7 +21,9 @@
/**
* Represents YANG java leaf list.
*/
-public class YangJavaLeafList extends YangLeafList {
+public class YangJavaLeafList
+ extends YangLeafList
+ implements HasJavaQualifiedTypeInfo {
private static final long serialVersionUID = 208201618L;
@@ -32,6 +34,7 @@
*
* @return java qualified type info
*/
+ @Override
public JavaQualifiedTypeInfo getJavaQualifiedTypeInfo() {
return javaQualifiedTypeInfo;
}
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java
index 9547e78..5acbc60 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java
@@ -388,8 +388,7 @@
* @throws DataModelException data model error
*/
public static YangEntityToResolveInfoImpl resolveLeafrefUnderGroupingForLeaf(YangLeaf clonedLeaf,
- YangLeavesHolder leafParentHolder,
- YangUses yangUses)
+ YangLeavesHolder leafParentHolder, YangUses yangUses)
throws
DataModelException {
if (clonedLeaf.getDataType().getDataTypeExtendedInfo() instanceof YangLeafRef) {
diff --git a/plugin/src/main/java/org/onosproject/yangutils/parser/exceptions/ParserException.java b/plugin/src/main/java/org/onosproject/yangutils/parser/exceptions/ParserException.java
index e030f6c..a11bcb8 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/parser/exceptions/ParserException.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/parser/exceptions/ParserException.java
@@ -114,5 +114,4 @@
public void setFileName(String fileName) {
this.fileName = fileName;
}
-
}
diff --git a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/GeneratedTempFileType.java b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/GeneratedTempFileType.java
index fc7d6e5..5451ea3 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/GeneratedTempFileType.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/GeneratedTempFileType.java
@@ -24,137 +24,137 @@
/**
* Attributes definition temporary file.
*/
- public static final int ATTRIBUTES_MASK = 1;
+ public static final int ATTRIBUTES_MASK = 1; //0x1
/**
* Getter methods for interface.
*/
- public static final int GETTER_FOR_INTERFACE_MASK = 2;
+ public static final int GETTER_FOR_INTERFACE_MASK = 2; //0x2
/**
* Getter methods for class.
*/
- public static final int GETTER_FOR_CLASS_MASK = 4;
+ public static final int GETTER_FOR_CLASS_MASK = 4; //0x4
/**
* Setter methods for interface.
*/
- public static final int SETTER_FOR_INTERFACE_MASK = 8;
+ public static final int SETTER_FOR_INTERFACE_MASK = 8; //0x8
/**
* Setter methods for class.
*/
- public static final int SETTER_FOR_CLASS_MASK = 16;
+ public static final int SETTER_FOR_CLASS_MASK = 16; //0x10
/**
* Constructor method of class.
*/
- public static final int CONSTRUCTOR_IMPL_MASK = 32;
+ public static final int CONSTRUCTOR_IMPL_MASK = 32; //0x20
/**
* Hash code implementation of class.
*/
- public static final int HASH_CODE_IMPL_MASK = 64;
+ public static final int HASH_CODE_IMPL_MASK = 64; //0X40
/**
* Equals implementation of class.
*/
- public static final int EQUALS_IMPL_MASK = 128;
+ public static final int EQUALS_IMPL_MASK = 128; //0x80
/**
* To string implementation of class.
*/
- public static final int TO_STRING_IMPL_MASK = 256;
+ public static final int TO_STRING_IMPL_MASK = 256; //0x100
/**
* Of string implementation of class.
*/
- public static final int OF_STRING_IMPL_MASK = 512;
+ public static final int OF_STRING_IMPL_MASK = 512; //0x200
/**
* Constructor for type class like typedef, union.
*/
- public static final int CONSTRUCTOR_FOR_TYPE_MASK = 1024;
+ public static final int CONSTRUCTOR_FOR_TYPE_MASK = 1024; //0x400
/**
* From string implementation of class.
*/
- public static final int FROM_STRING_IMPL_MASK = 2048;
+ public static final int FROM_STRING_IMPL_MASK = 2048; //0x800
/**
* Enum implementation of class.
*/
- public static final int ENUM_IMPL_MASK = 4096;
+ public static final int ENUM_IMPL_MASK = 4096; //0x1000
/**
* Rpc interface of module / sub module.
*/
- public static final int RPC_INTERFACE_MASK = 8192;
+ public static final int RPC_INTERFACE_MASK = 8192; //0x2000
/**
* Rpc implementation of module / sub module.
*/
- public static final int RPC_IMPL_MASK = 16384;
+ public static final int RPC_IMPL_MASK = 16384; //0x4000
/**
* Event enum implementation of class.
*/
- public static final int EVENT_ENUM_MASK = 32768;
+ public static final int EVENT_ENUM_MASK = 32768; //0X8000
/**
* Event method implementation of class.
*/
- public static final int EVENT_METHOD_MASK = 65536;
+ public static final int EVENT_METHOD_MASK = 65536; //0x10000
/**
* Event subject attribute implementation of class.
*/
- public static final int EVENT_SUBJECT_ATTRIBUTE_MASK = 131072;
+ public static final int EVENT_SUBJECT_ATTRIBUTE_MASK = 131072; //0X20000
/**
* Event subject getter implementation of class.
*/
- public static final int EVENT_SUBJECT_GETTER_MASK = 262144;
+ public static final int EVENT_SUBJECT_GETTER_MASK = 262144; //0x40000
/**
* Event subject setter implementation of class.
*/
- public static final int EVENT_SUBJECT_SETTER_MASK = 524288;
+ public static final int EVENT_SUBJECT_SETTER_MASK = 524288; //80000
/**
* Add to list method interface for class.
*/
- public static final int ADD_TO_LIST_INTERFACE_MASK = 1048576;
+ public static final int ADD_TO_LIST_INTERFACE_MASK = 1048576; //0X100000
/**
* Add to list method implementation for class.
*/
- public static final int ADD_TO_LIST_IMPL_MASK = 2097152;
+ public static final int ADD_TO_LIST_IMPL_MASK = 2097152; //0X200000
/**
* Leaf identifier enum attributes for class.
*/
- public static final int LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK = 4194304;
+ public static final int LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK = 4194304; //0X400000
/**
* Is filter content match for leaves class.
*/
- public static final int FILTER_CONTENT_MATCH_FOR_LEAF_MASK = 8388608;
+ public static final int FILTER_CONTENT_MATCH_FOR_LEAF_MASK = 8388608; //0X800000
/**
* Is filter content match for leaf lists class.
*/
- public static final int FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK = 16777216;
+ public static final int FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK = 16777216; //0X1000000
/**
* Is filter content match for nodes class.
*/
- public static final int FILTER_CONTENT_MATCH_FOR_NODES_MASK = 33554432;
+ public static final int FILTER_CONTENT_MATCH_FOR_NODES_MASK = 33554432; //0X2000000
/**
* Edit config class content for class.
*/
- public static final int EDIT_CONTENT_MASK = 67108864;
+ public static final int EDIT_CONTENT_MASK = 67108864; //0X4000000
/**
* Creates an instance of generated temp file type.
diff --git a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaEnumerationFragmentFiles.java b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaEnumerationFragmentFiles.java
index 8ea9fc6..d17c081 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaEnumerationFragmentFiles.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaEnumerationFragmentFiles.java
@@ -47,7 +47,8 @@
* Represents implementation of java code fragments temporary implementations. Maintains the temp files required
* specific for enumeration java snippet generation.
*/
-public class TempJavaEnumerationFragmentFiles extends TempJavaFragmentFiles {
+public class TempJavaEnumerationFragmentFiles
+ extends TempJavaFragmentFiles {
/**
* File name for temporary enum class.
@@ -181,7 +182,8 @@
* @param curEnumName current YANG enum
* @throws IOException when fails to do IO operations.
*/
- private void addAttributesForEnumClass(String curEnumName, YangPluginConfig pluginConfig) throws IOException {
+ private void addAttributesForEnumClass(String curEnumName, YangPluginConfig pluginConfig)
+ throws IOException {
appendToFile(getEnumClassTempFileHandle(),
generateEnumAttributeString(curEnumName, getEnumValue(), pluginConfig));
}
@@ -193,7 +195,8 @@
* @param pluginConfig plugin configurations
* @throws IOException when fails to do IO operations
*/
- void addEnumAttributeToTempFiles(YangNode curNode, YangPluginConfig pluginConfig) throws IOException {
+ void addEnumAttributeToTempFiles(YangNode curNode, YangPluginConfig pluginConfig)
+ throws IOException {
super.addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeForEnum(pluginConfig), pluginConfig);
if (curNode instanceof YangEnumeration) {
@@ -265,7 +268,8 @@
* @throws IOException when fails to generate java files
*/
@Override
- public void generateJavaFile(int fileType, YangNode curNode) throws IOException {
+ public void generateJavaFile(int fileType, YangNode curNode)
+ throws IOException {
createPackage(curNode);
setEnumClassJavaFileHandle(getJavaFileHandle(getJavaClassName(ENUM_CLASS_FILE_NAME_SUFFIX)));
setEnumClassJavaFileHandle(generateEnumClassFile(getEnumClassJavaFileHandle(), curNode));
@@ -279,7 +283,8 @@
* @throws IOException when failed to delete the temporary files
*/
@Override
- public void freeTemporaryResources(boolean isErrorOccurred) throws IOException {
+ public void freeTemporaryResources(boolean isErrorOccurred)
+ throws IOException {
closeFile(getEnumClassJavaFileHandle(), isErrorOccurred);
closeFile(getEnumClassTempFileHandle(), true);
super.freeTemporaryResources(isErrorOccurred);
diff --git a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java
index dd4c616..1988e5a 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java
@@ -84,14 +84,17 @@
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForClass;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterString;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethod;
-import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getIsFilerContentMatchForLeaf;
-import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getIsFilerContentMatchForLeafList;
-import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getIsFilterContentForNodes;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOverRideString;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForClass;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterString;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethod;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.parseBuilderInterfaceBuildMethodString;
+import static org.onosproject.yangutils.translator.tojava.utils.SubtreeFilteringMethodsGenerator
+ .getSubtreeFilteringForLeaf;
+import static org.onosproject.yangutils.translator.tojava.utils.SubtreeFilteringMethodsGenerator
+ .getSubtreeFilteringForLeafList;
+import static org.onosproject.yangutils.translator.tojava.utils.SubtreeFilteringMethodsGenerator
+ .getSubtreeFilteringForNode;
import static org.onosproject.yangutils.utils.UtilConstants.ARRAY_LIST_IMPORT;
import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT;
@@ -344,17 +347,17 @@
/**
* Temporary file handle for is content match method for leaf-list.
*/
- private File isContentMatchLeafListTempFileHandle;
+ private File getSubtreeFilteringForListTempFileHandle;
/**
* Temporary file handle for is content match method for node.
*/
- private File isContentMatchNodeTempFileHandle;
+ private File getSubtreeFilteringForChildNodeTempFileHandle;
/**
* Temporary file handle for is content match method for leaf.
*/
- private File isContentMatchLeafTempFileHandle;
+ private File subtreeFilteringForLeafTempFileHandle;
/**
* Temporary file handle for edit content file.
@@ -493,13 +496,15 @@
setLeafIdAttributeTempFileHandle(getTemporaryFileHandle(LEAF_IDENTIFIER_ATTRIBUTES_FILE_NAME));
}
if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_LEAF_MASK) != 0) {
- setIsContentMatchLeafTempFileHandle(getTemporaryFileHandle(FILTER_CONTENT_MATCH_LEAF_FILE_NAME));
+ setSubtreeFilteringForLeafTempFileHandle(getTemporaryFileHandle(FILTER_CONTENT_MATCH_LEAF_FILE_NAME));
}
if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK) != 0) {
- setIsContentMatchLeafListTempFileHandle(getTemporaryFileHandle(FILTER_CONTENT_MATCH_LEAF_LIST_FILE_NAME));
+ setGetSubtreeFilteringForListTempFileHandle(
+ getTemporaryFileHandle(FILTER_CONTENT_MATCH_LEAF_LIST_FILE_NAME));
}
if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_NODES_MASK) != 0) {
- setIsContentMatchNodeTempFileHandle(getTemporaryFileHandle(FILTER_CONTENT_MATCH_NODE_FILE_NAME));
+ setGetSubtreeFilteringForChildNodeTempFileHandle(
+ getTemporaryFileHandle(FILTER_CONTENT_MATCH_NODE_FILE_NAME));
}
if ((getGeneratedTempFiles() & EDIT_CONTENT_MASK) != 0) {
setEditContentTempFileHandle(getTemporaryFileHandle(EDIT_CONTENT_FILE_NAME));
@@ -515,12 +520,13 @@
* @throws IOException IO operation exception
*/
static void addCurNodeInfoInParentTempFile(YangNode curNode,
- boolean isList, YangPluginConfig pluginConfig)
+ boolean isList, YangPluginConfig pluginConfig)
throws IOException {
YangNode parent = getParentNodeInGenCode(curNode);
if (!(parent instanceof JavaCodeGenerator)) {
throw new TranslatorException("missing parent node to contain current node info in generated file");
}
+
if (parent instanceof YangJavaGroupingTranslator) {
/*
* In case of grouping, there is no need to add the information, it
@@ -528,6 +534,7 @@
*/
return;
}
+
TempJavaBeanFragmentFiles tempJavaBeanFragmentFiles = ((JavaCodeGeneratorInfo) parent)
.getTempJavaCodeFragmentFiles().getBeanTempFiles();
@@ -546,8 +553,8 @@
* @return AttributeInfo attribute details required to add in temporary files
*/
public static JavaAttributeInfo getCurNodeAsAttributeInTarget(YangNode curNode,
- YangNode targetNode, boolean isListNode,
- TempJavaFragmentFiles tempJavaFragmentFiles) {
+ YangNode targetNode, boolean isListNode,
+ TempJavaFragmentFiles tempJavaFragmentFiles) {
String curNodeName = ((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName();
if (curNodeName == null) {
updateJavaFileInfo(curNode, null);
@@ -624,7 +631,7 @@
* @return java attribute for leaf
*/
private static JavaAttributeInfo getJavaAttributeOfLeaf(TempJavaFragmentFiles tempJavaFragmentFiles, YangLeaf leaf,
- YangPluginConfig yangPluginConfig) {
+ YangPluginConfig yangPluginConfig) {
JavaLeafInfoContainer javaLeaf = (JavaLeafInfoContainer) leaf;
javaLeaf.setConflictResolveConfig(yangPluginConfig.getConflictResolver());
javaLeaf.updateJavaQualifiedInfo();
@@ -645,8 +652,8 @@
* @return java attribute for leaf-list
*/
private static JavaAttributeInfo getJavaAttributeOfLeafList(TempJavaFragmentFiles tempJavaFragmentFiles,
- YangLeafList leafList,
- YangPluginConfig yangPluginConfig) {
+ YangLeafList leafList,
+ YangPluginConfig yangPluginConfig) {
JavaLeafInfoContainer javaLeaf = (JavaLeafInfoContainer) leafList;
javaLeaf.setConflictResolveConfig(yangPluginConfig.getConflictResolver());
javaLeaf.updateJavaQualifiedInfo();
@@ -1035,10 +1042,10 @@
* @param attr java attribute
* @throws IOException when fails to do IO operations
*/
- private void addIsFilerForLeaf(JavaAttributeInfo attr)
+ private void addSubTreeFilteringForLeaf(JavaAttributeInfo attr)
throws IOException {
- appendToFile(getIsContentMatchLeafTempFileHandle(),
- getIsFilerContentMatchForLeaf(attr, attr.getAttributeType()) + NEW_LINE);
+ appendToFile(getSubtreeFilteringForLeafTempFileHandle(),
+ getSubtreeFilteringForLeaf(attr, attr.getAttributeType()) + NEW_LINE);
}
/**
@@ -1047,10 +1054,10 @@
* @param attr java attribute
* @throws IOException when fails to do IO operations
*/
- private void addIsFilerForLeafList(JavaAttributeInfo attr)
+ private void addSubtreeFilteringForLeafList(JavaAttributeInfo attr)
throws IOException {
- appendToFile(getIsContentMatchLeafTempFileHandle(),
- getIsFilerContentMatchForLeafList(attr) + NEW_LINE);
+ appendToFile(getGetSubtreeFilteringForListTempFileHandle(),
+ getSubtreeFilteringForLeafList(attr) + NEW_LINE);
}
/**
@@ -1059,10 +1066,10 @@
* @param attr java attribute
* @throws IOException when fails to do IO operations
*/
- private void addIsFilerForNode(JavaAttributeInfo attr)
+ private void addSubtreeFilteringForChildNode(JavaAttributeInfo attr)
throws IOException {
- appendToFile(getIsContentMatchLeafTempFileHandle(),
- getIsFilterContentForNodes(attr.getAttributeName(), attr.isListAttr()) + NEW_LINE);
+ appendToFile(getGetSubtreeFilteringForChildNodeTempFileHandle(),
+ getSubtreeFilteringForNode(attr) + NEW_LINE);
}
/**
@@ -1108,8 +1115,7 @@
/**
* Adds setter's implementation for class.
*
- * @param attr attribute info
- * @param pluginConfig
+ * @param attr attribute info
* @throws IOException when fails to append to temporary file
*/
private void addSetterImpl(JavaAttributeInfo attr, YangPluginConfig pluginConfig)
@@ -1162,10 +1168,11 @@
* @param pluginConfig plugin configurations
* @throws IOException when fails to do IO operations
*/
- private void addAddToListInterface(JavaAttributeInfo attr, YangPluginConfig pluginConfig) throws IOException {
+ private void addAddToListInterface(JavaAttributeInfo attr, YangPluginConfig pluginConfig)
+ throws IOException {
appendToFile(getAddToListInterfaceTempFileHandle(),
getJavaDoc(ADD_TO_LIST, getCapitalCase(attr.getAttributeName()), false, pluginConfig, null)
- + getAddToListMethodInterface(attr) + NEW_LINE);
+ + getAddToListMethodInterface(attr, getGeneratedJavaClassName()) + NEW_LINE);
}
/**
@@ -1174,9 +1181,10 @@
* @param attr attribute
* @throws IOException when fails to do IO operations
*/
- private void addAddToListImpl(JavaAttributeInfo attr) throws IOException {
+ private void addAddToListImpl(JavaAttributeInfo attr)
+ throws IOException {
appendToFile(getAddToListImplTempFileHandle(),
- getAddToListMethodImpl(attr) + NEW_LINE);
+ getAddToListMethodImpl(attr, getGeneratedJavaClassName(), isRooNode()) + NEW_LINE);
}
/**
@@ -1292,7 +1300,7 @@
* @throws IOException when fails to append to temporary file
*/
void addFromStringMethod(JavaAttributeInfo javaAttributeInfo,
- JavaAttributeInfo fromStringAttributeInfo)
+ JavaAttributeInfo fromStringAttributeInfo)
throws IOException {
appendToFile(getFromStringImplTempFileHandle(), getFromStringMethod(javaAttributeInfo,
fromStringAttributeInfo) + NEW_LINE);
@@ -1378,7 +1386,9 @@
* @return attribute string
*/
String parseAttribute(JavaAttributeInfo attr, YangPluginConfig pluginConfig) {
- //TODO: check if this utility needs to be called or move to the caller
+ /*
+ * TODO: check if this utility needs to be called or move to the caller
+ */
String attributeName = getCamelCase(attr.getAttributeName(), pluginConfig.getConflictResolver());
String attributeAccessType = PRIVATE;
if ((javaFileInfo.getGeneratedFileTypes() & GENERATE_INTERFACE_WITH_BUILDER) != 0) {
@@ -1449,7 +1459,7 @@
* @throws IOException IO operation fail
*/
private void addLeavesInfoToTempFiles(List<YangLeaf> listOfLeaves,
- YangPluginConfig yangPluginConfig, YangNode curNode)
+ YangPluginConfig yangPluginConfig, YangNode curNode)
throws IOException {
if (listOfLeaves != null) {
for (YangLeaf leaf : listOfLeaves) {
@@ -1478,7 +1488,8 @@
* @throws IOException IO operation fail
*/
private void addLeafListInfoToTempFiles(List<YangLeafList> listOfLeafList, YangPluginConfig yangPluginConfig,
- YangNode curNode) throws IOException {
+ YangNode curNode)
+ throws IOException {
if (listOfLeafList != null) {
for (YangLeafList leafList : listOfLeafList) {
if (!(leafList instanceof JavaLeafInfoContainer)) {
@@ -1505,7 +1516,7 @@
* @throws IOException IO operation fail
*/
void addCurNodeLeavesInfoToTempFiles(YangNode curNode,
- YangPluginConfig yangPluginConfig)
+ YangPluginConfig yangPluginConfig)
throws IOException {
if (!(curNode instanceof YangLeavesHolder)) {
throw new TranslatorException("Data model node does not have any leaves");
@@ -1557,15 +1568,15 @@
}
if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_NODES_MASK) != 0
&& newAttrInfo.getAttributeType() == null) {
- addIsFilerForNode(newAttrInfo);
+ addSubtreeFilteringForChildNode(newAttrInfo);
}
if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_LEAF_MASK) != 0 && !newAttrInfo.isListAttr()
&& newAttrInfo.getAttributeType() != null) {
- addIsFilerForLeaf(newAttrInfo);
+ addSubTreeFilteringForLeaf(newAttrInfo);
}
if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK) != 0 && newAttrInfo.isListAttr()
&& newAttrInfo.getAttributeType() != null) {
- addIsFilerForLeafList(newAttrInfo);
+ addSubtreeFilteringForLeafList(newAttrInfo);
}
if ((getGeneratedTempFiles() & LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK) != 0 && !newAttrInfo.isListAttr()
&& newAttrInfo.getAttributeType() != null) {
@@ -1750,7 +1761,7 @@
* @param curNode current node
*/
private void addImportsForAugmentableClass(List<String> imports, boolean operations, boolean isInterfaceFile,
- YangNode curNode) {
+ YangNode curNode) {
if (operations) {
if (!isInterfaceFile) {
imports.add(getJavaImportData().getHashMapImport());
@@ -1831,13 +1842,13 @@
closeFile(getLeafIdAttributeTempFileHandle(), true);
}
if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_LEAF_MASK) != 0) {
- closeFile(getIsContentMatchLeafTempFileHandle(), true);
+ closeFile(getSubtreeFilteringForLeafTempFileHandle(), true);
}
if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK) != 0) {
- closeFile(getIsContentMatchLeafListTempFileHandle(), true);
+ closeFile(getGetSubtreeFilteringForListTempFileHandle(), true);
}
if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_NODES_MASK) != 0) {
- closeFile(getIsContentMatchNodeTempFileHandle(), true);
+ closeFile(getGetSubtreeFilteringForChildNodeTempFileHandle(), true);
}
if ((getGeneratedTempFiles() & EDIT_CONTENT_MASK) != 0) {
closeFile(getEditContentTempFileHandle(), true);
@@ -1934,17 +1945,17 @@
*
* @return temp file for is content match
*/
- public File getIsContentMatchLeafTempFileHandle() {
- return isContentMatchLeafTempFileHandle;
+ public File getSubtreeFilteringForLeafTempFileHandle() {
+ return subtreeFilteringForLeafTempFileHandle;
}
/**
* Sets temp file handle for is content match.
*
- * @param isContentMatchLeafTempFileHandle temp file handle for is content match
+ * @param subtreeFilteringForLeafTempFileHandle temp file handle for is content match
*/
- private void setIsContentMatchLeafTempFileHandle(File isContentMatchLeafTempFileHandle) {
- this.isContentMatchLeafTempFileHandle = isContentMatchLeafTempFileHandle;
+ private void setSubtreeFilteringForLeafTempFileHandle(File subtreeFilteringForLeafTempFileHandle) {
+ this.subtreeFilteringForLeafTempFileHandle = subtreeFilteringForLeafTempFileHandle;
}
/**
@@ -1970,17 +1981,17 @@
*
* @return temp file for is content match
*/
- public File getIsContentMatchLeafListTempFileHandle() {
- return isContentMatchLeafListTempFileHandle;
+ public File getGetSubtreeFilteringForListTempFileHandle() {
+ return getSubtreeFilteringForListTempFileHandle;
}
/**
* Sets temp file handle for is content match.
*
- * @param isContentMatchLeafListTempFileHandle temp file handle for is content match
+ * @param getSubtreeFilteringForListTempFileHandle temp file handle for is content match
*/
- private void setIsContentMatchLeafListTempFileHandle(File isContentMatchLeafListTempFileHandle) {
- this.isContentMatchLeafListTempFileHandle = isContentMatchLeafListTempFileHandle;
+ private void setGetSubtreeFilteringForListTempFileHandle(File getSubtreeFilteringForListTempFileHandle) {
+ this.getSubtreeFilteringForListTempFileHandle = getSubtreeFilteringForListTempFileHandle;
}
/**
@@ -1988,16 +1999,16 @@
*
* @return temp file for is content match
*/
- public File getIsContentMatchNodeTempFileHandle() {
- return isContentMatchNodeTempFileHandle;
+ public File getGetSubtreeFilteringForChildNodeTempFileHandle() {
+ return getSubtreeFilteringForChildNodeTempFileHandle;
}
/**
* Sets temp file handle for is content match.
*
- * @param isContentMatchNodeTempFileHandle temp file handle for is content match
+ * @param getSubtreeFilteringForChildNodeTempFileHandle temp file handle for is content match
*/
- private void setIsContentMatchNodeTempFileHandle(File isContentMatchNodeTempFileHandle) {
- this.isContentMatchNodeTempFileHandle = isContentMatchNodeTempFileHandle;
+ private void setGetSubtreeFilteringForChildNodeTempFileHandle(File getSubtreeFilteringForChildNodeTempFileHandle) {
+ this.getSubtreeFilteringForChildNodeTempFileHandle = getSubtreeFilteringForChildNodeTempFileHandle;
}
}
diff --git a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaTypeFragmentFiles.java b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaTypeFragmentFiles.java
index e6a5379..b8f12e6 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaTypeFragmentFiles.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaTypeFragmentFiles.java
@@ -20,6 +20,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.datamodel.YangTypeHolder;
@@ -289,7 +290,7 @@
* @throws IOException IO operation fail
*/
private void addJavaSnippetInfoToApplicableTempFiles(JavaAttributeInfo javaAttributeInfo,
- YangPluginConfig pluginConfig, List<YangType<?>> typeList)
+ YangPluginConfig pluginConfig, List<YangType<?>> typeList)
throws IOException {
YangDataTypes attrType = javaAttributeInfo.getAttributeType().getDataType();
@@ -323,7 +324,8 @@
* @throws IOException when fails to do IO operations
*/
private void addMethodsWhenNoConflictingTypes(JavaAttributeInfo javaAttributeInfo,
- YangPluginConfig pluginConfig) throws IOException {
+ YangPluginConfig pluginConfig)
+ throws IOException {
if ((getGeneratedTempFiles() & OF_STRING_IMPL_MASK) != 0) {
addOfStringMethod(javaAttributeInfo, pluginConfig);
}
@@ -339,7 +341,8 @@
* @param pluginConfig plugin configurations
* @throws IOException when fails to do IO operations
*/
- private void addMethodsInConflictCase(YangPluginConfig pluginConfig) throws IOException {
+ private void addMethodsInConflictCase(YangPluginConfig pluginConfig)
+ throws IOException {
JavaAttributeInfo attr = getIntAttribute();
if (attr != null) {
attr = getUIntAttribute();
@@ -391,7 +394,8 @@
* @param pluginConfig plugin configurations
* @throws IOException when fails to do IO operations
*/
- private void addFromStringMethod(JavaAttributeInfo newAttrInfo, YangPluginConfig pluginConfig) throws IOException {
+ private void addFromStringMethod(JavaAttributeInfo newAttrInfo, YangPluginConfig pluginConfig)
+ throws IOException {
JavaQualifiedTypeInfoTranslator qualifiedInfoOfFromString = getQualifiedInfoOfFromString(newAttrInfo,
pluginConfig.getConflictResolver());
diff --git a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGen.java b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGen.java
index 0d52229..6b4da44 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGen.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGen.java
@@ -54,6 +54,7 @@
import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS;
import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE;
+import static org.onosproject.yangutils.utils.UtilConstants.PROTECTED;
import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC;
import static org.onosproject.yangutils.utils.UtilConstants.QUESTION_MARK;
import static org.onosproject.yangutils.utils.UtilConstants.QUEUE;
@@ -274,7 +275,7 @@
* @return attribute for augmentation
*/
static String addAugmentationAttribute() {
- return NEW_LINE + FOUR_SPACE_INDENTATION + PRIVATE + SPACE + MAP + DIAMOND_OPEN_BRACKET + CLASS_STRING
+ return NEW_LINE + FOUR_SPACE_INDENTATION + PROTECTED + SPACE + MAP + DIAMOND_OPEN_BRACKET + CLASS_STRING
+ DIAMOND_OPEN_BRACKET + QUESTION_MARK + DIAMOND_CLOSE_BRACKET + COMMA + SPACE + OBJECT_STRING
+ DIAMOND_CLOSE_BRACKET + SPACE + getSmallCase(YANG_AUGMENTED_INFO) + MAP + SPACE + EQUAL + SPACE +
NEW + SPACE + HASH_MAP + DIAMOND_OPEN_BRACKET + DIAMOND_CLOSE_BRACKET + OPEN_PARENTHESIS
diff --git a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
index 45cb014..dcca748 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
@@ -70,9 +70,6 @@
import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_SUBJECT_ATTRIBUTE_MASK;
import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_SUBJECT_GETTER_MASK;
import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_SUBJECT_SETTER_MASK;
-import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK;
-import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FILTER_CONTENT_MATCH_FOR_LEAF_MASK;
-import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FILTER_CONTENT_MATCH_FOR_NODES_MASK;
import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FROM_STRING_IMPL_MASK;
import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_CLASS_MASK;
import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_INTERFACE_MASK;
@@ -115,8 +112,6 @@
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethodOpen;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getInterfaceLeafIdEnumMethods;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getInterfaceLeafIdEnumSignature;
-import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getIsFilerContentMatchClose;
-import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getIsFilterContentMatchStart;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOmitNullValueString;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOperationAttributesGetters;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOverRideString;
@@ -130,10 +125,24 @@
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getYangAugmentInfoInterface;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getYangAugmentInfoMapImpl;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getYangAugmentInfoMapInterface;
-import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.isFilterContentMatchInterface;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.isLeafValueSetInterface;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.isSelectLeafSetInterface;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.processSubtreeFilteringInterface;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.setSelectLeafSetInterface;
+import static org.onosproject.yangutils.translator.tojava.utils.SubtreeFilteringMethodsGenerator
+ .getAugmentableSubTreeFiltering;
+import static org.onosproject.yangutils.translator.tojava.utils.SubtreeFilteringMethodsGenerator
+ .getProcessChildNodeSubtreeFiltering;
+import static org.onosproject.yangutils.translator.tojava.utils.SubtreeFilteringMethodsGenerator
+ .getProcessLeafListSubtreeFiltering;
+import static org.onosproject.yangutils.translator.tojava.utils.SubtreeFilteringMethodsGenerator
+ .getProcessLeafSubtreeFiltering;
+import static org.onosproject.yangutils.translator.tojava.utils.SubtreeFilteringMethodsGenerator
+ .getProcessSubTreeFilteringEnd;
+import static org.onosproject.yangutils.translator.tojava.utils.SubtreeFilteringMethodsGenerator
+ .getProcessSubtreeFilteringStart;
+import static org.onosproject.yangutils.translator.tojava.utils.SubtreeFilteringMethodsGenerator
+ .getProcessSubtreeFunctionBody;
import static org.onosproject.yangutils.utils.UtilConstants.BASE64;
import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER;
import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
@@ -159,6 +168,7 @@
import static org.onosproject.yangutils.utils.UtilConstants.OP_PARAM;
import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE;
+import static org.onosproject.yangutils.utils.UtilConstants.PROTECTED;
import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC;
import static org.onosproject.yangutils.utils.UtilConstants.RETURN;
import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
@@ -174,6 +184,7 @@
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.replaceLast;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.validateLineLength;
+
import static java.util.Collections.sort;
/**
@@ -195,7 +206,7 @@
* @throws IOException when fails to write in file
*/
public static File generateInterfaceFile(File file, List<String> imports, YangNode curNode,
- boolean isAttrPresent)
+ boolean isAttrPresent)
throws IOException {
JavaFileInfoTranslator javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
@@ -239,10 +250,6 @@
insertDataIntoJavaFile(file, getDataFromTempFileHandle(GETTER_FOR_INTERFACE_MASK,
((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
.getBeanTempFiles(), path));
- //Add to list method.
- insertDataIntoJavaFile(file, getDataFromTempFileHandle(ADD_TO_LIST_INTERFACE_MASK,
- ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
- .getBeanTempFiles(), path));
} catch (IOException e) {
throw new IOException("No data found in temporary java code fragment files for " + className
+ " while interface file generation");
@@ -250,7 +257,6 @@
}
if (curNode instanceof YangAugmentableNode && !(curNode instanceof YangChoice)) {
- methods.add(getAddAugmentInfoMethodInterface());
methods.add(getYangAugmentInfoInterface());
methods.add(getYangAugmentInfoMapInterface(javaFileInfo.getPluginConfig()));
}
@@ -258,9 +264,9 @@
YangNode caseParent = curNode.getParent();
JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifierInfoForCasesParent(caseParent,
javaFileInfo.getPluginConfig());
- methods.add(NEW_LINE + isFilterContentMatchInterface(qualifiedTypeInfo.getClassInfo()));
+ methods.add(NEW_LINE + processSubtreeFilteringInterface(qualifiedTypeInfo.getClassInfo()));
} else {
- methods.add(NEW_LINE + isFilterContentMatchInterface(className));
+ methods.add(NEW_LINE + processSubtreeFilteringInterface(className));
}
if (isLeavesPresent) {
@@ -322,12 +328,25 @@
methods.add(FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(SETTER_FOR_INTERFACE_MASK,
((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
.getBeanTempFiles(), path));
+
+ //Add to list method.
+ methods.add(NEW_LINE);
+ insertDataIntoJavaFile(file, getDataFromTempFileHandle(ADD_TO_LIST_INTERFACE_MASK,
+ ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
+ .getBeanTempFiles(), path));
+
} catch (IOException e) {
throw new IOException("No data found in temporary java code fragment files for " + className
+ " while builder interface file generation");
}
}
+ if (curNode instanceof YangAugmentableNode && !(curNode instanceof YangChoice)) {
+ methods.add(getAddAugmentInfoMethodInterface());
+ methods.add(getYangAugmentInfoInterface());
+ methods.add(getYangAugmentInfoMapInterface(javaFileInfo.getPluginConfig()));
+ }
+
if (isLeavesPresent) {
methods.add(NEW_LINE + setSelectLeafSetInterface(className));
}
@@ -357,7 +376,8 @@
*/
public static File generateBuilderClassFile(File file, YangNode curNode,
- boolean isAttrPresent) throws IOException {
+ boolean isAttrPresent)
+ throws IOException {
JavaFileInfoTranslator javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
YangPluginConfig pluginConfig = javaFileInfo.getPluginConfig();
@@ -385,6 +405,9 @@
initiateJavaFileGeneration(file, BUILDER_CLASS_MASK, null, curNode, className);
List<String> methods = new ArrayList<>();
+ if (curNode instanceof YangAugmentableNode) {
+ insertDataIntoJavaFile(file, JavaCodeSnippetGen.addAugmentationAttribute());
+ }
if (isAttrPresent) {
//Add attribute strings.
@@ -412,6 +435,11 @@
((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
.getBeanTempFiles(), path));
+ //Add to list impl method.
+ methods.add(getDataFromTempFileHandle(ADD_TO_LIST_IMPL_MASK,
+ ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
+ .getBeanTempFiles(), path));
+
insertDataIntoJavaFile(file, NEW_LINE);
methods.add(getGetterForOperationType());
@@ -429,6 +457,12 @@
insertDataIntoJavaFile(file, NEW_LINE);
}
+ if (curNode instanceof YangAugmentableNode) {
+ methods.add(getAddAugmentInfoMethodImpl());
+ methods.add(getYangAugmentInfoImpl());
+ methods.add(getYangAugmentInfoMapImpl());
+ }
+
// Add default constructor and build method impl.
methods.add(((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
.addBuildMethodImpl(curNode));
@@ -456,7 +490,7 @@
* @throws IOException when fails to write in file
*/
public static File generateDefaultClassFile(File file, YangNode curNode, boolean isAttrPresent,
- List<String> imports)
+ List<String> imports)
throws IOException {
JavaFileInfoTranslator javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
@@ -517,11 +551,6 @@
((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
.getBeanTempFiles(), path));
- //Add to list impl method.
- methods.add(getDataFromTempFileHandle(ADD_TO_LIST_IMPL_MASK,
- ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
- .getBeanTempFiles(), path));
-
// Hash code method.
methods.add(getHashCodeMethodClose(getHashCodeMethodOpen() +
getDataFromTempFileHandle(HASH_CODE_IMPL_MASK,
@@ -556,7 +585,6 @@
}
if (curNode instanceof YangAugmentableNode) {
- methods.add(getAddAugmentInfoMethodImpl());
methods.add(getYangAugmentInfoImpl());
methods.add(getYangAugmentInfoMapImpl());
}
@@ -576,24 +604,24 @@
methods.add(constructor + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE);
// add is filter content match.
- methods.add(getIsFilterContentMatchStart(curNode, pluginConfig)
- + getDataFromTempFileHandle(FILTER_CONTENT_MATCH_FOR_LEAF_MASK,
- ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
- .getBeanTempFiles(), path)
- + getDataFromTempFileHandle(FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK,
- ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
- .getBeanTempFiles(), path)
- + getDataFromTempFileHandle(FILTER_CONTENT_MATCH_FOR_NODES_MASK,
- ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
- .getBeanTempFiles(), path)
- + getIsFilerContentMatchClose());
+ String augmentableSubTreeFiltering = "";
+ if (curNode instanceof YangAugmentableNode) {
+ augmentableSubTreeFiltering = getAugmentableSubTreeFiltering();
+ }
+ methods.add(getProcessSubtreeFilteringStart(curNode, pluginConfig)
+ + getProcessSubtreeFunctionBody()
+ + augmentableSubTreeFiltering
+ + getProcessSubTreeFilteringEnd()
+ + getProcessLeafSubtreeFiltering(curNode, pluginConfig, path)
+ + getProcessLeafListSubtreeFiltering(curNode, pluginConfig, path)
+ + getProcessChildNodeSubtreeFiltering(curNode, pluginConfig, path));
} catch (IOException e) {
throw new IOException("No data found in temporary java code fragment files for " + className
+ " while impl class file generation");
}
methods.add(((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
- .addDefaultConstructor(PUBLIC, DEFAULT, pluginConfig, curNode));
+ .addDefaultConstructor(PROTECTED, DEFAULT, pluginConfig, curNode));
methods.add(builderMethod(className) + NEW_LINE);
if (isLeavesPresent) {
@@ -673,7 +701,6 @@
((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles(),
path));
-
// Hash code method.
methods.add(getHashCodeMethodClose(getHashCodeMethodOpen() +
getDataFromTempFileHandle(HASH_CODE_IMPL_MASK,
@@ -1032,7 +1059,8 @@
* @param imports imports for file
* @throws IOException when fails to generate class file
*/
- public static void generateEventFile(File file, YangNode curNode, List<String> imports) throws IOException {
+ public static void generateEventFile(File file, YangNode curNode, List<String> imports)
+ throws IOException {
String className = getCapitalCase(((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName())
+ EVENT_STRING;
diff --git a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGeneratorUtils.java b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGeneratorUtils.java
index a1000ca..1c33948 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGeneratorUtils.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGeneratorUtils.java
@@ -135,7 +135,7 @@
* @return file object
*/
public static File getFileObject(String filePath, String fileName, String extension,
- JavaFileInfoTranslator handler) {
+ JavaFileInfoTranslator handler) {
return new File(handler.getBaseCodeGenPath() + filePath + SLASH + fileName + extension);
}
@@ -149,7 +149,7 @@
* @throws IOException when failed to get the data from temporary file handle
*/
static String getDataFromTempFileHandle(int generatedTempFiles,
- TempJavaFragmentFiles tempJavaFragmentFiles, String absolutePath)
+ TempJavaFragmentFiles tempJavaFragmentFiles, String absolutePath)
throws IOException {
TempJavaTypeFragmentFiles typeFragmentFiles = null;
@@ -204,16 +204,16 @@
absolutePath);
} else if ((generatedTempFiles & FILTER_CONTENT_MATCH_FOR_LEAF_MASK) != 0) {
return tempJavaFragmentFiles
- .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getIsContentMatchLeafTempFileHandle(),
+ .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getSubtreeFilteringForLeafTempFileHandle(),
absolutePath);
} else if ((generatedTempFiles & FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK) != 0) {
return tempJavaFragmentFiles
- .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getIsContentMatchLeafListTempFileHandle(),
+ .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getGetSubtreeFilteringForListTempFileHandle(),
absolutePath);
} else if ((generatedTempFiles & FILTER_CONTENT_MATCH_FOR_NODES_MASK) != 0) {
return tempJavaFragmentFiles
- .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getIsContentMatchNodeTempFileHandle(),
- absolutePath);
+ .getTemporaryDataFromFileHandle(tempJavaFragmentFiles
+ .getGetSubtreeFilteringForChildNodeTempFileHandle(), absolutePath);
} else if ((generatedTempFiles & EDIT_CONTENT_MASK) != 0) {
return tempJavaFragmentFiles
.getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getEditContentTempFileHandle(),
@@ -331,7 +331,7 @@
* @throws IOException when fails to generate a file
*/
public static void initiateJavaFileGeneration(File file, String className, int genType, List<String> imports,
- String pkg, YangPluginConfig pluginConfig)
+ String pkg, YangPluginConfig pluginConfig)
throws IOException {
boolean isFileCreated;
@@ -357,7 +357,7 @@
* @throws IOException when fails to generate a file
*/
public static void initiateJavaFileGeneration(File file, int genType, List<String> imports,
- YangNode curNode, String className)
+ YangNode curNode, String className)
throws IOException {
boolean isFileCreated;
@@ -383,7 +383,7 @@
* @throws IOException when fails to do IO operations
*/
private static void appendContents(File file, int genType, List<String> importsList, YangNode curNode,
- String className)
+ String className)
throws IOException {
JavaFileInfoTranslator javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
@@ -452,7 +452,7 @@
* @throws IOException when fails to append contents
*/
private static void appendContents(File file, String fileName, int genType, List<String> importsList, String pkg,
- YangPluginConfig pluginConfig)
+ YangPluginConfig pluginConfig)
throws IOException {
String pkgString = parsePackageString(pkg, importsList);
@@ -553,7 +553,7 @@
* @throws IOException when fails to write into a file
*/
private static void write(File file, String fileName, int genType, JavaDocType javaDocType,
- YangPluginConfig pluginConfig)
+ YangPluginConfig pluginConfig)
throws IOException {
insertDataIntoJavaFile(file, getJavaDoc(javaDocType, fileName, false, pluginConfig, null));
insertDataIntoJavaFile(file, generateClassDefinition(genType, fileName));
@@ -654,8 +654,7 @@
* @return qualified type info of augmented node
*/
private static JavaQualifiedTypeInfoTranslator getQualifiedTypeInfoOfAugmentedNode(YangNode augmentedNode,
- String curNodeName,
- YangPluginConfig pluginConfig) {
+ String curNodeName, YangPluginConfig pluginConfig) {
JavaQualifiedTypeInfoTranslator javaQualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(augmentedNode,
getCapitalCase(curNodeName));
if (javaQualifiedTypeInfo.getPkgInfo() == null) {
@@ -673,7 +672,7 @@
* @return true if present in imports
*/
private static boolean validateQualifiedInfoOfAugmentedNode(JavaQualifiedTypeInfoTranslator javaQualifiedTypeInfo,
- JavaImportData importData) {
+ JavaImportData importData) {
for (JavaQualifiedTypeInfoTranslator curImportInfo : importData.getImportSet()) {
if (curImportInfo.getClassInfo()
.contentEquals(javaQualifiedTypeInfo.getClassInfo())) {
diff --git a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
index 20cb3e8..a816234 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
@@ -20,19 +20,13 @@
import java.util.Map;
import org.onosproject.yangutils.datamodel.YangAtomicPath;
-import org.onosproject.yangutils.datamodel.YangAugment;
-import org.onosproject.yangutils.datamodel.YangAugmentableNode;
-import org.onosproject.yangutils.datamodel.YangCase;
-import org.onosproject.yangutils.datamodel.YangChoice;
import org.onosproject.yangutils.datamodel.YangCompilerAnnotation;
-import org.onosproject.yangutils.datamodel.YangLeafRef;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
-import org.onosproject.yangutils.translator.tojava.JavaFileInfoTranslator;
import org.onosproject.yangutils.utils.io.YangPluginConfig;
import org.onosproject.yangutils.utils.io.impl.JavaDocGen;
@@ -45,28 +39,26 @@
import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT32;
import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT64;
import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT8;
-import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.LEAFREF;
import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT16;
import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT32;
import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT64;
import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT8;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getAugmentedClassNameForDataMethods;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils
+ .getAugmentedClassNameForDataMethods;
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getParentNodeNameForDataMethods;
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getSetOfNodeIdentifiers;
import static org.onosproject.yangutils.translator.tojava.utils.ValidatorTypeForUnionTypes.INT_TYPE_CONFLICT;
import static org.onosproject.yangutils.utils.UtilConstants.ADD;
import static org.onosproject.yangutils.utils.UtilConstants.ADD_STRING;
import static org.onosproject.yangutils.utils.UtilConstants.AND;
-import static org.onosproject.yangutils.utils.UtilConstants.APP_INSTANCE;
import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED;
import static org.onosproject.yangutils.utils.UtilConstants.BASE64;
import static org.onosproject.yangutils.utils.UtilConstants.BIG_DECIMAL;
import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER;
import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_DATA_TYPE;
import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_WRAPPER;
-import static org.onosproject.yangutils.utils.UtilConstants.BREAK;
import static org.onosproject.yangutils.utils.UtilConstants.BUILD;
import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
import static org.onosproject.yangutils.utils.UtilConstants.BYTE;
@@ -95,33 +87,22 @@
import static org.onosproject.yangutils.utils.UtilConstants.EXCEPTION;
import static org.onosproject.yangutils.utils.UtilConstants.EXCEPTION_VAR;
import static org.onosproject.yangutils.utils.UtilConstants.FALSE;
-import static org.onosproject.yangutils.utils.UtilConstants.FILTER_CONTENT_MATCH;
-import static org.onosproject.yangutils.utils.UtilConstants.FLAG;
import static org.onosproject.yangutils.utils.UtilConstants.FOR;
import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION;
import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_METHOD_NAME;
import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_PARAM_NAME;
import static org.onosproject.yangutils.utils.UtilConstants.GET;
-import static org.onosproject.yangutils.utils.UtilConstants.GET_CLASS;
import static org.onosproject.yangutils.utils.UtilConstants.GET_DECODER;
-import static org.onosproject.yangutils.utils.UtilConstants.GET_FILTER_LEAF;
-import static org.onosproject.yangutils.utils.UtilConstants.GET_LEAF_INDEX;
-import static org.onosproject.yangutils.utils.UtilConstants.GET_METHOD;
import static org.onosproject.yangutils.utils.UtilConstants.GET_METHOD_PREFIX;
import static org.onosproject.yangutils.utils.UtilConstants.GOOGLE_MORE_OBJECT_METHOD_STRING;
import static org.onosproject.yangutils.utils.UtilConstants.HASH;
import static org.onosproject.yangutils.utils.UtilConstants.HASH_CODE_STRING;
import static org.onosproject.yangutils.utils.UtilConstants.IF;
-import static org.onosproject.yangutils.utils.UtilConstants.ILLEGAL_ACCESS_EXCEPTION;
-import static org.onosproject.yangutils.utils.UtilConstants.INSTANCE;
import static org.onosproject.yangutils.utils.UtilConstants.INSTANCE_OF;
import static org.onosproject.yangutils.utils.UtilConstants.INT;
import static org.onosproject.yangutils.utils.UtilConstants.INTEGER_WRAPPER;
import static org.onosproject.yangutils.utils.UtilConstants.INT_MAX_RANGE;
import static org.onosproject.yangutils.utils.UtilConstants.INT_MIN_RANGE;
-import static org.onosproject.yangutils.utils.UtilConstants.INVOCATION_TARGET_EXCEPTION;
-import static org.onosproject.yangutils.utils.UtilConstants.INVOKE;
-import static org.onosproject.yangutils.utils.UtilConstants.IS_EMPTY;
import static org.onosproject.yangutils.utils.UtilConstants.IS_SELECT_LEAF;
import static org.onosproject.yangutils.utils.UtilConstants.LEAF_IDENTIFIER;
import static org.onosproject.yangutils.utils.UtilConstants.LIST;
@@ -134,8 +115,6 @@
import static org.onosproject.yangutils.utils.UtilConstants.MIN_RANGE;
import static org.onosproject.yangutils.utils.UtilConstants.NEW;
import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
-import static org.onosproject.yangutils.utils.UtilConstants.NOT;
-import static org.onosproject.yangutils.utils.UtilConstants.NO_SUCH_METHOD_EXCEPTION;
import static org.onosproject.yangutils.utils.UtilConstants.NULL;
import static org.onosproject.yangutils.utils.UtilConstants.OBJ;
import static org.onosproject.yangutils.utils.UtilConstants.OBJECT;
@@ -145,7 +124,6 @@
import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET;
import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS;
import static org.onosproject.yangutils.utils.UtilConstants.OP_PARAM;
-import static org.onosproject.yangutils.utils.UtilConstants.OR_OPERATION;
import static org.onosproject.yangutils.utils.UtilConstants.OTHER;
import static org.onosproject.yangutils.utils.UtilConstants.OVERRIDE;
import static org.onosproject.yangutils.utils.UtilConstants.PARSE_BOOLEAN;
@@ -155,6 +133,8 @@
import static org.onosproject.yangutils.utils.UtilConstants.PARSE_SHORT;
import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE;
+import static org.onosproject.yangutils.utils.UtilConstants.PROCESS_SUBTREE_FILTERING;
+import static org.onosproject.yangutils.utils.UtilConstants.PROTECTED;
import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC;
import static org.onosproject.yangutils.utils.UtilConstants.PUT;
import static org.onosproject.yangutils.utils.UtilConstants.QUESTION_MARK;
@@ -180,14 +160,11 @@
import static org.onosproject.yangutils.utils.UtilConstants.SWITCH;
import static org.onosproject.yangutils.utils.UtilConstants.THIS;
import static org.onosproject.yangutils.utils.UtilConstants.TMP_VAL;
-import static org.onosproject.yangutils.utils.UtilConstants.TMP_VAR;
import static org.onosproject.yangutils.utils.UtilConstants.TO;
import static org.onosproject.yangutils.utils.UtilConstants.TRIM_STRING;
import static org.onosproject.yangutils.utils.UtilConstants.TRUE;
import static org.onosproject.yangutils.utils.UtilConstants.TRY;
import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTATION;
-import static org.onosproject.yangutils.utils.UtilConstants.TWENTY_FOUR_SPACE_INDENTATION;
-import static org.onosproject.yangutils.utils.UtilConstants.TWENTY_SPACE_INDENTATION;
import static org.onosproject.yangutils.utils.UtilConstants.UINT_MAX_RANGE;
import static org.onosproject.yangutils.utils.UtilConstants.UINT_MIN_RANGE;
import static org.onosproject.yangutils.utils.UtilConstants.ULONG_MAX_RANGE;
@@ -197,7 +174,6 @@
import static org.onosproject.yangutils.utils.UtilConstants.VALUE_LEAF_SET;
import static org.onosproject.yangutils.utils.UtilConstants.VOID;
import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO;
-import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_OP_PARAM_INFO;
import static org.onosproject.yangutils.utils.UtilConstants.YANG_UTILS_TODO;
import static org.onosproject.yangutils.utils.UtilConstants.ZERO;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.BUILD_METHOD;
@@ -253,7 +229,8 @@
* @return getter string
*/
public static String getGetterString(JavaAttributeInfo attr, int generatedJavaFiles,
- YangPluginConfig pluginConfig) {
+ YangPluginConfig pluginConfig) {
+
String returnType = getReturnType(attr);
String attributeName = attr.getAttributeName();
String appDataStructure = null;
@@ -281,7 +258,8 @@
* @return setter string
*/
public static String getSetterString(JavaAttributeInfo attr, String className, int generatedJavaFiles,
- YangPluginConfig pluginConfig) {
+ YangPluginConfig pluginConfig) {
+
String attrType = getReturnType(attr);
String attributeName = attr.getAttributeName();
JavaDocGen.JavaDocType type;
@@ -320,7 +298,7 @@
* @return default constructor string
*/
public static String getDefaultConstructorString(String name, String modifierType,
- YangPluginConfig pluginConfig) {
+ YangPluginConfig pluginConfig) {
return getJavaDoc(DEFAULT_CONSTRUCTOR, name, false, pluginConfig, null)
+ getDefaultConstructor(name, modifierType) + NEW_LINE;
}
@@ -358,6 +336,7 @@
* @return getter method for class
*/
public static String getGetterForClass(JavaAttributeInfo attr, int generatedJavaFiles) {
+
String attrQualifiedType = getReturnType(attr);
String attributeName = attr.getAttributeName();
@@ -440,7 +419,7 @@
* @return setter for attribute
*/
private static String getSetter(String className, String name, String type, int generatedJavaFiles,
- boolean isTypeNull, boolean isList) {
+ boolean isTypeNull, boolean isList) {
if (generatedJavaFiles == GENERATE_SERVICE_AND_MANAGER) {
return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE + SET_METHOD_PREFIX
+ getCapitalCase(name) + OPEN_PARENTHESIS + type + SPACE + name + CLOSE_PARENTHESIS + SPACE +
@@ -520,7 +499,7 @@
* @return getter method for interface
*/
static String getGetterForInterface(String yangName, String returnType, boolean isList,
- int generatedJavaFiles, YangCompilerAnnotation compilerAnnotation) {
+ int generatedJavaFiles, YangCompilerAnnotation compilerAnnotation) {
if (!isList) {
return getGetterInterfaceString(returnType, yangName, generatedJavaFiles);
}
@@ -536,7 +515,7 @@
* @return getter for interface
*/
private static String getGetterInterfaceString(String returnType, String yangName,
- int generatedJavaFiles) {
+ int generatedJavaFiles) {
if (generatedJavaFiles == GENERATE_SERVICE_AND_MANAGER) {
return getGetMethodWithArgument(returnType, yangName);
} else {
@@ -557,8 +536,8 @@
* @return setter method for interface
*/
static String getSetterForInterface(String attrName, String attrType, String className,
- boolean isList, int generatedJavaFiles,
- YangCompilerAnnotation compilerAnnotation) {
+ boolean isList, int generatedJavaFiles,
+ YangCompilerAnnotation compilerAnnotation) {
if (!isList) {
return getSetterInterfaceString(className, attrName, attrType, generatedJavaFiles);
}
@@ -576,7 +555,7 @@
* @return setter string
*/
private static String getSetterInterfaceString(String className, String attrName, String attrType,
- int generatedJavaFiles) {
+ int generatedJavaFiles) {
if (generatedJavaFiles == GENERATE_SERVICE_AND_MANAGER) {
return FOUR_SPACE_INDENTATION + VOID + SPACE + SET_METHOD_PREFIX + getCapitalCase(attrName)
+ OPEN_PARENTHESIS + attrType + SPACE + attrName + CLOSE_PARENTHESIS + SEMI_COLAN;
@@ -636,7 +615,7 @@
if (isRootNode) {
returnType = yangName + OP_PARAM;
}
- String constructor = FOUR_SPACE_INDENTATION + PUBLIC + SPACE + returnType +
+ String constructor = FOUR_SPACE_INDENTATION + PROTECTED + SPACE + returnType +
OPEN_PARENTHESIS + yangName + BUILDER + SPACE + BUILDER.toLowerCase() + OBJECT
+ CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
return javadoc + constructor;
@@ -651,7 +630,8 @@
* @return constructor for class
*/
public static String getConstructor(JavaAttributeInfo attr, int generatedJavaFiles,
- YangPluginConfig pluginConfig) {
+ YangPluginConfig pluginConfig) {
+
String attributeName = attr.getAttributeName();
String constructor;
@@ -681,7 +661,8 @@
* @return rpc method string
*/
public static String getRpcServiceMethod(String rpcName, String inputName, String outputName,
- YangPluginConfig pluginConfig) {
+ YangPluginConfig pluginConfig) {
+
rpcName = getCamelCase(rpcName, pluginConfig.getConflictResolver());
if (!inputName.equals(EMPTY_STRING)) {
inputName = inputName + SPACE + RPC_INPUT_VAR_NAME;
@@ -700,7 +681,8 @@
* @return rpc method string
*/
public static String getRpcManagerMethod(String rpcName, String inputName, String outputName,
- YangPluginConfig pluginConfig) {
+ YangPluginConfig pluginConfig) {
+
rpcName = getCamelCase(rpcName, pluginConfig.getConflictResolver());
if (!inputName.equals(EMPTY_STRING)) {
inputName = inputName + SPACE + RPC_INPUT_VAR_NAME;
@@ -714,6 +696,7 @@
+ NEW_LINE;
}
method += FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
+
return method;
}
@@ -765,7 +748,7 @@
* @param dataType data type to be checked
* @return true, if data type can have primitive data type, false otherwise
*/
- private static boolean isPrimitiveDataType(YangDataTypes dataType) {
+ static boolean isPrimitiveDataType(YangDataTypes dataType) {
return dataType == INT8
|| dataType == INT16
|| dataType == INT32
@@ -780,273 +763,23 @@
}
- private static String getAttrTypeForFilterContentMatchWhenPrimitiveDataType(String attributeName) {
- return APP_INSTANCE + PERIOD + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
- + SPACE + NOT + EQUAL + SPACE + attributeName + OPEN_PARENTHESIS
- + CLOSE_PARENTHESIS;
- }
- private static String getAttrTypeForFilterContentMatchWhenNonPrimitiveDataTypes(String attributeName) {
- return APP_INSTANCE + PERIOD + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
- + SPACE + EQUAL + EQUAL + SPACE + NULL + SPACE + OR_OPERATION + SPACE
- + NOT + OPEN_PARENTHESIS + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
- + PERIOD + EQUALS_STRING + OPEN_PARENTHESIS + APP_INSTANCE + PERIOD
- + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
- + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS;
- }
-
- private static String getIfFilterContentMatchMethodImpl(String attributeName,
- YangType dataType) {
- String attrQualifiedType;
-
- if (isPrimitiveDataType(dataType.getDataType())) {
- attrQualifiedType = getAttrTypeForFilterContentMatchWhenPrimitiveDataType(attributeName);
- } else if (dataType.getDataType() == LEAFREF) {
- YangType type = ((YangLeafRef) dataType.getDataTypeExtendedInfo()).getEffectiveDataType();
- if (isPrimitiveDataType(type.getDataType())) {
- attrQualifiedType = getAttrTypeForFilterContentMatchWhenPrimitiveDataType(attributeName);
- } else {
- attrQualifiedType = getAttrTypeForFilterContentMatchWhenNonPrimitiveDataTypes(attributeName);
- }
- } else {
- attrQualifiedType = getAttrTypeForFilterContentMatchWhenNonPrimitiveDataTypes(attributeName);
- }
-
- return attrQualifiedType;
- }
-
- /**
- * Returns is filter content match for leaf.
- *
- * @param javaAttributeInfo java attribute
- * @param type data type
- * @return is filter content match for leaf
- */
- public static String getIsFilerContentMatchForLeaf(JavaAttributeInfo javaAttributeInfo, YangType<?> type) {
- String attrQualifiedType;
- String attributeName = javaAttributeInfo.getAttributeName();
- attrQualifiedType = getIfFilterContentMatchMethodImpl(attributeName,
- type);
- return EIGHT_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS
- + GET_FILTER_LEAF + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD + GET_METHOD_PREFIX
- + OPEN_PARENTHESIS + LEAF_IDENTIFIER + PERIOD + attributeName.toUpperCase() + PERIOD +
- GET_LEAF_INDEX
- + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS
- + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + TWELVE_SPACE_INDENTATION + IF + SPACE
- + OPEN_PARENTHESIS + attrQualifiedType + CLOSE_PARENTHESIS + SPACE
- + OPEN_CURLY_BRACKET + NEW_LINE + SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + FALSE
- + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE
- + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE;
- }
-
- /**
- * Returns is filter content match for leaf.
- *
- * @param javaAttributeInfo java attribute
- * @return is filter content match for leaf
- */
- public static String getIsFilerContentMatchForLeafList(JavaAttributeInfo javaAttributeInfo) {
- String attributeName = javaAttributeInfo.getAttributeName();
- return getIsFileContentMatchForLists(getCapitalCase(attributeName), true,
- javaAttributeInfo.getImportInfo().getClassInfo());
- }
-
- /**
- * Returns is filter content match for leaf.
- *
- * @param curNode current node
- * @param pluginConfig plugin configurations
- * @return is filter content match for leaf
- */
- static String getIsFilterContentMatchStart(YangNode curNode, YangPluginConfig pluginConfig) {
- JavaFileInfoTranslator javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
- JavaFileInfoTranslator parentInfo;
-
- String instance = APP_INSTANCE;
- String name = getCapitalCase(javaFileInfo.getJavaName());
- if (curNode instanceof YangCase) {
- instance = INSTANCE;
- YangNode parent = curNode.getParent();
- if (parent instanceof YangChoice) {
- parentInfo = ((JavaFileInfoContainer) parent).getJavaFileInfo();
- name = getCapitalCase(parentInfo.getJavaName());
- } else if (parent instanceof YangAugment) {
- parentInfo = ((JavaFileInfoContainer) ((YangAugment) parent).getAugmentedNode()).getJavaFileInfo();
- if (parentInfo != null) {
- name = getCapitalCase(parentInfo.getJavaName());
- } else {
- name = getCapitalCase(getCamelCase(((YangAugment) parent).getAugmentedNode().getName(),
- pluginConfig.getConflictResolver()));
- }
- }
- }
- String filterMethod = getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + BOOLEAN_DATA_TYPE
- + SPACE + FILTER_CONTENT_MATCH + OPEN_PARENTHESIS + name
- + SPACE + instance + CLOSE_PARENTHESIS + SPACE
- + OPEN_CURLY_BRACKET + NEW_LINE;
- if (curNode instanceof YangCase) {
- String caseName = getCapitalCase(javaFileInfo.getJavaName());
- filterMethod = filterMethod + EIGHT_SPACE_INDENTATION + caseName + SPACE + APP_INSTANCE + SPACE + EQUAL
- + SPACE
- + OPEN_PARENTHESIS + caseName + CLOSE_PARENTHESIS + SPACE + instance + SEMI_COLAN + NEW_LINE;
- }
- if (curNode instanceof YangAugmentableNode) {
- filterMethod = filterMethod + getAugmentableOpParamSyntax();
- }
- return filterMethod;
- }
-
- /**
- * Returns is filter content match for node.
- *
- * @param name attribute name
- * @param isList if list node
- * @return is filter content match for node
- */
- public static String getIsFilterContentForNodes(String name, boolean isList) {
- name = getCapitalCase(name);
- if (isList) {
- return getIsFileContentMatchForLists(name, false, null);
- } else {
- return getIsFilerContentMatchForChildNode(name);
- }
- }
-
- /**
- * Returns is filter content match close.
- *
- * @return is filter content match close
- */
- static String getIsFilerContentMatchClose() {
- return EIGHT_SPACE_INDENTATION + RETURN + SPACE + TRUE + SEMI_COLAN +
- NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE;
- }
-
- /**
- * Returns filter content match for child nodes.
- *
- * @param name name of node
- * @return filter content match for child nodes
- */
- private static String getIsFilerContentMatchForChildNode(String name) {
- name = getSmallCase(name);
- String method = EIGHT_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + name + OPEN_PARENTHESIS +
- CLOSE_PARENTHESIS + SPACE + NOT + EQUAL + SPACE + NULL + CLOSE_PARENTHESIS + SPACE +
- OPEN_CURLY_BRACKET + NEW_LINE + TWELVE_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + APP_INSTANCE
- + PERIOD + name + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + EQUAL
- + EQUAL + SPACE + NULL + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE +
- SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + FALSE + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION +
- CLOSE_CURLY_BRACKET + NEW_LINE;
- return method + TWELVE_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + name + OPEN_PARENTHESIS +
- CLOSE_PARENTHESIS + PERIOD + FILTER_CONTENT_MATCH + OPEN_PARENTHESIS + APP_INSTANCE + PERIOD + name +
- OPEN_PARENTHESIS + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS + SPACE +
- OPEN_CURLY_BRACKET + NEW_LINE + SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + FALSE + SEMI_COLAN +
- NEW_LINE + TWELVE_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION
- + CLOSE_CURLY_BRACKET + NEW_LINE;
- }
-
- /**
- * Returns filter content match for list types.
- *
- * @param name name of node
- * @param isLeafList if for leaf list
- * @param type type of the attribute
- * @return filter content match for list types
- */
- private static String getIsFileContentMatchForLists(String name, boolean isLeafList, String type) {
- String method = EIGHT_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + getSmallCase(name) + OPEN_PARENTHESIS
- + CLOSE_PARENTHESIS + SPACE + NOT + EQUAL + SPACE + NULL + SPACE + AND + AND + SPACE + NOT +
- getSmallCase(name) + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD + IS_EMPTY +
- CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET
+ static String getIfConditionBegin(String indentation, String condition) {
+ return indentation + IF + SPACE + OPEN_PARENTHESIS + condition + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET
+ NEW_LINE;
- method = method + TWELVE_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + APP_INSTANCE + PERIOD +
- getSmallCase(name)
- + OPEN_PARENTHESIS
- + CLOSE_PARENTHESIS + SPACE + EQUAL + EQUAL + SPACE + NULL + SPACE + "||" + SPACE +
- getSmallCase(name) + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD + IS_EMPTY + CLOSE_PARENTHESIS +
- SPACE + OPEN_CURLY_BRACKET
- + NEW_LINE + SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + FALSE + SEMI_COLAN + NEW_LINE +
- TWELVE_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE;
- if (isLeafList) {
- if (type.equals(getSmallCase(STRING_DATA_TYPE))) {
- type = STRING_DATA_TYPE;
- }
- method = method + TWELVE_SPACE_INDENTATION + FOR + SPACE + OPEN_PARENTHESIS + type + SPACE +
- getSmallCase(name)
- + SPACE + COLAN + SPACE + getSmallCase(name) + OPEN_PARENTHESIS + CLOSE_PARENTHESIS +
- CLOSE_PARENTHESIS
- + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + SIXTEEN_SPACE_INDENTATION + BOOLEAN_DATA_TYPE + SPACE +
- FLAG + SPACE + EQUAL + SPACE + FALSE + SEMI_COLAN + NEW_LINE;
- method = method + SIXTEEN_SPACE_INDENTATION + FOR + SPACE + OPEN_PARENTHESIS + type + SPACE +
- TMP_VAR + getSmallCase(name)
- + SPACE + COLAN + SPACE + APP_INSTANCE + PERIOD + getSmallCase(name) + OPEN_PARENTHESIS
- + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
- method = method + TWENTY_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + getSmallCase(name) + PERIOD;
- } else {
- method = method + TWELVE_SPACE_INDENTATION + FOR + SPACE + OPEN_PARENTHESIS + name + SPACE +
- getSmallCase(name)
- + SPACE + COLAN + SPACE + getSmallCase(name) + OPEN_PARENTHESIS + CLOSE_PARENTHESIS +
- CLOSE_PARENTHESIS
- + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + SIXTEEN_SPACE_INDENTATION + BOOLEAN_DATA_TYPE + SPACE +
- FLAG + SPACE + EQUAL + SPACE + FALSE + SEMI_COLAN + NEW_LINE;
- method = method + SIXTEEN_SPACE_INDENTATION + FOR + SPACE + OPEN_PARENTHESIS + name + SPACE +
- TMP_VAR + getSmallCase(name)
- + SPACE + COLAN + SPACE + APP_INSTANCE + PERIOD + getSmallCase(name) + OPEN_PARENTHESIS
- + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
- method = method + TWENTY_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + getSmallCase(name) + PERIOD;
- }
- if (!isLeafList) {
- method = method + FILTER_CONTENT_MATCH;
- } else {
- method = method + EQUALS_STRING;
- }
- method = method + OPEN_PARENTHESIS + TMP_VAR + getSmallCase(name) + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS
- + SPACE +
- OPEN_CURLY_BRACKET + NEW_LINE + TWENTY_FOUR_SPACE_INDENTATION + FLAG + SPACE + EQUAL + SPACE + TRUE +
- SEMI_COLAN
- + NEW_LINE + TWENTY_FOUR_SPACE_INDENTATION + BREAK + SEMI_COLAN + NEW_LINE + TWENTY_SPACE_INDENTATION
- + CLOSE_CURLY_BRACKET + NEW_LINE + SIXTEEN_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE;
-
- method = method + SIXTEEN_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + NOT + FLAG
- + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + TWENTY_SPACE_INDENTATION
- + RETURN + SPACE + FALSE + SEMI_COLAN + NEW_LINE + SIXTEEN_SPACE_INDENTATION + CLOSE_CURLY_BRACKET +
- NEW_LINE;
- return method + TWELVE_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION +
- CLOSE_CURLY_BRACKET + NEW_LINE;
-
}
- //Returns method string for op params augmented syntax
- private static String getAugmentableOpParamSyntax() {
- return EIGHT_SPACE_INDENTATION + FOR + SPACE + OPEN_PARENTHESIS + OBJECT_STRING + SPACE +
- getSmallCase(YANG_AUGMENTED_INFO) + SPACE + COLAN + SPACE + THIS +
- PERIOD + getSmallCase(YANG_AUGMENTED_INFO) + MAP + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD
- + VALUE + "s" + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET +
- NEW_LINE + TWELVE_SPACE_INDENTATION + OBJECT_STRING + SPACE +
- getSmallCase(YANG_AUGMENTED_OP_PARAM_INFO) + SPACE + EQUAL + SPACE + APP_INSTANCE + PERIOD +
- getSmallCase(YANG_AUGMENTED_INFO) + OPEN_PARENTHESIS + APP_INSTANCE + PERIOD + GET_CLASS +
- CLOSE_PARENTHESIS + SEMI_COLAN +
- NEW_LINE + TWELVE_SPACE_INDENTATION
- + BOOLEAN_DATA_TYPE + SPACE + FILTER_CONTENT_MATCH + SPACE + EQUAL + SPACE + FALSE + SEMI_COLAN
- + NEW_LINE + TWELVE_SPACE_INDENTATION + TRY + SPACE + OPEN_CURLY_BRACKET + NEW_LINE +
- SIXTEEN_SPACE_INDENTATION +
- FILTER_CONTENT_MATCH + SPACE + EQUAL + SPACE + OPEN_PARENTHESIS
- + BOOLEAN_DATA_TYPE + CLOSE_PARENTHESIS + SPACE + getSmallCase(YANG_AUGMENTED_INFO) + PERIOD +
- GET_CLASS + NEW_LINE + TWENTY_SPACE_INDENTATION + PERIOD + GET_METHOD
- + OPEN_PARENTHESIS + QUOTES + FILTER_CONTENT_MATCH + QUOTES + COMMA + SPACE + OBJECT_STRING + PERIOD
- + CLASS + CLOSE_PARENTHESIS + PERIOD + INVOKE + OPEN_PARENTHESIS + getSmallCase(YANG_AUGMENTED_INFO) +
- NEW_LINE + TWENTY_FOUR_SPACE_INDENTATION + PERIOD + GET_CLASS + COMMA + SPACE +
- getSmallCase(YANG_AUGMENTED_OP_PARAM_INFO)
- + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE
- + TWELVE_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + SPACE + CATCH + SPACE + OPEN_PARENTHESIS
- + NO_SUCH_METHOD_EXCEPTION + " | " + INVOCATION_TARGET_EXCEPTION + " | " + ILLEGAL_ACCESS_EXCEPTION +
- SPACE + EXCEPTION_VAR + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE
- + SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + FALSE + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION
- + CLOSE_CURLY_BRACKET + NEW_LINE + TWELVE_SPACE_INDENTATION
- + IF + SPACE + OPEN_PARENTHESIS + NOT + FILTER_CONTENT_MATCH + CLOSE_PARENTHESIS +
- SPACE + OPEN_CURLY_BRACKET + NEW_LINE + SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + FALSE +
- SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION
- + CLOSE_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE;
+ static String getElseIfConditionBegin(String indentation, String condition) {
+ return indentation + CLOSE_CURLY_BRACKET + SPACE + ELSE + SPACE + getIfConditionBegin("", condition);
+ }
+
+ static String getBlockEnd(String indentation) {
+ return indentation + CLOSE_CURLY_BRACKET + NEW_LINE;
+ }
+
+ static String getCollectionIteratorForLoopBegin(String indentation, String loopVar, String collection) {
+ return indentation + FOR + SPACE + OPEN_PARENTHESIS + loopVar + SPACE + COLAN + SPACE + collection
+ + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
}
/*
@@ -1113,7 +846,8 @@
* @return from string method's body string
*/
public static String getFromStringMethod(JavaAttributeInfo attr,
- JavaAttributeInfo fromStringAttributeInfo) {
+ JavaAttributeInfo fromStringAttributeInfo) {
+
return EIGHT_SPACE_INDENTATION + getTrySubString() + NEW_LINE + TWELVE_SPACE_INDENTATION
+ getParsedSubString(attr, fromStringAttributeInfo) + NEW_LINE + TWELVE_SPACE_INDENTATION
+ getReturnOfSubString() + NEW_LINE + EIGHT_SPACE_INDENTATION + getCatchSubString()
@@ -1155,7 +889,8 @@
* @return sub string with parsed statement for union's from string method
*/
private static String getParsedSubString(JavaAttributeInfo attr,
- JavaAttributeInfo fromStringAttributeInfo) {
+ JavaAttributeInfo fromStringAttributeInfo) {
+
String targetDataType = getReturnType(attr);
if (fromStringAttributeInfo.getAttributeType().getDataType() == BITS) {
String lines = targetDataType + SPACE + TMP_VAL + SPACE + EQUAL + SPACE + NEW + SPACE + targetDataType
@@ -1289,6 +1024,7 @@
* @return equals method
*/
public static String getEqualsMethod(JavaAttributeInfo attr) {
+
String attributeName = attr.getAttributeName();
return SIXTEEN_SPACE_INDENTATION + SPACE + OBJECT_STRING + SUFFIX_S + PERIOD + EQUALS_STRING + OPEN_PARENTHESIS
+ attributeName + COMMA + SPACE + OTHER + PERIOD + attributeName + CLOSE_PARENTHESIS + SPACE + AND
@@ -1319,7 +1055,8 @@
* @return of method's string and java doc for special type
*/
public static String getOfMethodStringAndJavaDoc(JavaAttributeInfo attr, String generatedJavaClassName,
- YangPluginConfig pluginConfig) {
+ YangPluginConfig pluginConfig) {
+
String attrType = getReturnType(attr);
String attrName = attr.getAttributeName();
@@ -1350,8 +1087,9 @@
* @return string and java doc for constructor of type class
*/
public static String getTypeConstructorStringAndJavaDoc(JavaAttributeInfo attr,
- String generatedJavaClassName,
- YangPluginConfig pluginConfig) {
+ String generatedJavaClassName,
+ YangPluginConfig pluginConfig) {
+
String attrType = getReturnType(attr);
String attrName = attr.getAttributeName();
return getJavaDoc(TYPE_CONSTRUCTOR, generatedJavaClassName + " for type " + attrName, false, pluginConfig, null)
@@ -1371,7 +1109,8 @@
*/
public static String getTypeConstructorStringAndJavaDoc(JavaAttributeInfo attr1, JavaAttributeInfo
attr2, String generatedJavaClassName, YangPluginConfig pluginConfig, ValidatorTypeForUnionTypes type,
- boolean addFirst) {
+ boolean addFirst) {
+
String attrType = getReturnType(attr1);
String attrName1 = "";
String attrName2 = "";
@@ -1415,7 +1154,8 @@
* @return type constructor string
*/
private static String getTypeConstructorString(String type, String attr1, String attr2, String className,
- ValidatorTypeForUnionTypes validatorType, boolean addInt) {
+ ValidatorTypeForUnionTypes validatorType, boolean addInt) {
+
String constructor;
constructor = FOUR_SPACE_INDENTATION + PUBLIC + SPACE + className + OPEN_PARENTHESIS + type + SPACE + VALUE
+ CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
@@ -1545,8 +1285,8 @@
* @return of method
*/
static String getEnumsOfMethod(String className, JavaAttributeInfo attr,
- Map<String, Integer> enumMap, List<String> enumList,
- YangPluginConfig pluginConfig) {
+ Map<String, Integer> enumMap, List<String> enumList,
+ YangPluginConfig pluginConfig) {
String attrType = getReturnType(attr);
String attrName = attr.getAttributeName();
@@ -1557,6 +1297,7 @@
+ CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
int value;
for (String str : enumList) {
+
value = enumMap.get(str);
method = method + TWELVE_SPACE_INDENTATION + CASE + SPACE + value + COLON + NEW_LINE
+ SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + getCapitalCase(className) + PERIOD
@@ -1728,11 +1469,12 @@
/**
* Returns add to list method interface.
*
- * @param attr java attribute
+ * @param attr java attribute
+ * @param className name of the class
* @return add to list method interface
*/
- public static String getAddToListMethodInterface(JavaAttributeInfo attr) {
- return FOUR_SPACE_INDENTATION + VOID + SPACE + ADD_STRING + getCapitalCase(TO) +
+ public static String getAddToListMethodInterface(JavaAttributeInfo attr, String className) {
+ return FOUR_SPACE_INDENTATION + className + BUILDER + SPACE + ADD_STRING + getCapitalCase(TO) +
getCapitalCase(attr.getAttributeName()) + OPEN_PARENTHESIS + getReturnType(attr) + SPACE +
VALUE + CLOSE_PARENTHESIS + SEMI_COLAN;
}
@@ -1740,15 +1482,23 @@
/**
* Returns add to list method impl.
*
- * @param attr java attribute
+ * @param attr java attribute
+ * @param generatedJavaClassName class name
+ * @param isRoot is root
* @return add to list method impl
*/
- public static String getAddToListMethodImpl(JavaAttributeInfo attr) {
- return getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE + ADD_STRING +
+ public static String getAddToListMethodImpl(JavaAttributeInfo attr, String generatedJavaClassName, boolean isRoot) {
+ String retString = "";
+ if (!isRoot) {
+ retString = getOverRideString();
+ }
+ return retString + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + generatedJavaClassName + BUILDER + SPACE +
+ ADD_STRING +
getCapitalCase(TO) + getCapitalCase(attr.getAttributeName()) + OPEN_PARENTHESIS +
getReturnType(attr) + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET
+ NEW_LINE + EIGHT_SPACE_INDENTATION + attr.getAttributeName() + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
+ PERIOD + ADD_STRING + OPEN_PARENTHESIS + VALUE + CLOSE_PARENTHESIS + SEMI_COLAN +
+ NEW_LINE + EIGHT_SPACE_INDENTATION + RETURN + SPACE + THIS + SEMI_COLAN +
NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
}
@@ -1772,7 +1522,7 @@
* @param name name of node
* @return is filter content match interface
*/
- static String isFilterContentMatchInterface(String name) {
+ static String processSubtreeFilteringInterface(String name) {
String method = " /**\n" +
" * Checks if the passed " + name + " maps the content match query condition.\n" +
" *\n" +
@@ -1781,8 +1531,10 @@
" content match\n" +
" * @return match result\n" +
" */\n";
- return method + FOUR_SPACE_INDENTATION + BOOLEAN_DATA_TYPE + SPACE + FILTER_CONTENT_MATCH + OPEN_PARENTHESIS
- + name + SPACE + getSmallCase(name) + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
+ return method + FOUR_SPACE_INDENTATION + name + SPACE + PROCESS_SUBTREE_FILTERING +
+ OPEN_PARENTHESIS
+ + name + SPACE + getSmallCase(name) + COMMA + SPACE + BOOLEAN_DATA_TYPE + SPACE +
+ "isSelectAllSchemaChild" + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
}
/**
diff --git a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/SubtreeFilteringMethodsGenerator.java b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/SubtreeFilteringMethodsGenerator.java
new file mode 100644
index 0000000..f9af450
--- /dev/null
+++ b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/SubtreeFilteringMethodsGenerator.java
@@ -0,0 +1,739 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.translator.tojava.utils;
+
+import java.io.IOException;
+
+import org.onosproject.yangutils.datamodel.YangAugment;
+import org.onosproject.yangutils.datamodel.YangCase;
+import org.onosproject.yangutils.datamodel.YangChoice;
+import org.onosproject.yangutils.datamodel.YangLeafRef;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangType;
+import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo;
+import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
+import org.onosproject.yangutils.translator.tojava.JavaFileInfoTranslator;
+import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer;
+import org.onosproject.yangutils.utils.io.YangPluginConfig;
+
+import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.LEAFREF;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FILTER_CONTENT_MATCH_FOR_LEAF_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FILTER_CONTENT_MATCH_FOR_NODES_MASK;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getDataFromTempFileHandle;
+import static org.onosproject.yangutils.utils.UtilConstants.ADD_STRING;
+import static org.onosproject.yangutils.utils.UtilConstants.AND_OPERATION;
+import static org.onosproject.yangutils.utils.UtilConstants.APP_INSTANCE;
+import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_DATA_TYPE;
+import static org.onosproject.yangutils.utils.UtilConstants.BREAK;
+import static org.onosproject.yangutils.utils.UtilConstants.BUILD;
+import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
+import static org.onosproject.yangutils.utils.UtilConstants.CATCH;
+import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET;
+import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS;
+import static org.onosproject.yangutils.utils.UtilConstants.COLAN;
+import static org.onosproject.yangutils.utils.UtilConstants.COMMA;
+import static org.onosproject.yangutils.utils.UtilConstants.CONTINUE;
+import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION;
+import static org.onosproject.yangutils.utils.UtilConstants.ELSE;
+import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_PARAMETER_FUNCTION_CALL;
+import static org.onosproject.yangutils.utils.UtilConstants.EQUAL;
+import static org.onosproject.yangutils.utils.UtilConstants.EQUALS_STRING;
+import static org.onosproject.yangutils.utils.UtilConstants.EXCEPTION_VAR;
+import static org.onosproject.yangutils.utils.UtilConstants.FALSE;
+import static org.onosproject.yangutils.utils.UtilConstants.FOR;
+import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION;
+import static org.onosproject.yangutils.utils.UtilConstants.GET_CLASS;
+import static org.onosproject.yangutils.utils.UtilConstants.GET_LEAF_INDEX;
+import static org.onosproject.yangutils.utils.UtilConstants.GET_METHOD;
+import static org.onosproject.yangutils.utils.UtilConstants.GET_METHOD_PREFIX;
+import static org.onosproject.yangutils.utils.UtilConstants.GET_SELECT_LEAF_FLAGS;
+import static org.onosproject.yangutils.utils.UtilConstants.GET_VALUE_LEAF_FLAGS;
+import static org.onosproject.yangutils.utils.UtilConstants.IF;
+import static org.onosproject.yangutils.utils.UtilConstants.ILLEGAL_ACCESS_EXCEPTION;
+import static org.onosproject.yangutils.utils.UtilConstants.INSTANCE;
+import static org.onosproject.yangutils.utils.UtilConstants.INVOCATION_TARGET_EXCEPTION;
+import static org.onosproject.yangutils.utils.UtilConstants.INVOKE;
+import static org.onosproject.yangutils.utils.UtilConstants.IS_ANY_SELECT_OR_CONTAINMENT_NODE_FLAG;
+import static org.onosproject.yangutils.utils.UtilConstants.IS_EMPTY;
+import static org.onosproject.yangutils.utils.UtilConstants.IS_SELECT_ALL_SCHEMA_CHILD_FLAG;
+import static org.onosproject.yangutils.utils.UtilConstants.LEAF_IDENTIFIER;
+import static org.onosproject.yangutils.utils.UtilConstants.MAP;
+import static org.onosproject.yangutils.utils.UtilConstants.NEW;
+import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
+import static org.onosproject.yangutils.utils.UtilConstants.NOT;
+import static org.onosproject.yangutils.utils.UtilConstants.NO_SUCH_METHOD_EXCEPTION;
+import static org.onosproject.yangutils.utils.UtilConstants.NULL;
+import static org.onosproject.yangutils.utils.UtilConstants.OBJECT;
+import static org.onosproject.yangutils.utils.UtilConstants.OBJECT_STRING;
+import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET;
+import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS;
+import static org.onosproject.yangutils.utils.UtilConstants.OR_OPERATION;
+import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
+import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE;
+import static org.onosproject.yangutils.utils.UtilConstants.PROCESS_SUBTREE_FILTERING;
+import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC;
+import static org.onosproject.yangutils.utils.UtilConstants.QUOTES;
+import static org.onosproject.yangutils.utils.UtilConstants.RETURN;
+import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
+import static org.onosproject.yangutils.utils.UtilConstants.SIXTEEN_SPACE_INDENTATION;
+import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
+import static org.onosproject.yangutils.utils.UtilConstants.SUBTREE_FILTERING_RESULT_BUILDER;
+import static org.onosproject.yangutils.utils.UtilConstants.THIRTY_TWO_SPACE_INDENTATION;
+import static org.onosproject.yangutils.utils.UtilConstants.THIS;
+import static org.onosproject.yangutils.utils.UtilConstants.TO;
+import static org.onosproject.yangutils.utils.UtilConstants.TRUE;
+import static org.onosproject.yangutils.utils.UtilConstants.TRY;
+import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTATION;
+import static org.onosproject.yangutils.utils.UtilConstants.TWENTY_EIGHT_SPACE_INDENTATION;
+import static org.onosproject.yangutils.utils.UtilConstants.TWENTY_FOUR_SPACE_INDENTATION;
+import static org.onosproject.yangutils.utils.UtilConstants.TWENTY_SPACE_INDENTATION;
+import static org.onosproject.yangutils.utils.UtilConstants.VALUE;
+import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO;
+import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_OP_PARAM_INFO;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase;
+
+/**
+ * Represents generator for subtree filtering methods of generated files based on the file type.
+ */
+public final class SubtreeFilteringMethodsGenerator {
+
+ /**
+ * private to make it a util.
+ */
+ private SubtreeFilteringMethodsGenerator() {
+ }
+
+ /**
+ * Returns is filter content match for leaf.
+ *
+ * @param javaAttributeInfo java attribute
+ * @param type data type
+ * @return is filter content match for leaf
+ */
+ public static String getSubtreeFilteringForLeaf(JavaAttributeInfo javaAttributeInfo, YangType<?> type) {
+ String attrQualifiedType;
+ String attributeName = javaAttributeInfo.getAttributeName();
+ attrQualifiedType = getIfFilterContentMatchMethodImpl(attributeName,
+ type);
+ return EIGHT_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS
+ + GET_VALUE_LEAF_FLAGS + EMPTY_PARAMETER_FUNCTION_CALL + PERIOD + GET_METHOD_PREFIX
+ + OPEN_PARENTHESIS + LEAF_IDENTIFIER + PERIOD + attributeName.toUpperCase() + PERIOD
+ + GET_LEAF_INDEX + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS
+ + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + TWELVE_SPACE_INDENTATION + IF + SPACE
+ + OPEN_PARENTHESIS + attrQualifiedType + CLOSE_PARENTHESIS + SPACE
+ + OPEN_CURLY_BRACKET + NEW_LINE + SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + FALSE
+ + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + SPACE + ELSE + SPACE
+ + OPEN_CURLY_BRACKET + NEW_LINE + SIXTEEN_SPACE_INDENTATION
+ + SUBTREE_FILTERING_RESULT_BUILDER + PERIOD + attributeName + OPEN_PARENTHESIS + APP_INSTANCE
+ + PERIOD + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS
+ + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE
+ + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + SPACE + ELSE + SPACE + IF + SPACE + OPEN_PARENTHESIS
+ + GET_SELECT_LEAF_FLAGS + EMPTY_PARAMETER_FUNCTION_CALL + PERIOD + GET_METHOD_PREFIX + OPEN_PARENTHESIS
+ + LEAF_IDENTIFIER + PERIOD + attributeName.toUpperCase() + PERIOD + GET_LEAF_INDEX + CLOSE_PARENTHESIS
+ + SPACE + OR_OPERATION + SPACE + IS_SELECT_ALL_SCHEMA_CHILD_FLAG + CLOSE_PARENTHESIS + SPACE
+ + OPEN_CURLY_BRACKET + NEW_LINE + TWELVE_SPACE_INDENTATION + IS_ANY_SELECT_OR_CONTAINMENT_NODE_FLAG
+ + SPACE + EQUAL + SPACE + TRUE + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION
+ + SUBTREE_FILTERING_RESULT_BUILDER + PERIOD + attributeName + OPEN_PARENTHESIS + APP_INSTANCE
+ + PERIOD + attributeName + EMPTY_PARAMETER_FUNCTION_CALL + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE
+ + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE;
+ }
+
+ private static String getAttrTypeForFilterContentMatchWhenPrimitiveDataType(String attributeName) {
+ return /* TODO: Need to check if we can expose the value leaf flag in interface.
+ NOT + APP_INSTANCE + PERIOD + GET_VALUE_LEAF_FLAGS + OPEN_PARENTHESIS + CLOSE_PARENTHESIS +
+ GET_METHOD_PREFIX + OPEN_PARENTHESIS + LEAF_IDENTIFIER + PERIOD + attributeName.toUpperCase() + PERIOD
+ + GET_LEAF_INDEX + OR_OPERATION +*/
+ APP_INSTANCE + PERIOD + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + NOT + EQUAL
+ + SPACE + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS;
+ }
+
+ private static String getAttrTypeForFilterContentMatchWhenNonPrimitiveDataTypes(String attributeName) {
+ return APP_INSTANCE + PERIOD + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
+ + SPACE + EQUAL + EQUAL + SPACE + NULL + SPACE + OR_OPERATION + SPACE
+ + NOT + OPEN_PARENTHESIS + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
+ + PERIOD + EQUALS_STRING + OPEN_PARENTHESIS + APP_INSTANCE + PERIOD
+ + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
+ + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS;
+ }
+
+ private static String getIfFilterContentMatchMethodImpl(String attributeName,
+ YangType dataType) {
+ String attrQualifiedType;
+
+ if (MethodsGenerator.isPrimitiveDataType(dataType.getDataType())) {
+ attrQualifiedType = getAttrTypeForFilterContentMatchWhenPrimitiveDataType(attributeName);
+ } else if (dataType.getDataType() == LEAFREF) {
+ YangType type = ((YangLeafRef) dataType.getDataTypeExtendedInfo()).getEffectiveDataType();
+ if (MethodsGenerator.isPrimitiveDataType(type.getDataType())) {
+ attrQualifiedType = getAttrTypeForFilterContentMatchWhenPrimitiveDataType(attributeName);
+ } else {
+ attrQualifiedType = getAttrTypeForFilterContentMatchWhenNonPrimitiveDataTypes(attributeName);
+ }
+ } else {
+ attrQualifiedType = getAttrTypeForFilterContentMatchWhenNonPrimitiveDataTypes(attributeName);
+ }
+
+ return attrQualifiedType;
+ }
+
+ /**
+ * Returns is filter content match for leaf.
+ *
+ * @param javaAttributeInfo java attribute
+ * @return is filter content match for leaf
+ */
+ public static String getSubtreeFilteringForLeafList(JavaAttributeInfo javaAttributeInfo) {
+ return getSubtreeFilteringForList(javaAttributeInfo, true);
+ }
+
+ /**
+ * Returns is filter content match for child node.
+ *
+ * @param curNode current node
+ * @param pluginConfig plugin configurations
+ * @param path path of temp file
+ * @return is filter content match for child node
+ */
+ static String getProcessChildNodeSubtreeFiltering(YangNode curNode, YangPluginConfig pluginConfig, String path)
+ throws IOException {
+ JavaFileInfoTranslator javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
+ JavaFileInfoTranslator parentInfo;
+
+ String instance = APP_INSTANCE;
+ String name = getCapitalCase(javaFileInfo.getJavaName());
+ String builderNamePrefix = getCapitalCase(javaFileInfo.getJavaName());
+ if (curNode instanceof YangCase) {
+ instance = INSTANCE;
+ YangNode parent = curNode.getParent();
+ if (parent instanceof YangChoice) {
+ parentInfo = ((JavaFileInfoContainer) parent).getJavaFileInfo();
+ name = getCapitalCase(parentInfo.getJavaName());
+ } else if (parent instanceof YangAugment) {
+ parentInfo = ((JavaFileInfoContainer) ((YangAugment) parent).getAugmentedNode()).getJavaFileInfo();
+ if (parentInfo != null) {
+ name = getCapitalCase(parentInfo.getJavaName());
+ } else {
+ name = getCapitalCase(getCamelCase(((YangAugment) parent).getAugmentedNode().getName(),
+ pluginConfig.getConflictResolver()));
+ }
+ }
+ }
+
+ String processSubtreeFilteringMethod =
+ FOUR_SPACE_INDENTATION + PRIVATE + SPACE + BOOLEAN_DATA_TYPE + SPACE
+ + "processChildNodesSubTreeFiltering" + OPEN_PARENTHESIS + name + SPACE + instance + COMMA
+ + SPACE + builderNamePrefix + BUILDER + SPACE + "subTreeFilteringResultBuilder"
+ + COMMA + NEW_LINE + TWELVE_SPACE_INDENTATION + "Boolean isAnySelectOrContainmentNode, "
+ + "boolean isSelectAllSchemaChild" + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
+
+ if (curNode instanceof YangCase) {
+ String caseName = getCapitalCase(javaFileInfo.getJavaName());
+ processSubtreeFilteringMethod =
+ processSubtreeFilteringMethod + EIGHT_SPACE_INDENTATION + caseName + SPACE + APP_INSTANCE + SPACE +
+ EQUAL + SPACE + OPEN_PARENTHESIS + caseName + CLOSE_PARENTHESIS + SPACE + instance
+ + SEMI_COLAN + NEW_LINE;
+ }
+
+ processSubtreeFilteringMethod += getDataFromTempFileHandle(FILTER_CONTENT_MATCH_FOR_NODES_MASK,
+ ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
+ .getBeanTempFiles(), path);
+
+ processSubtreeFilteringMethod += EIGHT_SPACE_INDENTATION + RETURN + SPACE + TRUE + SEMI_COLAN + NEW_LINE
+ + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE + NEW_LINE;
+
+ return processSubtreeFilteringMethod;
+ }
+
+ /**
+ * Returns is filter content match for leaf list.
+ *
+ * @param curNode current node
+ * @param pluginConfig plugin configurations
+ * @param path path of temp file
+ * @return is filter content match for leaf list
+ */
+ static String getProcessLeafListSubtreeFiltering(YangNode curNode, YangPluginConfig pluginConfig, String path)
+ throws IOException {
+ JavaFileInfoTranslator javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
+ JavaFileInfoTranslator parentInfo;
+
+ String instance = APP_INSTANCE;
+ String name = getCapitalCase(javaFileInfo.getJavaName());
+ String builderNamePrefix = getCapitalCase(javaFileInfo.getJavaName());
+ if (curNode instanceof YangCase) {
+ instance = INSTANCE;
+ YangNode parent = curNode.getParent();
+ if (parent instanceof YangChoice) {
+ parentInfo = ((JavaFileInfoContainer) parent).getJavaFileInfo();
+ name = getCapitalCase(parentInfo.getJavaName());
+ } else if (parent instanceof YangAugment) {
+ parentInfo = ((JavaFileInfoContainer) ((YangAugment) parent).getAugmentedNode()).getJavaFileInfo();
+ if (parentInfo != null) {
+ name = getCapitalCase(parentInfo.getJavaName());
+ } else {
+ name = getCapitalCase(getCamelCase(((YangAugment) parent).getAugmentedNode().getName(),
+ pluginConfig.getConflictResolver()));
+ }
+ }
+ }
+
+ String processSubtreeFilteringMethod =
+ FOUR_SPACE_INDENTATION + PRIVATE + SPACE + BOOLEAN_DATA_TYPE + SPACE +
+ "processLeafListSubTreeFiltering" + OPEN_PARENTHESIS + name + SPACE + instance + COMMA
+ + SPACE + builderNamePrefix + BUILDER + SPACE + "subTreeFilteringResultBuilder" + COMMA
+ + NEW_LINE + TWELVE_SPACE_INDENTATION + "Boolean isAnySelectOrContainmentNode, "
+ + "boolean isSelectAllSchemaChild" + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
+
+ if (curNode instanceof YangCase) {
+ String caseName = getCapitalCase(javaFileInfo.getJavaName());
+ processSubtreeFilteringMethod =
+ processSubtreeFilteringMethod + EIGHT_SPACE_INDENTATION + caseName + SPACE + APP_INSTANCE + SPACE +
+ EQUAL + SPACE + OPEN_PARENTHESIS + caseName + CLOSE_PARENTHESIS + SPACE + instance
+ + SEMI_COLAN + NEW_LINE;
+ }
+
+ processSubtreeFilteringMethod += getDataFromTempFileHandle(FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK,
+ ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
+ .getBeanTempFiles(), path);
+
+ processSubtreeFilteringMethod += EIGHT_SPACE_INDENTATION + RETURN + SPACE + TRUE + SEMI_COLAN + NEW_LINE
+ + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE + NEW_LINE;
+
+ return processSubtreeFilteringMethod;
+ }
+
+ /**
+ * Returns is filter content match for leaf.
+ *
+ * @param curNode current node
+ * @param pluginConfig plugin configurations
+ * @param path path of temp file
+ * @return is filter content match for leaf
+ */
+ static String getProcessLeafSubtreeFiltering(YangNode curNode, YangPluginConfig pluginConfig, String path)
+ throws IOException {
+ JavaFileInfoTranslator javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
+ JavaFileInfoTranslator parentInfo;
+
+ String instance = APP_INSTANCE;
+ String name = getCapitalCase(javaFileInfo.getJavaName());
+ String builderNamePrefix = getCapitalCase(javaFileInfo.getJavaName());
+ if (curNode instanceof YangCase) {
+ instance = INSTANCE;
+ YangNode parent = curNode.getParent();
+ if (parent instanceof YangChoice) {
+ parentInfo = ((JavaFileInfoContainer) parent).getJavaFileInfo();
+ name = getCapitalCase(parentInfo.getJavaName());
+ } else if (parent instanceof YangAugment) {
+ parentInfo = ((JavaFileInfoContainer) ((YangAugment) parent).getAugmentedNode()).getJavaFileInfo();
+ if (parentInfo != null) {
+ name = getCapitalCase(parentInfo.getJavaName());
+ } else {
+ name = getCapitalCase(getCamelCase(((YangAugment) parent).getAugmentedNode().getName(),
+ pluginConfig.getConflictResolver()));
+ }
+ }
+ }
+
+ String processSubtreeFilteringMethod =
+ FOUR_SPACE_INDENTATION + PRIVATE + SPACE + BOOLEAN_DATA_TYPE + SPACE + "processLeafSubtreeFiltering" +
+ OPEN_PARENTHESIS + name + SPACE + instance + COMMA + SPACE + builderNamePrefix
+ + BUILDER + SPACE + "subTreeFilteringResultBuilder" + COMMA + NEW_LINE
+ + TWELVE_SPACE_INDENTATION + "Boolean isAnySelectOrContainmentNode, "
+ + "boolean isSelectAllSchemaChild" + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
+
+ if (curNode instanceof YangCase) {
+ String caseName = getCapitalCase(javaFileInfo.getJavaName());
+ processSubtreeFilteringMethod =
+ processSubtreeFilteringMethod + EIGHT_SPACE_INDENTATION + caseName + SPACE + APP_INSTANCE + SPACE +
+ EQUAL + SPACE + OPEN_PARENTHESIS + caseName + CLOSE_PARENTHESIS + SPACE + instance
+ + SEMI_COLAN + NEW_LINE;
+ }
+
+ processSubtreeFilteringMethod += getDataFromTempFileHandle(FILTER_CONTENT_MATCH_FOR_LEAF_MASK,
+ ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
+ .getBeanTempFiles(), path);
+
+ processSubtreeFilteringMethod += EIGHT_SPACE_INDENTATION + RETURN + SPACE + TRUE + SEMI_COLAN + NEW_LINE
+ + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE + NEW_LINE;
+
+ return processSubtreeFilteringMethod;
+ }
+
+ /**
+ * Returns is filter content match for leaf.
+ *
+ * @param curNode current node
+ * @param pluginConfig plugin configurations
+ * @return is filter content match for leaf
+ */
+ static String getProcessSubtreeFilteringStart(YangNode curNode, YangPluginConfig pluginConfig) {
+ JavaFileInfoTranslator javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
+ JavaFileInfoTranslator parentInfo;
+
+ String instance = APP_INSTANCE;
+ String name = getCapitalCase(javaFileInfo.getJavaName());
+ String builderNamePrefix = getCapitalCase(javaFileInfo.getJavaName());
+ if (curNode instanceof YangCase) {
+ instance = INSTANCE;
+ YangNode parent = curNode.getParent();
+ if (parent instanceof YangChoice) {
+ parentInfo = ((JavaFileInfoContainer) parent).getJavaFileInfo();
+ name = getCapitalCase(parentInfo.getJavaName());
+ } else if (parent instanceof YangAugment) {
+ parentInfo = ((JavaFileInfoContainer) ((YangAugment) parent).getAugmentedNode()).getJavaFileInfo();
+ if (parentInfo != null) {
+ name = getCapitalCase(parentInfo.getJavaName());
+ } else {
+ name = getCapitalCase(getCamelCase(((YangAugment) parent).getAugmentedNode().getName(),
+ pluginConfig.getConflictResolver()));
+ }
+ }
+ }
+ String processSubtreeFilteringMethod =
+ MethodsGenerator.getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE +
+ name + SPACE + PROCESS_SUBTREE_FILTERING + OPEN_PARENTHESIS + name
+ + SPACE + instance + COMMA + SPACE + BOOLEAN_DATA_TYPE + SPACE + "isSelectAllSchemaChild" +
+ CLOSE_PARENTHESIS + SPACE
+ + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + builderNamePrefix
+ + BUILDER + SPACE + SUBTREE_FILTERING_RESULT_BUILDER + SPACE + EQUAL + SPACE + NEW + SPACE
+ + builderNamePrefix + BUILDER + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE
+ + EIGHT_SPACE_INDENTATION + "Boolean" + SPACE + IS_ANY_SELECT_OR_CONTAINMENT_NODE_FLAG
+ + SPACE + EQUAL + SPACE + FALSE + SEMI_COLAN + NEW_LINE;
+
+ if (curNode instanceof YangCase) {
+ String caseName = getCapitalCase(javaFileInfo.getJavaName());
+ processSubtreeFilteringMethod =
+ processSubtreeFilteringMethod + EIGHT_SPACE_INDENTATION + caseName + SPACE + APP_INSTANCE + SPACE +
+ EQUAL + SPACE + OPEN_PARENTHESIS + caseName + CLOSE_PARENTHESIS + SPACE + instance
+ + SEMI_COLAN + NEW_LINE;
+ }
+
+ return processSubtreeFilteringMethod;
+ }
+
+ /**
+ * Get the body for process subtree filtering.
+ *
+ * @return body of subtree filtering
+ */
+ static String getProcessSubtreeFunctionBody() {
+ String method = MethodsGenerator.getIfConditionBegin(EIGHT_SPACE_INDENTATION, NOT
+ + "processLeafSubtreeFiltering(appInstance, subTreeFilteringResultBuilder,"
+ + NEW_LINE + TWELVE_SPACE_INDENTATION + "isAnySelectOrContainmentNode, isSelectAllSchemaChild)");
+
+ method += TWELVE_SPACE_INDENTATION + RETURN + SPACE + NULL + SEMI_COLAN + NEW_LINE;
+
+ method += MethodsGenerator.getBlockEnd(EIGHT_SPACE_INDENTATION);
+
+ method += MethodsGenerator.getIfConditionBegin(EIGHT_SPACE_INDENTATION, NOT
+ + "processLeafListSubTreeFiltering(appInstance, subTreeFilteringResultBuilder,"
+ + NEW_LINE + TWELVE_SPACE_INDENTATION + "isAnySelectOrContainmentNode, isSelectAllSchemaChild)");
+
+ method += TWELVE_SPACE_INDENTATION + RETURN + SPACE + NULL + SEMI_COLAN + NEW_LINE;
+
+ method += MethodsGenerator.getBlockEnd(EIGHT_SPACE_INDENTATION);
+
+ method += MethodsGenerator.getIfConditionBegin(EIGHT_SPACE_INDENTATION, NOT
+ + "processChildNodesSubTreeFiltering(appInstance, subTreeFilteringResultBuilder,"
+ + NEW_LINE + TWELVE_SPACE_INDENTATION + "isAnySelectOrContainmentNode, isSelectAllSchemaChild)");
+
+ method += TWELVE_SPACE_INDENTATION + RETURN + SPACE + NULL + SEMI_COLAN + NEW_LINE;
+
+ method += MethodsGenerator.getBlockEnd(EIGHT_SPACE_INDENTATION);
+
+ return method;
+ }
+
+ /**
+ * Returns is filter content match for node.
+ *
+ * @param attr attribute info
+ * @return is filter content match for node
+ */
+ public static String getSubtreeFilteringForNode(JavaAttributeInfo attr) {
+ boolean isList = attr.isListAttr();
+ if (isList) {
+ return getSubtreeFilteringForList(attr, false);
+ } else {
+ return getSubtreeFilteringForChildNode(attr);
+ }
+ }
+
+ /**
+ * Returns is filter content match close.
+ *
+ * @return is filter content match close
+ */
+ static String getProcessSubTreeFilteringEnd() {
+ String method = MethodsGenerator
+ .getIfConditionBegin(EIGHT_SPACE_INDENTATION, NOT + IS_SELECT_ALL_SCHEMA_CHILD_FLAG
+ + SPACE + AND_OPERATION + SPACE + NOT + IS_ANY_SELECT_OR_CONTAINMENT_NODE_FLAG);
+
+ method += TWELVE_SPACE_INDENTATION + RETURN + SPACE + PROCESS_SUBTREE_FILTERING + OPEN_PARENTHESIS
+ + APP_INSTANCE + COMMA + SPACE + TRUE + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
+
+ method += MethodsGenerator.getBlockEnd(EIGHT_SPACE_INDENTATION);
+
+ method += EIGHT_SPACE_INDENTATION + RETURN + SPACE + SUBTREE_FILTERING_RESULT_BUILDER + PERIOD + BUILD
+ + EMPTY_PARAMETER_FUNCTION_CALL + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION
+ + CLOSE_CURLY_BRACKET + NEW_LINE;
+
+ return method;
+ }
+
+ /**
+ * Returns filter content match for child nodes.
+ *
+ * @param javaAttributeInfo attribute to be added
+ * @return filter content match for child nodes
+ */
+ private static String getSubtreeFilteringForChildNode(JavaAttributeInfo javaAttributeInfo) {
+ String name = javaAttributeInfo.getAttributeName();
+ name = getSmallCase(name);
+ String type = javaAttributeInfo.getImportInfo().getClassInfo();
+ if (javaAttributeInfo.isQualifiedName()) {
+ type = javaAttributeInfo.getImportInfo().getPkgInfo() + PERIOD + type;
+ }
+
+ String method = MethodsGenerator.getIfConditionBegin(EIGHT_SPACE_INDENTATION, name + "() != null");
+
+ method += TWELVE_SPACE_INDENTATION + IS_ANY_SELECT_OR_CONTAINMENT_NODE_FLAG + SPACE + EQUAL + SPACE + TRUE
+ + SEMI_COLAN + NEW_LINE;
+
+ method += TWELVE_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + APP_INSTANCE
+ + PERIOD + name + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + NOT
+ + EQUAL + SPACE + NULL + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
+
+
+ method += SIXTEEN_SPACE_INDENTATION + type + SPACE + "result = " + name + PERIOD +
+ PROCESS_SUBTREE_FILTERING + OPEN_PARENTHESIS + APP_INSTANCE + PERIOD + name
+ + EMPTY_PARAMETER_FUNCTION_CALL + COMMA + SPACE + FALSE + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
+
+ method += SIXTEEN_SPACE_INDENTATION + "if (result != null) {" + NEW_LINE;
+
+ method += TWENTY_SPACE_INDENTATION + SUBTREE_FILTERING_RESULT_BUILDER + PERIOD + name + OPEN_PARENTHESIS
+ + "result" + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE + SIXTEEN_SPACE_INDENTATION +
+ CLOSE_CURLY_BRACKET + NEW_LINE;
+
+ //if app instance is not null
+ method += MethodsGenerator.getBlockEnd(TWELVE_SPACE_INDENTATION);
+
+ //if query instance is not null
+ method += MethodsGenerator.getBlockEnd(EIGHT_SPACE_INDENTATION);
+
+ return method;
+ }
+
+ /**
+ * Returns filter content match for list types.
+ *
+ * @param javaAttributeInfo attribute information
+ * @param isLeafList if for leaf list
+ * @return filter content match for list types
+ */
+ private static String getSubtreeFilteringForList(JavaAttributeInfo javaAttributeInfo, boolean isLeafList) {
+ String capitalCaseName = getCapitalCase(javaAttributeInfo.getAttributeName());
+ String name = javaAttributeInfo.getAttributeName();
+ String type = javaAttributeInfo.getImportInfo().getClassInfo();
+ if (javaAttributeInfo.isQualifiedName()) {
+ type = javaAttributeInfo.getImportInfo().getPkgInfo() + PERIOD + type;
+ }
+
+ /*
+ * If select all schema child
+ */
+ String method = MethodsGenerator.getIfConditionBegin(EIGHT_SPACE_INDENTATION, IS_SELECT_ALL_SCHEMA_CHILD_FLAG);
+
+ method = method + MethodsGenerator.getCollectionIteratorForLoopBegin(TWELVE_SPACE_INDENTATION,
+ type + SPACE + name, APP_INSTANCE + PERIOD + name + EMPTY_PARAMETER_FUNCTION_CALL);
+
+ method = method + SIXTEEN_SPACE_INDENTATION + SUBTREE_FILTERING_RESULT_BUILDER + PERIOD + ADD_STRING
+ + getCapitalCase(TO) + capitalCaseName + OPEN_PARENTHESIS + name + CLOSE_PARENTHESIS + SEMI_COLAN
+ + NEW_LINE;
+
+ method += MethodsGenerator.getBlockEnd(TWELVE_SPACE_INDENTATION); // Close collection Iteration loop
+
+ //If need to explicitly participate in query
+ method += MethodsGenerator
+ .getElseIfConditionBegin(EIGHT_SPACE_INDENTATION, name + EMPTY_PARAMETER_FUNCTION_CALL + SPACE + NOT
+ + EQUAL + SPACE + NULL);
+
+ if (!isLeafList) {
+ method += TWELVE_SPACE_INDENTATION + IS_ANY_SELECT_OR_CONTAINMENT_NODE_FLAG + SPACE + EQUAL + SPACE
+ + TRUE + SEMI_COLAN + NEW_LINE;
+ }
+
+ //If there is any parameter in the query condition
+ method += MethodsGenerator
+ .getIfConditionBegin(TWELVE_SPACE_INDENTATION, NOT + name + EMPTY_PARAMETER_FUNCTION_CALL + PERIOD
+ + IS_EMPTY);
+
+ if (isLeafList) {
+ /*
+ * If there is no app instance to perform content match
+ */
+ method += MethodsGenerator.getIfConditionBegin(SIXTEEN_SPACE_INDENTATION, APP_INSTANCE + PERIOD + name
+ + EMPTY_PARAMETER_FUNCTION_CALL + SPACE + EQUAL + EQUAL + SPACE + NULL + SPACE + OR_OPERATION
+ + SPACE + APP_INSTANCE + PERIOD + name + EMPTY_PARAMETER_FUNCTION_CALL + PERIOD + IS_EMPTY);
+
+ method += TWENTY_SPACE_INDENTATION + RETURN + SPACE + FALSE + SEMI_COLAN + NEW_LINE;
+
+ method += MethodsGenerator.getBlockEnd(SIXTEEN_SPACE_INDENTATION);
+
+ // for instance iterator
+ method += MethodsGenerator.getCollectionIteratorForLoopBegin(SIXTEEN_SPACE_INDENTATION, type + SPACE + name,
+ name + EMPTY_PARAMETER_FUNCTION_CALL);
+
+ method += TWENTY_SPACE_INDENTATION + BOOLEAN_DATA_TYPE + SPACE + "flag" + SPACE + EQUAL
+ + SPACE + FALSE + SEMI_COLAN + NEW_LINE;
+
+ // for app instance iterator
+ method += MethodsGenerator.getCollectionIteratorForLoopBegin(TWENTY_SPACE_INDENTATION,
+ type + SPACE + name + "2", APP_INSTANCE + PERIOD + name + EMPTY_PARAMETER_FUNCTION_CALL);
+
+ //the content match leaf list attribute value matches
+ method += MethodsGenerator.getIfConditionBegin(TWENTY_FOUR_SPACE_INDENTATION, name + PERIOD + EQUALS_STRING
+ + OPEN_PARENTHESIS + name + "2" + CLOSE_PARENTHESIS);
+
+ method += TWENTY_EIGHT_SPACE_INDENTATION + "flag" + SPACE + EQUAL + SPACE + TRUE + SEMI_COLAN + NEW_LINE;
+
+ method += TWENTY_EIGHT_SPACE_INDENTATION + SUBTREE_FILTERING_RESULT_BUILDER + PERIOD + ADD_STRING +
+ getCapitalCase(TO) + capitalCaseName + OPEN_PARENTHESIS + name + "2" + CLOSE_PARENTHESIS +
+ SEMI_COLAN + NEW_LINE + TWENTY_EIGHT_SPACE_INDENTATION + BREAK + SEMI_COLAN + NEW_LINE;
+
+ //the content match leaf list attribute value matches
+ method += MethodsGenerator.getBlockEnd(TWENTY_FOUR_SPACE_INDENTATION);
+
+ // for app instance iterator
+ method += MethodsGenerator.getBlockEnd(TWENTY_SPACE_INDENTATION);
+
+ //if the content match failed
+ method += MethodsGenerator.getIfConditionBegin(TWENTY_SPACE_INDENTATION, "!flag");
+
+ method += TWENTY_FOUR_SPACE_INDENTATION + RETURN + SPACE + FALSE + SEMI_COLAN + NEW_LINE;
+
+ method += MethodsGenerator.getBlockEnd(TWENTY_SPACE_INDENTATION); // if flag == false
+
+ method += MethodsGenerator.getBlockEnd(SIXTEEN_SPACE_INDENTATION); // for instance iterator
+
+
+ } else {
+
+ /*if there is any app instance entry*/
+ method += MethodsGenerator.getIfConditionBegin(SIXTEEN_SPACE_INDENTATION, APP_INSTANCE + PERIOD + name
+ + EMPTY_PARAMETER_FUNCTION_CALL + SPACE + NOT + EQUAL + SPACE + NULL + SPACE + AND_OPERATION + SPACE
+ + NOT + APP_INSTANCE + PERIOD + name + EMPTY_PARAMETER_FUNCTION_CALL + PERIOD + IS_EMPTY);
+
+ /*
+ * loop all the query condition instance(s)
+ */
+ method += MethodsGenerator.getCollectionIteratorForLoopBegin(TWENTY_SPACE_INDENTATION, type + SPACE + name,
+ name + EMPTY_PARAMETER_FUNCTION_CALL);
+
+ //loop all the app instance(s)
+ method += MethodsGenerator.getCollectionIteratorForLoopBegin(TWENTY_FOUR_SPACE_INDENTATION,
+ type + SPACE + name + "2", APP_INSTANCE + PERIOD + name + EMPTY_PARAMETER_FUNCTION_CALL);
+
+ method += TWENTY_EIGHT_SPACE_INDENTATION + type + SPACE + "result = " + name + PERIOD +
+ PROCESS_SUBTREE_FILTERING + OPEN_PARENTHESIS + name + "2" + COMMA
+ + SPACE + FALSE + CLOSE_PARENTHESIS + SEMI_COLAN
+ + NEW_LINE;
+
+ method += TWENTY_EIGHT_SPACE_INDENTATION + "if (result != null) {" + NEW_LINE;
+
+ method += THIRTY_TWO_SPACE_INDENTATION + SUBTREE_FILTERING_RESULT_BUILDER + PERIOD + ADD_STRING +
+ getCapitalCase(TO) + capitalCaseName + OPEN_PARENTHESIS + "result" + CLOSE_PARENTHESIS +
+ SEMI_COLAN + NEW_LINE + TWENTY_EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE;
+
+ //loop all the app instance(s)
+ method += MethodsGenerator.getBlockEnd(TWENTY_FOUR_SPACE_INDENTATION);
+
+ //loop all the query condition instance(s)
+ method += MethodsGenerator.getBlockEnd(TWENTY_SPACE_INDENTATION);
+
+ //if there is any app instance entry
+ method += MethodsGenerator.getBlockEnd(SIXTEEN_SPACE_INDENTATION);
+ }
+
+ method += TWELVE_SPACE_INDENTATION + "} else {" + NEW_LINE;
+
+ if (isLeafList) {
+ method += SIXTEEN_SPACE_INDENTATION + IS_ANY_SELECT_OR_CONTAINMENT_NODE_FLAG + SPACE + EQUAL
+ + SPACE + TRUE + SEMI_COLAN + NEW_LINE;
+ }
+
+ method += MethodsGenerator.getIfConditionBegin(SIXTEEN_SPACE_INDENTATION, APP_INSTANCE + PERIOD + name
+ + EMPTY_PARAMETER_FUNCTION_CALL + SPACE + NOT + EQUAL + SPACE + NULL + SPACE + AND_OPERATION + SPACE
+ + NOT + APP_INSTANCE + PERIOD + name + EMPTY_PARAMETER_FUNCTION_CALL + PERIOD + IS_EMPTY);
+
+ method = method + MethodsGenerator.getCollectionIteratorForLoopBegin(TWENTY_SPACE_INDENTATION,
+ type + SPACE + name, APP_INSTANCE + PERIOD + name + EMPTY_PARAMETER_FUNCTION_CALL);
+
+ method = method + TWENTY_FOUR_SPACE_INDENTATION + SUBTREE_FILTERING_RESULT_BUILDER + PERIOD + ADD_STRING
+ + getCapitalCase(TO) + capitalCaseName + OPEN_PARENTHESIS + name + CLOSE_PARENTHESIS + SEMI_COLAN
+ + NEW_LINE;
+
+ method += MethodsGenerator.getBlockEnd(TWENTY_SPACE_INDENTATION); // Close collection Iteration loop
+
+ method += MethodsGenerator.getBlockEnd(SIXTEEN_SPACE_INDENTATION); // close if condition
+
+ method += MethodsGenerator.getBlockEnd(TWELVE_SPACE_INDENTATION); // close else condition
+
+ method += MethodsGenerator.getBlockEnd(EIGHT_SPACE_INDENTATION); // close else if condition
+
+ return method;
+
+ }
+
+ //Returns method string for op params augmented syntax
+ static String getAugmentableSubTreeFiltering() {
+ return EIGHT_SPACE_INDENTATION + FOR + SPACE + OPEN_PARENTHESIS + OBJECT_STRING + SPACE +
+ getSmallCase(YANG_AUGMENTED_INFO) + SPACE + COLAN + SPACE + THIS +
+ PERIOD + getSmallCase(YANG_AUGMENTED_INFO) + MAP + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD
+ + VALUE + "s" + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET +
+ NEW_LINE + TWELVE_SPACE_INDENTATION + OBJECT_STRING + SPACE +
+ getSmallCase(YANG_AUGMENTED_OP_PARAM_INFO) + SPACE + EQUAL + SPACE + APP_INSTANCE + PERIOD +
+ getSmallCase(YANG_AUGMENTED_INFO) + OPEN_PARENTHESIS + getSmallCase(YANG_AUGMENTED_INFO) + PERIOD +
+ GET_CLASS + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION
+ + OBJECT + SPACE + PROCESS_SUBTREE_FILTERING + SEMI_COLAN
+ + NEW_LINE + TWELVE_SPACE_INDENTATION + TRY + SPACE + OPEN_CURLY_BRACKET + NEW_LINE +
+ SIXTEEN_SPACE_INDENTATION +
+ "Class<?>[] interfaces = " + getSmallCase(YANG_AUGMENTED_INFO) + ".getClass().getInterfaces();" +
+ NEW_LINE + SIXTEEN_SPACE_INDENTATION +
+ PROCESS_SUBTREE_FILTERING + SPACE + EQUAL + SPACE + getSmallCase(YANG_AUGMENTED_INFO) + PERIOD
+ + GET_CLASS + NEW_LINE + TWENTY_SPACE_INDENTATION + PERIOD + GET_METHOD
+ + OPEN_PARENTHESIS + QUOTES + PROCESS_SUBTREE_FILTERING + QUOTES + COMMA + SPACE + "interfaces[0]"
+ + CLOSE_PARENTHESIS + PERIOD + INVOKE + OPEN_PARENTHESIS + getSmallCase(YANG_AUGMENTED_INFO) + COMMA
+ + NEW_LINE + TWENTY_FOUR_SPACE_INDENTATION + getSmallCase(YANG_AUGMENTED_OP_PARAM_INFO)
+ + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE
+ + SIXTEEN_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + PROCESS_SUBTREE_FILTERING + SPACE
+ + NOT + EQUAL + SPACE + NULL + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE
+ + TWENTY_SPACE_INDENTATION + SUBTREE_FILTERING_RESULT_BUILDER + PERIOD + "add" + YANG_AUGMENTED_INFO
+ + OPEN_PARENTHESIS + PROCESS_SUBTREE_FILTERING + COMMA + SPACE + PROCESS_SUBTREE_FILTERING + PERIOD
+ + GET_CLASS + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE + SIXTEEN_SPACE_INDENTATION
+ + CLOSE_CURLY_BRACKET + NEW_LINE
+ + TWELVE_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + SPACE + CATCH + SPACE + OPEN_PARENTHESIS
+ + NO_SUCH_METHOD_EXCEPTION + " | " + INVOCATION_TARGET_EXCEPTION + " | " + ILLEGAL_ACCESS_EXCEPTION +
+ SPACE + EXCEPTION_VAR + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE
+ + SIXTEEN_SPACE_INDENTATION + CONTINUE + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION
+ + CLOSE_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE;
+ }
+}
diff --git a/plugin/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java b/plugin/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
index 580b6cf..a0c66b0 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
@@ -724,6 +724,11 @@
public static final String CLOSE_PARENTHESIS = ")";
/**
+ * Static attribute for empty parameter function call.
+ */
+ public static final String EMPTY_PARAMETER_FUNCTION_CALL = "()";
+
+ /**
* Static attribute for open curly bracket syntax.
*/
public static final String OPEN_CURLY_BRACKET = "{";
@@ -761,7 +766,13 @@
/**
* Static attribute for get filter leaf flags.
*/
- public static final String GET_FILTER_LEAF = "getValueLeafFlags";
+ public static final String GET_VALUE_LEAF_FLAGS = "getValueLeafFlags";
+
+ /**
+ * Static attribute for get select filter leaf flags.
+ */
+ public static final String GET_SELECT_LEAF_FLAGS = "getSelectLeafFlags";
+
/**
* Static attribute for getLeafIndex.
@@ -777,7 +788,22 @@
/**
* Static attribute for is filter content match method prefix.
*/
- public static final String FILTER_CONTENT_MATCH = "isFilterContentMatch";
+ public static final String PROCESS_SUBTREE_FILTERING = "processSubtreeFiltering";
+
+ /**
+ * variable name of the subtree filtering result builder.
+ */
+ public static final String SUBTREE_FILTERING_RESULT_BUILDER = "subTreeFilteringResultBuilder";
+
+ /**
+ * variable name of the subtree filtering result flag.
+ */
+ public static final String IS_ANY_SELECT_OR_CONTAINMENT_NODE_FLAG = "isAnySelectOrContainmentNode";
+
+ /**
+ * variable name of the subtree filtering to select all child.
+ */
+ public static final String IS_SELECT_ALL_SCHEMA_CHILD_FLAG = "isSelectAllSchemaChild";
/**
* Static attribute for flag prefix.
@@ -842,22 +868,37 @@
/**
* Static attribute for twelve space indentation.
*/
- public static final String TWELVE_SPACE_INDENTATION = FOUR_SPACE_INDENTATION + EIGHT_SPACE_INDENTATION;
+ public static final String TWELVE_SPACE_INDENTATION = EIGHT_SPACE_INDENTATION + FOUR_SPACE_INDENTATION;
/**
* Static attribute for sixteen space indentation.
*/
- public static final String SIXTEEN_SPACE_INDENTATION = EIGHT_SPACE_INDENTATION + EIGHT_SPACE_INDENTATION;
+ public static final String SIXTEEN_SPACE_INDENTATION = TWELVE_SPACE_INDENTATION + FOUR_SPACE_INDENTATION;
/**
* Static attribute for twenty space indentation.
*/
- public static final String TWENTY_SPACE_INDENTATION = FOUR_SPACE_INDENTATION + SIXTEEN_SPACE_INDENTATION;
+ public static final String TWENTY_SPACE_INDENTATION = SIXTEEN_SPACE_INDENTATION + FOUR_SPACE_INDENTATION;
/**
* Static attribute for twenty four space indentation.
*/
- public static final String TWENTY_FOUR_SPACE_INDENTATION = EIGHT_SPACE_INDENTATION + SIXTEEN_SPACE_INDENTATION;
+ public static final String TWENTY_FOUR_SPACE_INDENTATION = TWENTY_SPACE_INDENTATION + FOUR_SPACE_INDENTATION;
+
+ /**
+ * Static attribute for twenty eight space indentation.
+ */
+ public static final String TWENTY_EIGHT_SPACE_INDENTATION = TWENTY_FOUR_SPACE_INDENTATION + FOUR_SPACE_INDENTATION;
+
+ /**
+ * Static attribute for thirty two space indentation.
+ */
+ public static final String THIRTY_TWO_SPACE_INDENTATION = TWENTY_EIGHT_SPACE_INDENTATION + FOUR_SPACE_INDENTATION;
+
+ /**
+ * continue.
+ */
+ public static final String CONTINUE = "continue";
/**
* Static attribute for generated code path.
@@ -1301,6 +1342,11 @@
public static final String OR_OPERATION = "||";
/**
+ * Static attribute for or operator.
+ */
+ public static final String AND_OPERATION = "&&";
+
+ /**
* Static attribute for YANG file error.
*/
public static final String YANG_FILE_ERROR = "YANG file error : ";
diff --git a/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGeneratorTest.java b/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGeneratorTest.java
index 9579b7d..534a70a 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGeneratorTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGeneratorTest.java
@@ -67,6 +67,7 @@
import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS;
import static org.onosproject.yangutils.utils.UtilConstants.OVERRIDE;
import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
+import static org.onosproject.yangutils.utils.UtilConstants.PROTECTED;
import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC;
import static org.onosproject.yangutils.utils.UtilConstants.QUOTES;
import static org.onosproject.yangutils.utils.UtilConstants.RETURN;
@@ -178,7 +179,7 @@
public void getConstructorStartTest() {
YangPluginConfig pluginConfig = new YangPluginConfig();
String method = getConstructorStart(CLASS_NAME, pluginConfig, false);
- assertThat(true, is(method.contains(PUBLIC + SPACE + "Default" + CLASS_NAME + OPEN_PARENTHESIS + CLASS_NAME
+ assertThat(true, is(method.contains(PROTECTED + SPACE + "Default" + CLASS_NAME + OPEN_PARENTHESIS + CLASS_NAME
+ BUILDER + SPACE + BUILDER.toLowerCase() + OBJECT + CLOSE_PARENTHESIS + SPACE
+ OPEN_CURLY_BRACKET + NEW_LINE)));
}