Skip to content
This repository was archived by the owner on Jun 19, 2024. It is now read-only.

Commit 9794f78

Browse files
committed
Add last missing docs
1 parent a1de487 commit 9794f78

3 files changed

Lines changed: 25 additions & 3 deletions

File tree

ultralight-java-databind-generated-callers/src/main/java/com/labymedia/ultralight/databind/call/property/generated/PropertyCallerGenerator.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
import java.util.UUID;
3838
import java.util.function.Consumer;
3939

40+
/**
41+
* Generates certain {@link SingleGeneratedPropertyCaller}s.
42+
*/
4043
public class PropertyCallerGenerator {
4144

4245
private static final Class<?> GENERATION_INTERFACE = SingleGeneratedPropertyCaller.class;
@@ -121,6 +124,7 @@ public SingleGeneratedPropertyCaller generateConstructorCaller(Constructor<?> co
121124
public SingleGeneratedPropertyCaller generateFieldCaller(Field field) throws NotFoundException, CannotCompileException, IOException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
122125
Class<?> type = field.getType();
123126

127+
// when the caller is called with arguments, the field value will be set to the first argument
124128
StringBuilder methodContentBuilder = new StringBuilder("if (")
125129
.append(PARAMETERS_PARAMETER_NAME)
126130
.append(" != null && ")
@@ -136,6 +140,7 @@ public SingleGeneratedPropertyCaller generateFieldCaller(Field field) throws Not
136140
.append(";")
137141
.append(" return null; } return ");
138142

143+
// when no arguments are present, just return the field value
139144
this.wrapPrimitiveType(methodContentBuilder, type, builder ->
140145
this.castInstance(builder, field.getDeclaringClass(), field.getModifiers())
141146
.append(".")
@@ -211,6 +216,9 @@ private StringBuilder castParameter(StringBuilder builder, Class<?> type, int in
211216
.append(")");
212217

213218
if (isWrapped) {
219+
// unwrapping the wrapper type to its primitive
220+
// this is necessary to avoid verify errors,
221+
// the javassist compiler has some issues with primitives and their wrappers
214222
builder.append(".")
215223
.append(type.getName())
216224
.append("Value()");
@@ -250,6 +258,9 @@ private StringBuilder wrapPrimitiveType(StringBuilder builder, Class<?> type, Co
250258
boolean isWrapped = wrappedType != null;
251259

252260
if (isWrapped) {
261+
// wrapping primitive type to its wrapper
262+
// this is necessary to avoid verify errors,
263+
// the javassist compiler has some issues with primitives and their wrappers
253264
builder.append(wrappedType.getName())
254265
.append(".valueOf(");
255266
}

ultralight-java-databind/src/main/java/com/labymedia/ultralight/databind/DatabindConfiguration.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public final class DatabindConfiguration {
4343
*
4444
* @param classCache The class cache used by this configuration
4545
* @param methodChooser The method chooser used by this configuration
46-
* @param propertyCallerFactory
46+
* @param propertyCallerFactory The factory creating the property caller used for calling properties on java objects and classes
4747
* @param automaticPrototype If {@code true}, automatic prototyping is enabled
4848
* @param contextProviderFactory The factory for binding context providers, or {@code null}, if this feature
4949
*/
@@ -79,6 +79,11 @@ public MethodChooser methodChooser() {
7979
return methodChooser;
8080
}
8181

82+
/**
83+
* Retrieves the property caller used for calling properties on java objects and classes.
84+
*
85+
* @return The property caller used for calling properties on java objects and classes
86+
*/
8287
public PropertyCaller.Factory propertyCallerFactory() {
8388
return propertyCallerFactory;
8489
}
@@ -153,6 +158,12 @@ public Builder methodChooser(MethodChooser methodChooser) {
153158
return this;
154159
}
155160

161+
/**
162+
* Sets the property caller used for calling properties on java objects and classes.
163+
*
164+
* @param propertyCallerFactory The property caller to use
165+
* @return this
166+
*/
156167
public Builder propertyCallerFactory(PropertyCaller.Factory propertyCallerFactory) {
157168
this.propertyCallerFactory = propertyCallerFactory;
158169
return this;

ultralight-java-databind/src/main/java/com/labymedia/ultralight/databind/DatabindJavascriptMethodHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public final class DatabindJavascriptMethodHandler {
5454
*
5555
* @param configuration The configuration to use
5656
* @param conversionUtils The conversion utilities to use for converting objects
57-
* @param propertyCaller
57+
* @param propertyCaller The property caller used for calling properties on java objects and classes
5858
* @param methodSet The methods which can be invoked by this handler
5959
* @param name The name of this handler class
6060
*/
@@ -164,7 +164,7 @@ public JavascriptClass bake() {
164164
*
165165
* @param configuration The configuration to use
166166
* @param conversionUtils The conversion utilities to user for converting objects
167-
* @param propertyCaller
167+
* @param propertyCaller The property caller used for calling properties on java objects and classes
168168
* @param methodSet The sets of methods invocable by this handler
169169
* @param name The name of this handler class
170170
* @return The created handler

0 commit comments

Comments
 (0)