MappedInvocationHandler Class — spring-boot Architecture
Architecture documentation for the MappedInvocationHandler class in MappedObject.java from the spring-boot codebase.
Entity Profile
Relationship Graph
Source Code
buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/json/MappedObject.java lines 220–272
private static class MappedInvocationHandler implements InvocationHandler {
private static final String GET = "get";
private static final String IS = "is";
private final MappedObject root;
private final JsonNode node;
private final Lookup lookup;
MappedInvocationHandler(MappedObject root, JsonNode node, Lookup lookup) {
this.root = root;
this.node = node;
this.lookup = lookup;
}
@Override
public @Nullable Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Class<?> declaringClass = method.getDeclaringClass();
if (method.isDefault()) {
Lookup lookup = this.lookup.in(declaringClass);
MethodHandle methodHandle = lookup.unreflectSpecial(method, declaringClass).bindTo(proxy);
return methodHandle.invokeWithArguments();
}
if (declaringClass == Object.class) {
method.invoke(proxy, args);
}
Assert.state(args == null || args.length == 0, () -> "Unsupported method " + method);
String name = getName(method.getName());
Class<?> type = method.getReturnType();
return valueForProperty(name, type);
}
private String getName(String name) {
StringBuilder result = new StringBuilder(name);
if (name.startsWith(GET)) {
result = new StringBuilder(name.substring(GET.length()));
}
if (name.startsWith(IS)) {
result = new StringBuilder(name.substring(IS.length()));
}
Assert.state(result.length() >= 0, "Missing name");
result.setCharAt(0, Character.toLowerCase(result.charAt(0)));
return result.toString();
}
private @Nullable Object valueForProperty(String name, Class<?> type) {
return valueAt(this.root, this.node, this.lookup, "/" + name, type);
}
}
Domain
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free