KotlinValueObject Class — spring-boot Architecture
Architecture documentation for the KotlinValueObject class in ValueObjectBinder.java from the spring-boot codebase.
Entity Profile
Relationship Graph
Source Code
core/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/ValueObjectBinder.java lines 266–314
private static final class KotlinValueObject<T> extends ValueObject<T> {
private static final Annotation[] ANNOTATION_ARRAY = new Annotation[0];
private final List<ConstructorParameter> constructorParameters;
private KotlinValueObject(Constructor<T> primaryConstructor, KFunction<T> kotlinConstructor,
ResolvableType type) {
super(primaryConstructor);
this.constructorParameters = parseConstructorParameters(kotlinConstructor, type);
}
private List<ConstructorParameter> parseConstructorParameters(KFunction<T> kotlinConstructor,
ResolvableType type) {
List<KParameter> parameters = kotlinConstructor.getParameters();
List<ConstructorParameter> result = new ArrayList<>(parameters.size());
for (KParameter parameter : parameters) {
String name = getParameterName(parameter);
ResolvableType parameterType = ResolvableType
.forType(ReflectJvmMapping.getJavaType(parameter.getType()), type);
Annotation[] annotations = parameter.getAnnotations().toArray(ANNOTATION_ARRAY);
Assert.state(name != null, "'name' must not be null");
result.add(new ConstructorParameter(name, parameterType, annotations));
}
return Collections.unmodifiableList(result);
}
private @Nullable String getParameterName(KParameter parameter) {
return MergedAnnotations.from(parameter, parameter.getAnnotations().toArray(ANNOTATION_ARRAY))
.get(Name.class)
.getValue(MergedAnnotation.VALUE, String.class)
.orElseGet(parameter::getName);
}
@Override
List<ConstructorParameter> getConstructorParameters() {
return this.constructorParameters;
}
static <T> @Nullable ValueObject<T> get(Constructor<T> bindConstructor, ResolvableType type,
ParameterNameDiscoverer parameterNameDiscoverer) {
KFunction<T> kotlinConstructor = ReflectJvmMapping.getKotlinFunction(bindConstructor);
if (kotlinConstructor != null) {
return new KotlinValueObject<>(bindConstructor, kotlinConstructor, type);
}
return DefaultValueObject.get(bindConstructor, type, parameterNameDiscoverer);
}
}
Domain
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free