import com.google.common.annotations.Beta;
import java.io.Serial;
+import org.eclipse.jdt.annotation.NonNull;
/**
* Thrown where incorrect nesting of data structures was detected and was caused by user. This typically indicates
super(message);
}
- public static IncorrectNestingException create(final String message, final Object... args) {
- return new IncorrectNestingException(String.format(message, args));
+ public IncorrectNestingException(final String message, final Object... args) {
+ this(message.formatted(args));
+ }
+
+ @Deprecated(since = "12.0.0", forRemoval = true)
+ public static @NonNull IncorrectNestingException create(final String message, final Object... args) {
+ return new IncorrectNestingException(message, args);
}
}
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableSet;
+import edu.umd.cs.findbugs.annotations.CheckReturnValue;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
return nullable;
}
+ @CheckReturnValue
private IllegalArgumentException childNullException(final QName child, final String message, final Object... args) {
final QNameModule module = child.getModule();
if (!factory().getRuntimeContext().getEffectiveModelContext().findModule(module).isPresent()) {
- throw new MissingSchemaException("Module " + module + " is not present in current schema context.");
+ return new MissingSchemaException("Module " + module + " is not present in current schema context.");
}
- throw IncorrectNestingException.create(message, args);
+ return new IncorrectNestingException(message, args);
}
- private IllegalArgumentException childNullException(final Class<?> childClass, final String message,
+ @CheckReturnValue
+ private @NonNull IllegalArgumentException childNullException(final Class<?> childClass, final String message,
final Object... args) {
- final BindingRuntimeContext runtimeContext = factory().getRuntimeContext();
+ return childNullException(factory().getRuntimeContext(), childClass, message, args);
+ }
+
+ @CheckReturnValue
+ private static @NonNull IllegalArgumentException childNullException(final BindingRuntimeContext runtimeContext,
+ final Class<?> childClass, final String message, final Object... args) {
final CompositeRuntimeType schema;
if (Augmentation.class.isAssignableFrom(childClass)) {
schema = runtimeContext.getAugmentationDefinition(childClass.asSubclass(Augmentation.class));
schema = runtimeContext.getSchemaDefinition(childClass);
}
if (schema == null) {
- throw new MissingSchemaForClassException(childClass);
+ return new MissingSchemaForClassException(childClass);
}
try {
runtimeContext.loadClass(Type.of(childClass));
} catch (final ClassNotFoundException e) {
- throw new MissingClassInLoadingStrategyException(
+ return new MissingClassInLoadingStrategyException(
"User supplied class " + childClass.getName() + " is not available in " + runtimeContext, e);
}
- throw IncorrectNestingException.create(message, args);
+ return new IncorrectNestingException(message, args);
}
private static QName extractName(final YangInstanceIdentifier.PathArgument child) {