Exemplo n.º 1
0
  /**
   * Creates package name from specified <code>basePackageName</code> (package name for module) and
   * <code>schemaPath</code>.
   *
   * <p>Resulting package name is concatenation of <code>basePackageName</code> and all local names
   * of YANG nodes which are parents of some node for which <code>schemaPath</code> is specified.
   *
   * @param basePackageName string with package name of the module
   * @param schemaPath list of names of YANG nodes which are parents of some node + name of this
   *     node
   * @param isUsesAugment boolean true if using augment
   * @return string with valid JAVA package name
   * @deprecated Use {@link #packageNameForGeneratedType(String, SchemaPath)} or {@link
   *     #packageNameForAugmentedGeneratedType(String, SchemaPath)} instead.
   */
  @Deprecated
  public static String packageNameForGeneratedType(
      final String basePackageName, final SchemaPath schemaPath, final boolean isUsesAugment) {
    if (basePackageName == null) {
      throw new IllegalArgumentException("Base Package Name cannot be NULL!");
    }
    if (schemaPath == null) {
      throw new IllegalArgumentException("Schema Path cannot be NULL!");
    }

    final Iterable<QName> iterable = schemaPath.getPathFromRoot();
    final int size = Iterables.size(iterable);
    final int traversalSteps;
    if (isUsesAugment) {
      traversalSteps = size;
    } else {
      traversalSteps = size - 1;
    }

    if (traversalSteps == 0) {
      return BindingMapping.normalizePackageName(basePackageName);
    }

    return generateNormalizedPackageName(basePackageName, iterable, traversalSteps);
  }
Exemplo n.º 2
0
  /**
   * Generates the package name for type definition from <code>typeDefinition</code> and <code>
   * basePackageName</code>.
   *
   * @param basePackageName string with the package name of the module
   * @param typeDefinition type definition for which the package name will be generated *
   * @return string with valid JAVA package name
   * @throws IllegalArgumentException
   *     <ul>
   *       <li>if <code>basePackageName</code> equals <code>null</code>
   *       <li>if <code>typeDefinition</code> equals <code>null</code>
   *     </ul>
   *
   * @deprecated This method ignores typeDefinition argument and its result is only <code>
   *     BindingMapping.normalizePackageName(basePackageName)</code>. Aside from tests, there is not
   *     a single user in OpenDaylight codebase, hence it can be considered buggy and defunct. It is
   *     scheduled for removal in Boron release.
   */
  @Deprecated
  public static String packageNameForTypeDefinition(
      final String basePackageName, final TypeDefinition<?> typeDefinition) {
    if (basePackageName == null) {
      throw new IllegalArgumentException("Base Package Name cannot be NULL!");
    }
    if (typeDefinition == null) {
      throw new IllegalArgumentException("Type Definition reference cannot be NULL!");
    }

    return BindingMapping.normalizePackageName(basePackageName);
  }
Exemplo n.º 3
0
 private static String generateNormalizedPackageName(
     final String base, final Iterable<QName> path, final int size) {
   final StringBuilder builder = new StringBuilder(base);
   final Iterator<QName> iterator = path.iterator();
   for (int i = 0; i < size; ++i) {
     builder.append('.');
     String nodeLocalName = iterator.next().getLocalName();
     // FIXME: Collon ":" is invalid in node local name as per RFC6020, identifier statement.
     builder.append(DASH_COLON_MATCHER.replaceFrom(nodeLocalName, '.'));
   }
   return BindingMapping.normalizePackageName(builder.toString());
 }
Exemplo n.º 4
0
 /**
  * Converts module name to valid JAVA package name.
  *
  * <p>The package name consists of:
  *
  * <ul>
  *   <li>prefix - <i>org.opendaylight.yang.gen.v</i>
  *   <li>module YANG version - <i>org.opendaylight.yang.gen.v</i>
  *   <li>module namespace - invalid characters are replaced with dots
  *   <li>revision prefix - <i>.rev</i>
  *   <li>revision - YYYYMMDD (MM and DD aren't spread to the whole length)
  * </ul>
  *
  * @param module module which contains data about namespace and revision date
  * @return string with the valid JAVA package name
  * @throws IllegalArgumentException if the revision date of the <code>module</code> equals <code>
  *     null</code>
  * @deprecated USe {@link BindingMapping#getRootPackageName(QNameModule)} with {@link
  *     Module#getQNameModule()}.
  */
 @Deprecated
 public static String moduleNamespaceToPackageName(final Module module) {
   return BindingMapping.getRootPackageName(module.getQNameModule());
 }