1 package org.onap.vid.model.aaiTree;
3 import org.apache.commons.proxy.Invoker;
4 import org.apache.commons.proxy.factory.javassist.JavassistProxyFactory;
5 import org.jetbrains.annotations.NotNull;
6 import org.onap.vid.exceptions.GenericUncheckedException;
8 public class FailureAAITreeNode extends AAITreeNode {
10 private static final Class[] classes = {AAITreeNode.class};
11 private static final JavassistProxyFactory proxyFactory = new JavassistProxyFactory(); // can proxy a class without an interface
13 private FailureAAITreeNode() {
14 // don't instantiate this class
18 Returns a new AAITreeNode instance that throws an exception when
19 invoking any of its methods
21 public static AAITreeNode of(Exception failureException) {
22 return (AAITreeNode) proxyFactory.createInvokerProxy(exceptionThrower(failureException), classes);
26 private static Invoker exceptionThrower(Exception exception) {
27 return (self, thisMethod, args) -> {
28 throw new GenericUncheckedException("AAI node fetching failed.", exception);