import java.util.regex.Pattern;
import javax.annotation.RegEx;
import org.opendaylight.yangtools.util.ClassLoaderUtils;
+import org.opendaylight.yangtools.yang.binding.Action;
import org.opendaylight.yangtools.yang.binding.Augmentable;
import org.opendaylight.yangtools.yang.binding.Augmentation;
import org.opendaylight.yangtools.yang.binding.BaseIdentity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@Deprecated
public final class BindingReflections {
private static final long EXPIRATION_TIME = 60;
@SuppressWarnings("checkstyle:illegalCatch")
public static QNameModule getQNameModule(final Class<?> clz) {
- if (DataContainer.class.isAssignableFrom(clz) || BaseIdentity.class.isAssignableFrom(clz)) {
+ if (DataContainer.class.isAssignableFrom(clz) || BaseIdentity.class.isAssignableFrom(clz)
+ || Action.class.isAssignableFrom(clz)) {
return findQName(clz).getModule();
}
try {
*/
public static Map<Class<?>, Method> getChildrenClassToMethod(final Class<?> type) {
checkArgument(type != null, "Target type must not be null");
- checkArgument(DataContainer.class.isAssignableFrom(type), "Supplied type must be derived from DataContainer");
+ checkArgument(DataContainer.class.isAssignableFrom(type), "Supplied type %s must be derived from DataContainer",
+ type);
Map<Class<?>, Method> ret = new HashMap<>();
for (Method method : type.getMethods()) {
Optional<Class<? extends DataContainer>> entity = getYangModeledReturnType(method);
*/
private static Optional<QName> resolveQNameNoCache(final Class<?> key) {
try {
- Field field = key.getField(BindingMapping.QNAME_STATIC_FIELD_NAME);
- Object obj = field.get(null);
+ final Field field;
+ try {
+ field = key.getField(BindingMapping.QNAME_STATIC_FIELD_NAME);
+ } catch (NoSuchFieldException e) {
+ LOG.debug("{} does not have a {} field, falling back to computation", key,
+ BindingMapping.QNAME_STATIC_FIELD_NAME, e);
+ return Optional.of(computeQName(key));
+ }
+
+ final Object obj = field.get(null);
if (obj instanceof QName) {
return Optional.of((QName) obj);
}
-
- } catch (NoSuchFieldException e) {
- return Optional.of(computeQName(key));
-
} catch (SecurityException | IllegalArgumentException | IllegalAccessException e) {
/*
- *
- * It is safe to log this this exception on debug, since this method
- * should not fail. Only failures are possible if the runtime /
- * backing.
+ * It is safe to log this this exception on debug, since this method should not fail. Only failures are
+ * possible if the runtime / backing is inconsistent.
*/
LOG.debug("Unexpected exception during extracting QName for {}", key, e);
}
return false;
}
} catch (NoSuchMethodException e) {
- // Counterpart method is missing, so classes could not be
- // substituted.
+ // Counterpart method is missing, so classes could not be substituted.
return false;
} catch (SecurityException e) {
throw new IllegalStateException("Could not compare methods", e);