import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil
import org.opendaylight.yangtools.binding.generator.util.ReferencedTypeImpl
import org.opendaylight.yangtools.binding.generator.util.Types
-import org.opendaylight.yangtools.sal.binding.generator.util.ClassLoaderUtils
import org.opendaylight.yangtools.sal.binding.generator.util.CodeGenerationException
import org.opendaylight.yangtools.sal.binding.generator.util.XtendHelper
import org.opendaylight.yangtools.sal.binding.model.api.Enumeration
import org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType
import org.opendaylight.yangtools.sal.binding.model.api.Type
import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTypeBuilder
+import org.opendaylight.yangtools.util.ClassLoaderUtils
import org.opendaylight.yangtools.yang.binding.Augmentation
import org.opendaylight.yangtools.yang.binding.BindingCodec
import org.opendaylight.yangtools.yang.binding.BindingDeserializer
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.sal.binding.generator.util;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.locks.Lock;
-
-import com.google.common.base.Joiner;
-import com.google.common.base.Optional;
-
-/**
- * @deprecated Use {@link org.opendaylight.yangtools.yang.binding.util.ClassLoaderUtils} instead.
- */
-@Deprecated
-public final class ClassLoaderUtils {
-
- private ClassLoaderUtils() {
- throw new UnsupportedOperationException("Utility class");
- }
-
- public static <V> V withClassLoader(final ClassLoader cls, final Callable<V> function) throws Exception {
- checkNotNull(cls, "Classloader should not be null");
- checkNotNull(function, "Function should not be null");
-
- final ClassLoader oldCls = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(cls);
- return function.call();
- } finally {
- Thread.currentThread().setContextClassLoader(oldCls);
- }
- }
-
- public static <V> V withClassLoaderAndLock(final ClassLoader cls, final Lock lock, final Callable<V> function) throws Exception {
- checkNotNull(lock, "Lock should not be null");
-
- lock.lock();
- try {
- return withClassLoader(cls, function);
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * @deprecated Use one of the other utility methods.
- */
- @Deprecated
- public static <V> V withClassLoaderAndLock(final ClassLoader cls, final Optional<Lock> lock, final Callable<V> function) throws Exception {
- if (lock.isPresent()) {
- return withClassLoaderAndLock(cls, lock.get(), function);
- } else {
- return withClassLoader(cls, function);
- }
- }
-
- public static Object construct(final Constructor<? extends Object> constructor, final List<Object> objects)
- throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
- Object[] initargs = objects.toArray(new Object[] {});
- return constructor.newInstance(initargs);
- }
-
-
- public static Class<?> loadClass(final ClassLoader cls, final String name) throws ClassNotFoundException {
- if ("byte[]".equals(name)) {
- return byte[].class;
- } else if("char[]".equals(name)) {
- return char[].class;
- }
- try {
- return cls.loadClass(name);
- } catch (ClassNotFoundException e) {
- String[] components = name.split("\\.");
- String potentialOuter;
- int length = components.length;
- if (length > 2 && (potentialOuter = components[length - 2]) != null && Character.isUpperCase(potentialOuter.charAt(0))) {
-
- String outerName = Joiner.on(".").join(Arrays.asList(components).subList(0, length - 1));
- String innerName = outerName + "$" + components[length-1];
- return cls.loadClass(innerName);
- } else {
- throw e;
- }
- }
- }
-
- public static Class<?> loadClassWithTCCL(final String name) throws ClassNotFoundException {
- return loadClass(Thread.currentThread().getContextClassLoader(), name);
- }
-
- public static Class<?> tryToLoadClassWithTCCL(final String fullyQualifiedName) {
- try {
- return loadClassWithTCCL(fullyQualifiedName);
- } catch (ClassNotFoundException e) {
- return null;
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.concepts.util;
-
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.concurrent.Callable;
-import java.util.concurrent.locks.Lock;
-
-/**
- * @deprecated Use {@link org.opendaylight.yangtools.yang.binding.util.ClassLoaderUtils} instead.
- */
-@Deprecated
-public final class ClassLoaderUtils {
-
- private ClassLoaderUtils() {
- throw new UnsupportedOperationException("Utility class");
- }
-
- public static <V> V withClassLoader(final ClassLoader cls, final Callable<V> function) throws Exception {
- return withClassLoaderAndLock(cls, null, function);
- }
-
- public static <V> V withClassLoaderAndLock(final ClassLoader cls, final Lock lock, final Callable<V> function) throws Exception {
- if (cls == null) {
- throw new IllegalArgumentException("Classloader should not be null");
- }
- if (function == null) {
- throw new IllegalArgumentException("Function should not be null");
- }
-
- if (lock != null) {
- lock.lock();
- }
- ClassLoader oldCls = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(cls);
- return function.call();
- } finally {
- Thread.currentThread().setContextClassLoader(oldCls);
- if (lock != null) {
- lock.unlock();
- }
- }
- }
-
- public static ParameterizedType findParameterizedType(final Class<?> subclass, final Class<?> genericType) {
- if(subclass == null || genericType == null) {
- throw new IllegalArgumentException("Class was not specified.");
- }
- for (Type type : subclass.getGenericInterfaces()) {
- if (type instanceof ParameterizedType && genericType.equals(((ParameterizedType) type).getRawType())) {
- return (ParameterizedType) type;
- }
- }
- return null;
- }
-
- public static <S,G,P> Class<P> findFirstGenericArgument(final Class<S> scannedClass, final Class<G> genericType) {
- try {
- return withClassLoader(scannedClass.getClassLoader(), ClassLoaderUtils.<S,G,P>findFirstGenericArgumentTask(scannedClass, genericType));
- } catch (Exception e) {
- return null;
- }
- }
-
- private static <S,G,P> Callable<Class<P>> findFirstGenericArgumentTask(final Class<S> scannedClass, final Class<G> genericType) {
- return new Callable<Class<P>>() {
- @Override
- @SuppressWarnings("unchecked")
- public Class<P> call() throws Exception {
- final ParameterizedType augmentationGeneric = findParameterizedType(scannedClass,
- genericType);
- if (augmentationGeneric == null) {
- return null;
- }
- return (Class<P>) augmentationGeneric.getActualTypeArguments()[0];
- }
- };
- }
-
- public static Type getFirstGenericParameter(final Type type) {
- if(type instanceof ParameterizedType) {
- return ((ParameterizedType) type).getActualTypeArguments()[0];
- }
- return null;
- }
-
-}
\ No newline at end of file
import java.util.EventListener;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+
import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
-
+/**
+ * @deprecated Use {@link org.opendaylight.yangtools.util.ListenerRegistry} instead.
+ *
+ * @param <T>
+ */
+@Deprecated
public class ListenerRegistry<T extends EventListener> implements Iterable<ListenerRegistration<T>> {
private final ConcurrentHashMap<ListenerRegistration<? extends T>,ListenerRegistration<? extends T>> listeners;
return unmodifiableView;
}
- public ListenerRegistration<T> register(T listener) {
+ public ListenerRegistration<T> register(final T listener) {
if (listener == null) {
throw new IllegalArgumentException("Listener should not be null.");
}
listeners.put(ret,ret);
return ret;
}
-
- public <L extends T> ListenerRegistration<L> registerWithType(L listener) {
+
+ public <L extends T> ListenerRegistration<L> registerWithType(final L listener) {
ListenerRegistrationImpl<L> ret = new ListenerRegistrationImpl<L>(listener);
listeners.put(ret,ret);
return ret;
}
-
+
@Override
public java.util.Iterator<ListenerRegistration<T>> iterator() {
return unmodifiableView.iterator();
}
@SuppressWarnings("rawtypes")
- private void remove(ListenerRegistrationImpl registration) {
+ private void remove(final ListenerRegistrationImpl registration) {
listeners.remove(registration);
}
- private class ListenerRegistrationImpl<P extends EventListener> //
- extends AbstractObjectRegistration<P> //
- implements ListenerRegistration<P> {
+ private class ListenerRegistrationImpl<P extends EventListener> extends AbstractObjectRegistration<P> implements ListenerRegistration<P> {
- public ListenerRegistrationImpl(P instance) {
+ public ListenerRegistrationImpl(final P instance) {
super(instance);
}
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.util;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Supplier;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.Callable;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class ClassLoaderUtils {
+ private static final Logger LOG = LoggerFactory.getLogger(ClassLoaderUtils.class);
+
+ private ClassLoaderUtils() {
+ throw new UnsupportedOperationException("Utility class");
+ }
+
+ /**
+ *
+ * Runs {@link Supplier} with provided {@link ClassLoader}.
+ *
+ * Invokes supplies function and makes sure that original {@link ClassLoader}
+ * is context {@link ClassLoader} after execution.
+ *
+ * @param cls {@link ClassLoader} to be used.
+ * @param function Function to be executed.
+ * @return Result of supplier invocation.
+ *
+ */
+ public static <V> V withClassLoader(final ClassLoader cls, final Supplier<V> function) {
+ checkNotNull(cls, "Classloader should not be null");
+ checkNotNull(function, "Function should not be null");
+
+ final ClassLoader oldCls = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(cls);
+ return function.get();
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldCls);
+ }
+ }
+
+ /**
+ *
+ * Runs {@link Callable} with provided {@link ClassLoader}.
+ *
+ * Invokes supplies function and makes sure that original {@link ClassLoader}
+ * is context {@link ClassLoader} after execution.
+ *
+ * @param cls {@link ClassLoader} to be used.
+ * @param function Function to be executed.
+ * @return Result of callable invocation.
+ *
+ */
+ public static <V> V withClassLoader(final ClassLoader cls, final Callable<V> function) throws Exception {
+ checkNotNull(cls, "Classloader should not be null");
+ checkNotNull(function, "Function should not be null");
+
+ final ClassLoader oldCls = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(cls);
+ return function.call();
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldCls);
+ }
+ }
+
+ public static Object construct(final Constructor<? extends Object> constructor, final List<Object> objects)
+ throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ final Object[] initargs = objects.toArray();
+ return constructor.newInstance(initargs);
+ }
+
+ /**
+ *
+ * Loads class using this supplied classloader.
+ *
+ *
+ * @param cls
+ * @param name String name of class.
+ * @return
+ * @throws ClassNotFoundException
+ */
+ public static Class<?> loadClass(final ClassLoader cls, final String name) throws ClassNotFoundException {
+ if ("byte[]".equals(name)) {
+ return byte[].class;
+ }
+ if ("char[]".equals(name)) {
+ return char[].class;
+ }
+
+ try {
+ return cls.loadClass(name);
+ } catch (ClassNotFoundException e) {
+ String[] components = name.split("\\.");
+ String potentialOuter;
+ int length = components.length;
+ if (length > 2 && (potentialOuter = components[length - 2]) != null && Character.isUpperCase(potentialOuter.charAt(0))) {
+ String outerName = Joiner.on(".").join(Arrays.asList(components).subList(0, length - 1));
+ String innerName = outerName + "$" + components[length-1];
+ return cls.loadClass(innerName);
+ } else {
+ throw e;
+ }
+ }
+ }
+
+ public static Class<?> loadClassWithTCCL(final String name) throws ClassNotFoundException {
+ return loadClass(Thread.currentThread().getContextClassLoader(), name);
+ }
+
+ public static Class<?> tryToLoadClassWithTCCL(final String fullyQualifiedName) {
+ try {
+ return loadClassWithTCCL(fullyQualifiedName);
+ } catch (ClassNotFoundException e) {
+ LOG.debug("Failed to load class {}", fullyQualifiedName, e);
+ return null;
+ }
+ }
+
+ public static <S,G,P> Class<P> findFirstGenericArgument(final Class<S> scannedClass, final Class<G> genericType) {
+ return withClassLoader(scannedClass.getClassLoader(), ClassLoaderUtils.<S,G,P>findFirstGenericArgumentTask(scannedClass, genericType));
+ }
+
+ private static <S,G,P> Supplier<Class<P>> findFirstGenericArgumentTask(final Class<S> scannedClass, final Class<G> genericType) {
+ return new Supplier<Class<P>>() {
+ @Override
+ @SuppressWarnings("unchecked")
+ public Class<P> get() {
+ final ParameterizedType augmentationGeneric = findParameterizedType(scannedClass, genericType);
+ if (augmentationGeneric != null) {
+ return (Class<P>) augmentationGeneric.getActualTypeArguments()[0];
+ }
+ return null;
+ }
+ };
+ }
+
+ public static ParameterizedType findParameterizedType(final Class<?> subclass, final Class<?> genericType) {
+ Preconditions.checkNotNull(subclass);
+ Preconditions.checkNotNull(genericType);
+
+ for (Type type : subclass.getGenericInterfaces()) {
+ if (type instanceof ParameterizedType && genericType.equals(((ParameterizedType) type).getRawType())) {
+ return (ParameterizedType) type;
+ }
+ }
+
+ LOG.debug("Class {} does not declare interface {}", subclass, genericType);
+ return null;
+ }
+
+ public static Type getFirstGenericParameter(final Type type) {
+ if (type instanceof ParameterizedType) {
+ return ((ParameterizedType) type).getActualTypeArguments()[0];
+ }
+ return null;
+ }
+}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.yangtools.concepts.util;
+package org.opendaylight.yangtools.util;
import java.math.BigDecimal;
import java.math.BigInteger;
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.util;
+
+
+import java.util.Collections;
+import java.util.EventListener;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+
+
+public class ListenerRegistry<T extends EventListener> implements Iterable<ListenerRegistration<T>> {
+
+ private final ConcurrentHashMap<ListenerRegistration<? extends T>,ListenerRegistration<? extends T>> listeners;
+ final Set<ListenerRegistration<T>> unmodifiableView;
+
+ @SuppressWarnings("unchecked")
+ public ListenerRegistry() {
+ listeners = new ConcurrentHashMap<>();
+ // This conversion is known to be safe.
+ @SuppressWarnings("rawtypes")
+ final Set rawSet = Collections.unmodifiableSet(listeners.keySet());
+ unmodifiableView = rawSet;
+ }
+
+ public Iterable<ListenerRegistration<T>> getListeners() {
+ return unmodifiableView;
+ }
+
+ public ListenerRegistration<T> register(T listener) {
+ if (listener == null) {
+ throw new IllegalArgumentException("Listener should not be null.");
+ }
+ ListenerRegistrationImpl<T> ret = new ListenerRegistrationImpl<T>(listener);
+ listeners.put(ret,ret);
+ return ret;
+ }
+
+ public <L extends T> ListenerRegistration<L> registerWithType(L listener) {
+ ListenerRegistrationImpl<L> ret = new ListenerRegistrationImpl<L>(listener);
+ listeners.put(ret,ret);
+ return ret;
+ }
+
+ @Override
+ public java.util.Iterator<ListenerRegistration<T>> iterator() {
+ return unmodifiableView.iterator();
+ }
+
+ @SuppressWarnings("rawtypes")
+ private void remove(ListenerRegistrationImpl registration) {
+ listeners.remove(registration);
+ }
+
+ private class ListenerRegistrationImpl<P extends EventListener> //
+ extends AbstractObjectRegistration<P> //
+ implements ListenerRegistration<P> {
+
+ public ListenerRegistrationImpl(P instance) {
+ super(instance);
+ }
+
+ @Override
+ protected void removeRegistration() {
+ ListenerRegistry.this.remove(this);
+ }
+ }
+
+ public static <T extends EventListener> ListenerRegistry<T> create() {
+ return new ListenerRegistry<>();
+ }
+}
import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.base.Joiner;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Supplier;
+
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.ParameterizedType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Joiner;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Supplier;
-
+/**
+ * @deprecated Use {@link org.opendaylight.yangtools.util.ClassLoaderUtils} instead.
+ */
+@Deprecated
public final class ClassLoaderUtils {
private static final Logger LOG = LoggerFactory.getLogger(ClassLoaderUtils.class);
}
/**
- *
- * Runs {@link Callable} with provided {@link ClassLoader}.
- *
- * Invokes supplies function and makes sure that original {@link ClassLoader}
- * is context {@link ClassLoader} after execution.
- *
- * @param cls {@link ClassLoader} to be used.
- * @param function Function to be executed.
- * @return Result of callable invocation.
- *
- */
+ *
+ * Runs {@link Callable} with provided {@link ClassLoader}.
+ *
+ * Invokes supplies function and makes sure that original {@link ClassLoader}
+ * is context {@link ClassLoader} after execution.
+ *
+ * @param cls {@link ClassLoader} to be used.
+ * @param function Function to be executed.
+ * @return Result of callable invocation.
+ *
+ */
public static <V> V withClassLoader(final ClassLoader cls, final Callable<V> function) throws Exception {
checkNotNull(cls, "Classloader should not be null");
checkNotNull(function, "Function should not be null");
}
}
- /**
- *
- * Runs {@link Callable} with provided {@link ClassLoader} and Lock.
- *
- * Invokes supplies function after acquiring lock
- * and makes sure that original {@link ClassLoader}
- * is context {@link ClassLoader} and lock is unlocked
- * after execution.
- *
- * @param cls {@link ClassLoader} to be used.
- * @param function Function to be executed.
- * @return Result of Callable invocation.
- *
- */
+ /**
+ *
+ * Runs {@link Callable} with provided {@link ClassLoader} and Lock.
+ *
+ * Invokes supplies function after acquiring lock
+ * and makes sure that original {@link ClassLoader}
+ * is context {@link ClassLoader} and lock is unlocked
+ * after execution.
+ *
+ * @param cls {@link ClassLoader} to be used.
+ * @param function Function to be executed.
+ * @return Result of Callable invocation.
+ *
+ */
public static <V> V withClassLoaderAndLock(final ClassLoader cls, final Lock lock, final Supplier<V> function) {
checkNotNull(lock, "Lock should not be null");
String potentialOuter;
int length = components.length;
if (length > 2 && (potentialOuter = components[length - 2]) != null && Character.isUpperCase(potentialOuter.charAt(0))) {
- String outerName = Joiner.on(".").join(Arrays.asList(components).subList(0, length - 1));
- String innerName = outerName + "$" + components[length-1];
- return cls.loadClass(innerName);
+ String outerName = Joiner.on(".").join(Arrays.asList(components).subList(0, length - 1));
+ String innerName = outerName + "$" + components[length-1];
+ return cls.loadClass(innerName);
} else {
throw e;
}
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>test-parent</artifactId>
- <version>1.0</version>
+ <version>0.6.2-SNAPSHOT</version>
</parent>
<artifactId>additional-config</artifactId>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
</dependency>
</dependencies>
<plugin>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<type>test-jar</type>
</dependency>
</dependencies>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>test-parent</artifactId>
- <version>1.0</version>
+ <version>0.6.2-SNAPSHOT</version>
</parent>
<artifactId>correct</artifactId>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
</dependency>
</dependencies>
<plugin>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<type>test-jar</type>
</dependency>
</dependencies>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>test-parent</artifactId>
- <version>1.0</version>
+ <version>0.6.2-SNAPSHOT</version>
</parent>
<artifactId>generator-test1</artifactId>
<plugin>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<type>test-jar</type>
</dependency>
</dependencies>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>test-parent</artifactId>
- <version>1.0</version>
+ <version>0.6.2-SNAPSHOT</version>
</parent>
<artifactId>generator-test2</artifactId>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>generator-test1</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<scope>system</scope>
- <systemPath>${project.basedir}/../GenerateTest1/target/generator-test1-1.0.jar</systemPath>
+ <systemPath>${project.basedir}/../GenerateTest1/target/generator-test1-${project.version}.jar</systemPath>
</dependency>
</dependencies>
<plugin>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<type>test-jar</type>
</dependency>
</dependencies>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>test-parent</artifactId>
- <version>1.0</version>
+ <version>0.6.2-SNAPSHOT</version>
</parent>
<artifactId>generator</artifactId>
<plugin>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<type>test-jar</type>
</dependency>
</dependencies>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>test-parent</artifactId>
- <version>1.0</version>
+ <version>0.6.2-SNAPSHOT</version>
</parent>
<artifactId>invalid-version</artifactId>
<plugin>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<type>test-jar</type>
</dependency>
</dependencies>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>test-parent</artifactId>
- <version>1.0</version>
+ <version>0.6.2-SNAPSHOT</version>
</parent>
<artifactId>missing-yang-in-dep</artifactId>
<plugin>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<type>test-jar</type>
</dependency>
</dependencies>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>test-parent</artifactId>
- <version>1.0</version>
+ <version>0.6.2-SNAPSHOT</version>
</parent>
<artifactId>naming-conflict</artifactId>
<plugin>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>maven-sal-api-gen-plugin</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<type>jar</type>
</dependency>
</dependencies>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>test-parent</artifactId>
- <version>1.0</version>
+ <version>0.6.2-SNAPSHOT</version>
</parent>
<artifactId>no-generators</artifactId>
<plugin>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<executions>
<execution>
<goals>
<goal>generate-sources</goal>
</goals>
- <configuration>
+ <configuration combine.self="override">
<yangFilesRootDir>../files</yangFilesRootDir>
<inspectDependencies>false</inspectDependencies>
<codeGenerators>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<type>test-jar</type>
</dependency>
</dependencies>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>test-parent</artifactId>
- <version>1.0</version>
+ <version>0.6.2-SNAPSHOT</version>
</parent>
<artifactId>no-output-dir</artifactId>
<plugin>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<type>test-jar</type>
</dependency>
</dependencies>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>test-parent</artifactId>
- <version>1.0</version>
+ <version>0.6.2-SNAPSHOT</version>
</parent>
<artifactId>no-yang-files</artifactId>
<plugin>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<type>test-jar</type>
</dependency>
</dependencies>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>test-parent</artifactId>
- <version>1.0</version>
+ <version>0.6.2-SNAPSHOT</version>
</parent>
<artifactId>unknown-generator</artifactId>
<plugin>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<type>test-jar</type>
</dependency>
</dependencies>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>test-parent</artifactId>
- <version>1.0</version>
+ <version>0.6.2-SNAPSHOT</version>
</parent>
<artifactId>yang-root-not-exist</artifactId>
<plugin>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>${it-project.version}</version>
+ <version>${project.version}</version>
<executions>
<execution>
<goals>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yangtools-parent</artifactId>
+ <version>0.6.2-SNAPSHOT</version>
+ <relativePath>/../../common/parent/pom.xml</relativePath>
+ </parent>
+
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>test-parent</artifactId>
- <version>1.0</version>
<packaging>pom</packaging>
- <properties>
- <it-project.version>0.6.2-SNAPSHOT</it-project.version>
- </properties>
-
<modules>
<module>additional-config</module>
<module>correct</module>
if (parent instanceof TypeDefinitionBuilder) {
TypeDefinitionBuilder typedef = (TypeDefinitionBuilder) parent;
- typedef.setRanges(rangeStatements);
- typedef.setLengths(lengthStatements);
- typedef.setPatterns(patternStatements);
- typedef.setFractionDigits(fractionDigits);
+ if (!(typedef instanceof UnionTypeBuilder)) {
+ typedef.setRanges(rangeStatements);
+ typedef.setLengths(lengthStatements);
+ typedef.setPatterns(patternStatements);
+ typedef.setFractionDigits(fractionDigits);
+ }
return unknownType.build();
} else {
TypeDefinition<?> baseType = unknownType.build();
import java.io.File;
import java.math.BigInteger;
import java.net.URI;
+import java.util.Arrays;
import java.util.List;
import java.util.Set;
import org.junit.Before;
assertNotNull(type);
}
+ @Test
+ public void testUnionWithExt() throws Exception {
+ File extdef = new File(getClass().getResource("/types/union-with-ext/extdef.yang").toURI());
+ File unionbug = new File(getClass().getResource("/types/union-with-ext/unionbug.yang").toURI());
+ File inet = new File(getClass().getResource("/ietf/ietf-inet-types@2010-09-24.yang").toURI());
+ YangContextParser parser = new YangParserImpl();
+ parser.parseFiles(Arrays.asList(extdef, unionbug, inet));
+ }
+
}
--- /dev/null
+module "extdef" {
+ yang-version 1;
+ namespace "urn:test:bug:extdef";
+ prefix "extdef";
+
+ revision 2012-04-16 {
+ }
+
+ extension "help" {
+ argument "text";
+ }
+
+}
--- /dev/null
+module unionbug {
+ yang-version 1;
+ namespace "urn:test:bug:unionbug";
+ prefix "unionbug";
+
+ import extdef {
+ prefix extdef;
+ }
+
+ import ietf-inet-types {
+ prefix "inet";
+ }
+
+ revision 2012-04-16 {
+ }
+
+ typedef address {
+ type union {
+ type inet:ip-address {
+ extdef:help "IP address";
+ }
+ type inet:ip-prefix {
+ extdef:help "Subnet";
+ }
+ type string {
+ extdef:help "Address name";
+ }
+ }
+ }
+
+}