Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,6 +30,7 @@ public class ValueCodeGenerationException extends RuntimeException {
|
||||
@Nullable
|
||||
private final Object value;
|
||||
|
||||
|
||||
protected ValueCodeGenerationException(String message, @Nullable Object value, @Nullable Throwable cause) {
|
||||
super(message, cause);
|
||||
this.value = value;
|
||||
@@ -49,9 +50,9 @@ public class ValueCodeGenerationException extends RuntimeException {
|
||||
return message.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the value that failed to be generated.
|
||||
* @return the value
|
||||
*/
|
||||
@Nullable
|
||||
public Object getValue() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,20 +33,24 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public final class ValueCodeGenerator {
|
||||
|
||||
private static final ValueCodeGenerator INSTANCE = new ValueCodeGenerator(ValueCodeGeneratorDelegates.INSTANCES, null);
|
||||
private static final ValueCodeGenerator INSTANCE =
|
||||
new ValueCodeGenerator(ValueCodeGeneratorDelegates.INSTANCES, null);
|
||||
|
||||
private static final CodeBlock NULL_VALUE_CODE_BLOCK = CodeBlock.of("null");
|
||||
|
||||
|
||||
private final List<Delegate> delegates;
|
||||
|
||||
@Nullable
|
||||
private final GeneratedMethods generatedMethods;
|
||||
|
||||
|
||||
private ValueCodeGenerator(List<Delegate> delegates, @Nullable GeneratedMethods generatedMethods) {
|
||||
this.delegates = delegates;
|
||||
this.generatedMethods = generatedMethods;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return an instance that provides support for {@linkplain
|
||||
* ValueCodeGeneratorDelegates#INSTANCES common value types}.
|
||||
@@ -75,6 +79,7 @@ public final class ValueCodeGenerator {
|
||||
return new ValueCodeGenerator(new ArrayList<>(delegates), null);
|
||||
}
|
||||
|
||||
|
||||
public ValueCodeGenerator add(List<Delegate> additionalDelegates) {
|
||||
Assert.notEmpty(additionalDelegates, "AdditionalDelegates must not be empty");
|
||||
List<Delegate> allDelegates = new ArrayList<>(this.delegates);
|
||||
@@ -117,7 +122,6 @@ public final class ValueCodeGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the {@link GeneratedMethods} that represents the scope
|
||||
* in which code generated by this instance will be added, or
|
||||
@@ -129,6 +133,7 @@ public final class ValueCodeGenerator {
|
||||
return this.generatedMethods;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Strategy interface that can be used to implement code generation for a
|
||||
* particular value type.
|
||||
@@ -146,7 +151,6 @@ public final class ValueCodeGenerator {
|
||||
*/
|
||||
@Nullable
|
||||
CodeBlock generateCode(ValueCodeGenerator valueCodeGenerator, Object value);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user