-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
2937703
commit e3a8994
Showing
5 changed files
with
115 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
...s/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/YangStatementTranslator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
* Copyright 2024 Xyna GmbH, Germany | ||
* | ||
* 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 xdev.yang.impl; | ||
|
||
|
||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.yangcentral.yangkit.base.YangElement; | ||
import org.yangcentral.yangkit.model.api.stmt.Container; | ||
import org.yangcentral.yangkit.model.api.stmt.Leaf; | ||
import org.yangcentral.yangkit.model.api.stmt.Uses; | ||
import org.yangcentral.yangkit.model.api.stmt.YangStatement; | ||
|
||
|
||
|
||
public class YangStatementTranslator { | ||
|
||
public static final Map<Class<?>, YangStatementTranslation> translations = setupStatementTranslations(); | ||
|
||
|
||
private static Map<Class<?>, YangStatementTranslation> setupStatementTranslations() { | ||
Map<Class<?>, YangStatementTranslation> result = new HashMap<Class<?>, YangStatementTranslation>(); | ||
result.put(Container.class, new YangStatementTranslation(Constants.TYPE_CONTAINER)); | ||
result.put(Leaf.class, new YangStatementTranslation(Constants.TYPE_LEAF)); | ||
result.put(Uses.class, new YangStatementTranslation(Constants.TYPE_USES)); | ||
return result; | ||
} | ||
|
||
|
||
public static YangStatementTranslation getTranslation(Class<?> yangStatementClass) { | ||
return translations.get(yangStatementClass); | ||
} | ||
|
||
|
||
public static class YangStatementTranslation { | ||
|
||
private String yangStatementName; | ||
|
||
|
||
public YangStatementTranslation(String yangStatementName) { | ||
this.yangStatementName = yangStatementName; | ||
|
||
} | ||
|
||
|
||
public String getYangStatementName() { | ||
return yangStatementName; | ||
} | ||
|
||
|
||
public static String getLocalName(YangStatement statement) { | ||
return statement.getArgStr(); | ||
} | ||
|
||
|
||
public static String getUriString(YangStatement statement) { | ||
return statement.getContext().getNamespace().getUri().toString(); | ||
} | ||
|
||
|
||
public static List<YangElement> getSubStatements(YangStatement statement) { | ||
if (statement instanceof Uses) { | ||
return ((Uses) statement).getRefGrouping().getSubElements(); | ||
} else { | ||
return statement.getSubElements(); | ||
} | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters