private final String name;
private final String revision;
- public SourceIdentifier(String name, Optional<String> formattedRevision) {
+ public SourceIdentifier(final String name, final Optional<String> formattedRevision) {
super();
this.name = name;
this.revision = formattedRevision.orNull();
}
@Override
- public boolean equals(Object obj) {
- if (this == obj)
+ public boolean equals(final Object obj) {
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
SourceIdentifier other = (SourceIdentifier) obj;
if (name == null) {
- if (other.name != null)
+ if (other.name != null) {
return false;
- } else if (!name.equals(other.name))
+ }
+ } else if (!name.equals(other.name)) {
return false;
+ }
if (revision == null) {
- if (other.revision != null)
+ if (other.revision != null) {
return false;
- } else if (!revision.equals(other.revision))
+ }
+ } else if (!revision.equals(other.revision)) {
return false;
+ }
return true;
}
return revision;
}
- public static SourceIdentifier create(String moduleName, Optional<String> revision) {
+ public static SourceIdentifier create(final String moduleName, final Optional<String> revision) {
return new SourceIdentifier(moduleName, revision);
}
-
+
public String toYangFilename() {
return toYangFileName(name, Optional.fromNullable(revision));
}
-
+
@Override
public String toString() {
return "SourceIdentifier [name=" + name + "@" + revision + "]";
}
- public static final String toYangFileName(String moduleName, Optional<String> revision) {
+ public static final String toYangFileName(final String moduleName, final Optional<String> revision) {
StringBuilder filename = new StringBuilder(moduleName);
if (revision.isPresent()) {
filename.append("@");
return filename.toString();
}
-}
\ No newline at end of file
+}
private final ImmutableSet<ModuleImport> moduleImports;
private final ImmutableSet<ModuleImport> dependencies;
- public YangModelDependencyInfo(String name, String formattedRevision, ImmutableSet<ModuleImport> imports,
- ImmutableSet<ModuleImport> includes) {
+ public YangModelDependencyInfo(final String name, final String formattedRevision, final ImmutableSet<ModuleImport> imports,
+ final ImmutableSet<ModuleImport> includes) {
this.name = name;
this.formattedRevision = formattedRevision;
this.revision = QName.parseRevision(formattedRevision);
}
@Override
- public boolean equals(Object obj) {
- if (this == obj)
+ public boolean equals(final Object obj) {
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (!(obj instanceof YangModelDependencyInfo))
+ }
+ if (!(obj instanceof YangModelDependencyInfo)) {
return false;
+ }
YangModelDependencyInfo other = (YangModelDependencyInfo) obj;
if (formattedRevision == null) {
- if (other.formattedRevision != null)
+ if (other.formattedRevision != null) {
return false;
- } else if (!formattedRevision.equals(other.formattedRevision))
+ }
+ } else if (!formattedRevision.equals(other.formattedRevision)) {
return false;
+ }
if (name == null) {
- if (other.name != null)
+ if (other.name != null) {
return false;
- } else if (!name.equals(other.name))
+ }
+ } else if (!name.equals(other.name)) {
return false;
+ }
return true;
}
- public static YangModelDependencyInfo fromInputStream(InputStream yangStream) {
+ public static YangModelDependencyInfo fromInputStream(final InputStream yangStream) {
YangContext yangContext = YangParserImpl.parseStreamWithoutErrorListeners(yangStream);
Optional<Module_stmtContext> moduleCtx = getFirstContext(yangContext, Module_stmtContext.class);
throw new IllegalArgumentException("Supplied stream is not valid yang file.");
}
- private static YangModelDependencyInfo fromModuleContext(Module_stmtContext module) {
+ private static YangModelDependencyInfo fromModuleContext(final Module_stmtContext module) {
String name = getArgumentString(module);
// String prefix =
// getArgumentString(module.module_header_stmts().prefix_stmt(0));
return new ModuleDependencyInfo(name, latestRevision, namespace, imports, includes);
}
- private static ImmutableSet<ModuleImport> getImports(List<Import_stmtContext> importStatements) {
+ private static ImmutableSet<ModuleImport> getImports(final List<Import_stmtContext> importStatements) {
ImmutableSet.Builder<ModuleImport> builder = ImmutableSet.builder();
for (Import_stmtContext importStmt : importStatements) {
String moduleName = getArgumentString(importStmt);
return builder.build();
}
- private static String getLatestRevision(Revision_stmtsContext revision_stmts) {
+ private static String getLatestRevision(final Revision_stmtsContext revision_stmts) {
List<Revision_stmtContext> revisions = revision_stmts.getRuleContexts(Revision_stmtContext.class);
String latestRevision = null;
for (Revision_stmtContext revisionStmt : revisions) {
return latestRevision;
}
- private static YangModelDependencyInfo fromSubmoduleContext(Submodule_stmtContext submodule) {
+ private static YangModelDependencyInfo fromSubmoduleContext(final Submodule_stmtContext submodule) {
String name = getArgumentString(submodule);
Belongs_to_stmtContext belongsToStmt = submodule.submodule_header_stmts().belongs_to_stmt(0);
String belongsTo = getArgumentString(belongsToStmt);
return new SubmoduleDependencyInfo(name, latestRevision, belongsTo, imports, includes);
}
- private static ImmutableSet<ModuleImport> getIncludes(List<Include_stmtContext> importStatements) {
+ private static ImmutableSet<ModuleImport> getIncludes(final List<Include_stmtContext> importStatements) {
ImmutableSet.Builder<ModuleImport> builder = ImmutableSet.builder();
for (Include_stmtContext importStmt : importStatements) {
String moduleName = getArgumentString(importStmt);
return builder.build();
}
- private static Date getRevision(Revision_date_stmtContext revision_date_stmt) {
+ private static Date getRevision(final Revision_date_stmtContext revision_date_stmt) {
if (revision_date_stmt == null) {
return null;
}
public static final class ModuleDependencyInfo extends YangModelDependencyInfo {
- private ModuleDependencyInfo(String name, String latestRevision, String namespace,
- ImmutableSet<ModuleImport> imports, ImmutableSet<ModuleImport> includes) {
+ private ModuleDependencyInfo(final String name, final String latestRevision, final String namespace,
+ final ImmutableSet<ModuleImport> imports, final ImmutableSet<ModuleImport> includes) {
super(name, latestRevision, imports, includes);
}
return "Module [name=" + getName() + ", revision=" + getRevision()
+ ", dependencies=" + getDependencies() + "]";
}
-
}
public static final class SubmoduleDependencyInfo extends YangModelDependencyInfo {
return belongsTo;
}
- private SubmoduleDependencyInfo(String name, String latestRevision, String belongsTo,
- ImmutableSet<ModuleImport> imports, ImmutableSet<ModuleImport> includes) {
+ private SubmoduleDependencyInfo(final String name, final String latestRevision, final String belongsTo,
+ final ImmutableSet<ModuleImport> imports, final ImmutableSet<ModuleImport> includes) {
super(name, latestRevision, imports, includes);
this.belongsTo = belongsTo;
}
return "Submodule [name=" + getName() + ", revision=" + getRevision()
+ ", dependencies=" + getDependencies() + "]";
}
-
}
private static final class ModuleImportImpl implements ModuleImport {
- private Date revision;
- private String name;
+ private final Date revision;
+ private final String name;
- public ModuleImportImpl(String moduleName, Date revision) {
+ public ModuleImportImpl(final String moduleName, final Date revision) {
this.name = moduleName;
this.revision = revision;
}
}
@Override
- public boolean equals(Object obj) {
- if (this == obj)
+ public boolean equals(final Object obj) {
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
ModuleImportImpl other = (ModuleImportImpl) obj;
if (name == null) {
- if (other.name != null)
+ if (other.name != null) {
return false;
- } else if (!name.equals(other.name))
+ }
+ } else if (!name.equals(other.name)) {
return false;
+ }
if (revision == null) {
- if (other.revision != null)
+ if (other.revision != null) {
return false;
- } else if (!revision.equals(other.revision))
+ }
+ } else if (!revision.equals(other.revision)) {
return false;
+ }
return true;
}
public String toString() {
return "ModuleImportImpl [name=" + name + ", revision=" + QName.formattedRevision(revision) + "]";
}
-
-
}
}