diff options
author | frank feng <frank.fengchong@huawei.com> | 2023-09-13 11:40:58 +0800 |
---|---|---|
committer | frank feng <frank.fengchong@huawei.com> | 2023-09-13 14:12:20 +0800 |
commit | c591d5e079dee38969ddd6366481bb1b476aaa31 (patch) | |
tree | e056f675f70814a18fada5ea103ba3dd7c4c8d27 /yang-comparator | |
parent | 921f0af17f560e45b95668a1b00f895bca48039d (diff) |
modify yang-comparator, such as yang compiler plugin, and some java doc. modify some functions of yang-compiler.
Issue-ID: MODELING-680
Change-Id: I37784c6a3511cfffafe0e19bd4ebdb4ba9d9b958
Signed-off-by: frank feng <frank.fengchong@huawei.com>
Diffstat (limited to 'yang-comparator')
28 files changed, 120 insertions, 261 deletions
diff --git a/yang-comparator/pom.xml b/yang-comparator/pom.xml index 094b6ea..cac954e 100644 --- a/yang-comparator/pom.xml +++ b/yang-comparator/pom.xml @@ -63,9 +63,9 @@ <version>1.3.5</version> </dependency> <dependency> - <groupId>io.github.yang-central.yangkit</groupId> + <groupId>org.onap.modeling.yangkit</groupId> <artifactId>yang-compiler</artifactId> - <version>1.3.1</version> + <version>1.0.0-SNAPSHOT</version> </dependency> <dependency> <groupId>org.dom4j</groupId> diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/AugmentComparator.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/AugmentComparator.java index 44fd21b..1870586 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/AugmentComparator.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/AugmentComparator.java @@ -24,10 +24,10 @@ import org.yangcentral.yangkit.model.api.stmt.Augment; public class AugmentComparator extends SchemaNodeComparator<Augment> { /** - * - * @param left left statement - * @param right right statement - * @return + * compare the left and right statement. + * @param left left statement + * @param right right statement + * @return list of compare result */ @Override public List<YangCompareResult> compare(Augment left, Augment right) { diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/BaseComparator.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/BaseComparator.java index d362fdd..bbb6fd7 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/BaseComparator.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/BaseComparator.java @@ -24,11 +24,11 @@ import org.yangcentral.yangkit.model.api.stmt.Type; public class BaseComparator extends CommonYangStatementComparator<Base> { /** - * + * get the default compatibility from left and right base statements. * @param left left statement * @param right right statement - * @param changeInfo - * @return + * @param changeInfo the change information + * @return default compatibility information */ @Override protected CompatibilityInfo defaultCompatibility(Base left, Base right, diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/ChangeType.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/ChangeType.java index 6f7f818..cc04039 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/ChangeType.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/ChangeType.java @@ -25,16 +25,16 @@ public enum ChangeType { private String description; /** - * - * @param description + * the constructor (private). + * @param description description */ private ChangeType(String description) { this.description = description; } /** - * - * @return + * get the name. + * @return the name */ public String getName() { return this.description; diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/CommonYangStatementComparator.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/CommonYangStatementComparator.java index 8be269e..77be97b 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/CommonYangStatementComparator.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/CommonYangStatementComparator.java @@ -36,10 +36,10 @@ public class CommonYangStatementComparator<T extends YangStatement> extends Abst public static final int OPTION_ALL = 3; /** - * + * get then change information between left and right statements. * @param left left statement * @param right right statement - * @return + * @return the change information */ @Override protected List<CompatibilityRule.ChangeInfo> getChangeInfo(T left, T right) { @@ -65,11 +65,7 @@ public class CommonYangStatementComparator<T extends YangStatement> extends Abst return changeInfos; } - /** - * - * @param stmt - * @return - */ + private int getIndex(T stmt) { YangStatement parentStmt = stmt.getParentStatement(); if (null == parentStmt) { @@ -89,9 +85,9 @@ public class CommonYangStatementComparator<T extends YangStatement> extends Abst } /** - * - * @param changeInfo - * @return + * get the change type from change information. + * @param changeInfo change information + * @return change type */ protected ChangeType getChangeType(CompatibilityRule.ChangeInfo changeInfo) { switch (changeInfo) { @@ -110,11 +106,11 @@ public class CommonYangStatementComparator<T extends YangStatement> extends Abst /** - * + * get the default compatibility. * @param left left statement * @param right right statement - * @param changeInfo - * @return + * @param changeInfo change information + * @return default compatibility */ @Override protected CompatibilityInfo defaultCompatibility(T left, T right, CompatibilityRule.ChangeInfo changeInfo) { @@ -147,10 +143,10 @@ public class CommonYangStatementComparator<T extends YangStatement> extends Abst } /** - * + * compare the children of left and right statements. * @param left left statement * @param right right statement - * @return + * @return list of compare result */ protected List<YangCompareResult> compareChildren(T left, T right) { List<YangCompareResult> compareResults = @@ -160,10 +156,10 @@ public class CommonYangStatementComparator<T extends YangStatement> extends Abst } /** - * + * compare the left and right statements. * @param left left statement * @param right right statement - * @return + * @return list compare result */ @Override public List<YangCompareResult> compare(T left, T right) { diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/CompatibilityRules.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/CompatibilityRules.java index cbab987..c7b3d6f 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/CompatibilityRules.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/CompatibilityRules.java @@ -91,12 +91,7 @@ public class CompatibilityRules { } } - /** - * - * @param left left statement - * @param right right statement - * @return - */ + private boolean matchCondition(CompatibilityRule left, CompatibilityRule.ChangeInfo right) { if (left.getCondition() == CompatibilityRule.ChangeInfo.ANY) { return true; diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/ConfigComparator.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/ConfigComparator.java index a0018d7..496978e 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/ConfigComparator.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/ConfigComparator.java @@ -26,10 +26,10 @@ import org.yangcentral.yangkit.model.api.stmt.SchemaNode; public class ConfigComparator extends CommonYangStatementComparator<Config> { /** - * + * get the change information. * @param left left statement * @param right right statement - * @return + * @return list of change information */ @Override protected List<CompatibilityRule.ChangeInfo> getChangeInfo(Config left, Config right) { @@ -60,11 +60,11 @@ public class ConfigComparator extends CommonYangStatementComparator<Config> { } /** - * + * get the default compatibility. * @param left left statement * @param right right statement - * @param changeInfo - * @return + * @param changeInfo change information + * @return default compatibility */ @Override protected CompatibilityInfo defaultCompatibility(Config left, Config right, diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/DefaultComparator.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/DefaultComparator.java index f7b1c13..f47ac5c 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/DefaultComparator.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/DefaultComparator.java @@ -22,11 +22,11 @@ import org.yangcentral.yangkit.model.api.stmt.Default; public class DefaultComparator extends CommonYangStatementComparator<Default> { /** - * + * get default compatibility. * @param left left statement * @param right right statement - * @param changeInfo - * @return + * @param changeInfo change information. + * @return default compatibility */ @Override protected CompatibilityInfo defaultCompatibility(Default left, Default right, diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/DescriptionComparator.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/DescriptionComparator.java index 2b5db1c..ea7b7a3 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/DescriptionComparator.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/DescriptionComparator.java @@ -22,11 +22,11 @@ import org.yangcentral.yangkit.model.api.stmt.Description; public class DescriptionComparator extends CommonYangStatementComparator<Description> { /** - * + * get default compatibility. * @param left left statement * @param right right statement - * @param changeInfo - * @return + * @param changeInfo change information. + * @return default compatibility */ @Override protected CompatibilityInfo defaultCompatibility(Description left, Description right, diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/EnumBitComparator.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/EnumBitComparator.java index e0fb3ef..30792b4 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/EnumBitComparator.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/EnumBitComparator.java @@ -22,11 +22,11 @@ import org.yangcentral.yangkit.model.api.stmt.YangStatement; public class EnumBitComparator extends CommonYangStatementComparator { /** - * + * get default compatibility. * @param left left statement * @param right right statement - * @param changeInfo - * @return + * @param changeInfo change information. + * @return default compatibility */ @Override protected CompatibilityInfo defaultCompatibility(YangStatement left, YangStatement right, diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/IdentifierComparator.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/IdentifierComparator.java index 3eff979..6a6aa4e 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/IdentifierComparator.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/IdentifierComparator.java @@ -22,11 +22,11 @@ import org.yangcentral.yangkit.model.api.stmt.YangStatement; public class IdentifierComparator extends CommonYangStatementComparator { /** - * + * get default compatibility. * @param left left statement * @param right right statement - * @param changeInfo - * @return + * @param changeInfo change information. + * @return default compatibility */ @Override protected CompatibilityInfo defaultCompatibility(YangStatement left, YangStatement right, diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/IfFeatureComparator.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/IfFeatureComparator.java index dfa0199..b4e770f 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/IfFeatureComparator.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/IfFeatureComparator.java @@ -21,11 +21,11 @@ import org.yangcentral.yangkit.model.api.stmt.IfFeature; public class IfFeatureComparator extends CommonYangStatementComparator<IfFeature> { /** - * + * get default compatibility. * @param left left statement * @param right right statement - * @param changeInfo - * @return + * @param changeInfo change information. + * @return default compatibility */ @Override protected CompatibilityInfo defaultCompatibility(IfFeature left, IfFeature right, diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/MandatoryComparator.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/MandatoryComparator.java index 375d69b..6e5cb43 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/MandatoryComparator.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/MandatoryComparator.java @@ -24,10 +24,10 @@ import org.yangcentral.yangkit.model.api.stmt.Mandatory; public class MandatoryComparator extends CommonYangStatementComparator<Mandatory> { /** - * + * get the change information. * @param left left statement * @param right right statement - * @return + * @return list of change information */ @Override protected List<CompatibilityRule.ChangeInfo> getChangeInfo(Mandatory left, Mandatory right) { @@ -45,11 +45,11 @@ public class MandatoryComparator extends CommonYangStatementComparator<Mandatory } /** - * + * get default compatibility. * @param left left statement * @param right right statement - * @param changeInfo - * @return + * @param changeInfo change information. + * @return default compatibility */ @Override protected CompatibilityInfo defaultCompatibility(Mandatory left, Mandatory right, diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/MaxElementsComparator.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/MaxElementsComparator.java index 1361ef2..e71b3f5 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/MaxElementsComparator.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/MaxElementsComparator.java @@ -25,10 +25,10 @@ import org.yangcentral.yangkit.model.api.stmt.MaxElements; public class MaxElementsComparator extends CommonYangStatementComparator<MaxElements> { /** - * + * get the change information. * @param left left statement * @param right right statement - * @return + * @return list of change information */ @Override protected List<CompatibilityRule.ChangeInfo> getChangeInfo(MaxElements left, MaxElements right) { @@ -51,11 +51,11 @@ public class MaxElementsComparator extends CommonYangStatementComparator<MaxElem } /** - * + * get default compatibility. * @param left left statement * @param right right statement - * @param changeInfo - * @return + * @param changeInfo change information. + * @return default compatibility */ @Override protected CompatibilityInfo defaultCompatibility(MaxElements left, MaxElements right, diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/MinElementsComparator.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/MinElementsComparator.java index f97e313..4e8c133 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/MinElementsComparator.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/MinElementsComparator.java @@ -24,12 +24,7 @@ import org.yangcentral.yangkit.model.api.stmt.MinElements; public class MinElementsComparator extends CommonYangStatementComparator<MinElements> { - /** - * - * @param left left statement - * @param right right statement - * @return - */ + @Override protected List<CompatibilityRule.ChangeInfo> getChangeInfo(MinElements left, MinElements right) { List<CompatibilityRule.ChangeInfo> changeInfos = new ArrayList<>(); @@ -44,13 +39,7 @@ public class MinElementsComparator extends CommonYangStatementComparator<MinElem return changeInfos; } - /** - * - * @param left left statement - * @param right right statement - * @param changeInfo - * @return - */ + @Override protected CompatibilityInfo defaultCompatibility(MinElements left, MinElements right, CompatibilityRule.ChangeInfo changeInfo) { diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/ModuleComparator.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/ModuleComparator.java index 9c9bb7f..574dff7 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/ModuleComparator.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/ModuleComparator.java @@ -25,24 +25,13 @@ import org.yangcentral.yangkit.model.api.stmt.Module; public class ModuleComparator extends CommonYangStatementComparator<Module> { - /** - * - * @param left left statement - * @param right right statement - * @return - */ + @Override protected List<CompatibilityRule.ChangeInfo> getChangeInfo(Module left, Module right) { return super.getChangeInfo(left, right); } - /** - * - * @param left left statement - * @param right right statement - * @param changeInfo - * @return - */ + @Override protected CompatibilityInfo defaultCompatibility(Module left, Module right, CompatibilityRule.ChangeInfo changeInfo) { @@ -54,12 +43,7 @@ public class ModuleComparator extends CommonYangStatementComparator<Module> { return super.defaultCompatibility(left, right, changeInfo); } - /** - * - * @param left left statement - * @param right right statement - * @return - */ + @Override protected List<YangCompareResult> compareChildren(Module left, Module right) { List<YangCompareResult> results = new ArrayList<>(); diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/NamespaceComparator.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/NamespaceComparator.java index 8ea9953..565cf6d 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/NamespaceComparator.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/NamespaceComparator.java @@ -21,13 +21,7 @@ import org.yangcentral.yangkit.model.api.stmt.Namespace; public class NamespaceComparator extends CommonYangStatementComparator<Namespace> { - /** - * - * @param left left statement - * @param right right statement - * @param changeInfo - * @return - */ + @Override protected CompatibilityInfo defaultCompatibility(Namespace left, Namespace right, CompatibilityRule.ChangeInfo changeInfo) { diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/OperationComparator.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/OperationComparator.java index 58cde02..6ae9aee 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/OperationComparator.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/OperationComparator.java @@ -28,11 +28,6 @@ import org.yangcentral.yangkit.model.api.stmt.YangStatement; public class OperationComparator extends SchemaNodeComparator<Operation> { - /** - * - * @param schemaNodeContainer - * @return - */ private boolean hasActiveSchemaChildren(SchemaNodeContainer schemaNodeContainer) { for (SchemaNode schemaNode : schemaNodeContainer.getSchemaNodeChildren()) { if (schemaNode.isActive()) { @@ -42,12 +37,7 @@ public class OperationComparator extends SchemaNodeComparator<Operation> { return false; } - /** - * - * @param left left statement - * @param right right statement - * @return - */ + @Override protected List<YangCompareResult> compareChildren(Operation left, Operation right) { List<YangCompareResult> compareResults = new ArrayList<>(); diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/PatternComparator.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/PatternComparator.java index 83f3f9b..f373a09 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/PatternComparator.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/PatternComparator.java @@ -21,13 +21,7 @@ import org.yangcentral.yangkit.model.api.stmt.type.Pattern; public class PatternComparator extends CommonYangStatementComparator<Pattern> { - /** - * - * @param left left statement - * @param right right statement - * @param changeInfo - * @return - */ + @Override protected CompatibilityInfo defaultCompatibility(Pattern left, Pattern right, CompatibilityRule.ChangeInfo changeInfo) { diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/RangeLengthComparator.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/RangeLengthComparator.java index 076b7bf..ea4ef6c 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/RangeLengthComparator.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/RangeLengthComparator.java @@ -24,12 +24,7 @@ import org.yangcentral.yangkit.model.api.stmt.type.SectionExpression; public class RangeLengthComparator extends CommonYangStatementComparator<SectionExpression> { - /** - * - * @param left left statement - * @param right right statement - * @return - */ + @Override protected List<CompatibilityRule.ChangeInfo> getChangeInfo(SectionExpression left, SectionExpression right) { List<CompatibilityRule.ChangeInfo> changeInfos = new ArrayList<>(); @@ -48,13 +43,7 @@ public class RangeLengthComparator extends CommonYangStatementComparator<Section return changeInfos; } - /** - * - * @param left left statement - * @param right right statement - * @param changeInfo - * @return - */ + @Override protected CompatibilityInfo defaultCompatibility(SectionExpression left, SectionExpression right, CompatibilityRule.ChangeInfo changeInfo) { diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/ReferenceComparator.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/ReferenceComparator.java index be50fa1..59026c0 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/ReferenceComparator.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/ReferenceComparator.java @@ -21,13 +21,6 @@ import org.yangcentral.yangkit.model.api.stmt.Reference; public class ReferenceComparator extends CommonYangStatementComparator<Reference> { - /** - * - * @param left left statement - * @param right right statement - * @param changeInfo - * @return - */ @Override protected CompatibilityInfo defaultCompatibility(Reference left, Reference right, CompatibilityRule.ChangeInfo changeInfo) { diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/SchemaNodeComparator.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/SchemaNodeComparator.java index ff6de53..3439b7f 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/SchemaNodeComparator.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/SchemaNodeComparator.java @@ -25,12 +25,7 @@ import org.yangcentral.yangkit.model.api.stmt.SchemaNodeContainer; public class SchemaNodeComparator<T extends SchemaNode> extends CommonYangStatementComparator<T> { - /** - * - * @param left left statement - * @param right right statement - * @return - */ + @Override protected List<CompatibilityRule.ChangeInfo> getChangeInfo(T left, T right) { List<CompatibilityRule.ChangeInfo> changeInfos = new ArrayList<>(); @@ -48,13 +43,6 @@ public class SchemaNodeComparator<T extends SchemaNode> extends CommonYangStatem return changeInfos; } - /** - * - * @param left left statement - * @param right right statement - * @param changeInfo - * @return - */ @Override protected CompatibilityInfo defaultCompatibility(T left, T right, CompatibilityRule.ChangeInfo changeInfo) { @@ -66,12 +54,7 @@ public class SchemaNodeComparator<T extends SchemaNode> extends CommonYangStatem } - /** - * - * @param left left statement - * @param right right statement - * @return - */ + @Override protected List<YangCompareResult> compareChildren(T left, T right) { List<YangCompareResult> results = new ArrayList<>(); @@ -92,12 +75,7 @@ public class SchemaNodeComparator<T extends SchemaNode> extends CommonYangStatem return results; } - /** - * - * @param left left statement - * @param right right statement - * @return - */ + @Override public List<YangCompareResult> compare(T left, T right) { List<YangCompareResult> compareResults = new ArrayList<>(); diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/StatusComparator.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/StatusComparator.java index 8a6df4d..ff92321 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/StatusComparator.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/StatusComparator.java @@ -26,12 +26,6 @@ import org.yangcentral.yangkit.model.api.stmt.StatusStmt; public class StatusComparator extends CommonYangStatementComparator<StatusStmt> { - /** - * - * @param left left statement - * @param right right statement - * @return - */ @Override protected List<CompatibilityRule.ChangeInfo> getChangeInfo(StatusStmt left, StatusStmt right) { List<CompatibilityRule.ChangeInfo> changeInfos = new ArrayList<>(); @@ -52,13 +46,7 @@ public class StatusComparator extends CommonYangStatementComparator<StatusStmt> } - /** - * - * @param left left statement - * @param right right statement - * @param changeInfo - * @return - */ + @Override protected CompatibilityInfo defaultCompatibility(StatusStmt left, StatusStmt right, CompatibilityRule.ChangeInfo changeInfo) { diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/UniqueComparator.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/UniqueComparator.java index 1611818..be53a75 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/UniqueComparator.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/UniqueComparator.java @@ -25,12 +25,7 @@ import org.yangcentral.yangkit.model.api.stmt.YangStatement; public class UniqueComparator extends CommonYangStatementComparator<Unique> { - /** - * - * @param left left statement - * @param right right statement - * @return - */ + @Override protected List<CompatibilityRule.ChangeInfo> getChangeInfo(Unique left, Unique right) { List<CompatibilityRule.ChangeInfo> changeInfos = new ArrayList<>(); @@ -85,13 +80,7 @@ public class UniqueComparator extends CommonYangStatementComparator<Unique> { return changeInfos; } - /** - * - * @param left left statement - * @param right right statement - * @param changeInfo - * @return - */ + @Override protected CompatibilityInfo defaultCompatibility(Unique left, Unique right, CompatibilityRule.ChangeInfo changeInfo) { diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/UnitsComparator.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/UnitsComparator.java index f484af2..a7f7045 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/UnitsComparator.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/UnitsComparator.java @@ -21,13 +21,7 @@ import org.yangcentral.yangkit.model.api.stmt.Units; public class UnitsComparator extends CommonYangStatementComparator<Units> { - /** - * - * @param left left statement - * @param right right statement - * @param changeInfo - * @return - */ + @Override protected CompatibilityInfo defaultCompatibility(Units left, Units right, CompatibilityRule.ChangeInfo changeInfo) { diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/ValuePositionComparator.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/ValuePositionComparator.java index c680dea..f27f5db 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/ValuePositionComparator.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/ValuePositionComparator.java @@ -20,13 +20,7 @@ import org.yangcentral.yangkit.model.api.stmt.YangStatement; public class ValuePositionComparator extends CommonYangStatementComparator { - /** - * - * @param left left statement - * @param right right statement - * @param changeInfo - * @return - */ + @Override protected CompatibilityInfo defaultCompatibility(YangStatement left, YangStatement right, CompatibilityRule.ChangeInfo changeInfo) { diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/WhenMustComparator.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/WhenMustComparator.java index 3825a74..a933ccc 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/WhenMustComparator.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/WhenMustComparator.java @@ -20,13 +20,7 @@ import org.yangcentral.yangkit.model.api.stmt.YangStatement; public class WhenMustComparator extends CommonYangStatementComparator { - /** - * - * @param left left statement - * @param right right statement - * @param changeInfo - * @return - */ + @Override protected CompatibilityInfo defaultCompatibility(YangStatement left, YangStatement right, CompatibilityRule.ChangeInfo changeInfo) { diff --git a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/app/YangComparatorPlugin.java b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/app/YangComparatorPlugin.java index 8b513cc..a46b97d 100644 --- a/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/app/YangComparatorPlugin.java +++ b/yang-comparator/src/main/java/org/onap/modeling/yangkit/comparator/app/YangComparatorPlugin.java @@ -16,26 +16,28 @@ limitations under the License. package org.onap.modeling.yangkit.comparator.app; -import java.io.File; +import com.google.gson.JsonElement; + import java.io.IOException; -import java.util.Iterator; import java.util.List; -import java.util.Map; -import java.util.Properties; import org.dom4j.Document; import org.dom4j.DocumentException; import org.onap.modeling.yangkit.comparator.CompareType; import org.onap.modeling.yangkit.comparator.YangComparator; import org.onap.modeling.yangkit.comparator.YangCompareResult; +import org.onap.modeling.yangkit.compiler.BuildOption; +import org.onap.modeling.yangkit.compiler.Settings; +import org.onap.modeling.yangkit.compiler.Source; +import org.onap.modeling.yangkit.compiler.YangCompiler; +import org.onap.modeling.yangkit.compiler.YangCompilerException; +import org.onap.modeling.yangkit.compiler.plugin.YangCompilerPlugin; +import org.onap.modeling.yangkit.compiler.plugin.YangCompilerPluginParameter; +import org.onap.modeling.yangkit.compiler.util.YangCompilerUtil; import org.yangcentral.yangkit.common.api.validate.ValidatorResult; -import org.yangcentral.yangkit.compiler.Settings; -import org.yangcentral.yangkit.compiler.YangCompiler; -import org.yangcentral.yangkit.compiler.YangCompilerException; + import org.yangcentral.yangkit.model.api.schema.YangSchemaContext; -import org.yangcentral.yangkit.plugin.YangCompilerPlugin; -import org.yangcentral.yangkit.plugin.YangCompilerPluginParameter; import org.yangcentral.yangkit.utils.file.FileUtil; import org.yangcentral.yangkit.utils.xml.XmlWriter; @@ -45,65 +47,62 @@ import org.yangcentral.yangkit.utils.xml.XmlWriter; */ public class YangComparatorPlugin implements YangCompilerPlugin { @Override - public YangCompilerPluginParameter getParameter(Properties properties, String name, String value) + public YangCompilerPluginParameter getParameter(String name, JsonElement value) throws YangCompilerException { if (!name.equals("old-yang") && !name.equals("settings") && !name.equals("compare-type") && !name.equals("rule") && !name.equals("result")) { throw new YangCompilerException("unrecognized parameter:" + name); } - YangCompilerPluginParameter yangCompilerPluginParameter = new YangCompilerPluginParameter() { - @Override - public String getName() { - return name; - } + if (name.equals("old-yang") || name.equals("compare-type")) { + YangCompilerPluginParameter yangCompilerPluginParameter = new YangCompilerPluginParameter() { + @Override + public String getName() { + return name; + } - @Override - public Object getValue() throws YangCompilerException { - if (name.equals("old-yang") || name.equals("settings") - || name.equals("rule") || name.equals("result")) { - Iterator<Map.Entry<Object, Object>> it = properties.entrySet().iterator(); - String formatStr = value; - while (it.hasNext()) { - Map.Entry<Object, Object> entry = it.next(); - formatStr = formatStr.replaceAll("\\{" + entry.getKey() + "\\}", (String) entry.getValue()); + @Override + public Object getValue() throws YangCompilerException { + if (name.equals("old-yang")) { + return BuildOption.parseSources(value); } - return formatStr; - } - if (name.equals("compare-type")) { - if (value.equals("stmt")) { - return CompareType.STMT; - } else if (value.equals("tree")) { - return CompareType.TREE; - } else if (value.equals("compatible-check")) { - return CompareType.COMPATIBLE_CHECK; + if (name.equals("compare-type")) { + if (value.equals("stmt")) { + return CompareType.STMT; + } else if (value.equals("tree")) { + return CompareType.TREE; + } else if (value.equals("compatible-check")) { + return CompareType.COMPATIBLE_CHECK; + } + throw new YangCompilerException("unrecognized value:" + value); } - throw new YangCompilerException("unrecognized value:" + value); + return null; } - return null; - } - }; - return yangCompilerPluginParameter; + }; + return yangCompilerPluginParameter; + } + return YangCompilerPlugin.super.getParameter(name, value); + } @Override public void run(YangSchemaContext yangSchemaContext, YangCompiler yangCompiler, List<YangCompilerPluginParameter> list) throws YangCompilerException { CompareType compareType = null; - String oldYangPath = null; + List<Source> sources = null; + Settings settings = yangCompiler.getSettings(); String rulePath = null; String resultPath = null; for (YangCompilerPluginParameter parameter : list) { //System.out.println("para name="+parameter.getName() + " para value="+parameter.getValue()); if (parameter.getName().equals("old-yang")) { - oldYangPath = (String) parameter.getValue(); - yangCompiler.setYang(new File(oldYangPath)); + sources = (List<Source>) parameter.getValue(); } else if (parameter.getName().equals("settings")) { String settingsPath = (String) parameter.getValue(); try { - yangCompiler.setSettings(Settings.parse(FileUtil.readFile2String(settingsPath))); + settings = Settings.parse(FileUtil.readFile2String(settingsPath)); } catch (IOException e) { throw new RuntimeException(e); } @@ -116,7 +115,7 @@ public class YangComparatorPlugin implements YangCompilerPlugin { } } - if (oldYangPath == null) { + if (sources == null) { throw new YangCompilerException("missing mandatory parameter:old-yang"); } if (compareType == null) { @@ -125,11 +124,10 @@ public class YangComparatorPlugin implements YangCompilerPlugin { if (resultPath == null) { throw new YangCompilerException("missing mandatory parameter:result"); } - YangSchemaContext oldSchemaContext = yangCompiler.buildSchemaContext(); + YangSchemaContext oldSchemaContext = YangCompilerUtil.buildSchemaContext(sources, settings); ValidatorResult oldResult = oldSchemaContext.validate(); if (!oldResult.isOk()) { - throw new YangCompilerException("fail to validate the schema context of " - + oldYangPath + throw new YangCompilerException("fail to validate the schema context" + ".\n" + oldResult); } |