Skip to content

Commit 489b79a

Browse files
authored
Update java-extension.md
1 parent 3d1437a commit 489b79a

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

java-extension.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ iter.read(Date.class); // Sat Dec 10 18:19:50 CST 2016
4747

4848
Generic types can also be customized by `TypeLiteral`. Here is an example:
4949

50-
```
50+
```java
5151
TypeLiteral<List<Integer>> listOfIntType = new TypeLiteral<List<Integer>>() {
5252
};
5353
JsonIterator.registerTypeDecoder(listOfIntType, new Decoder() {
@@ -137,7 +137,7 @@ The callback `updateBinding` change the data source or decoder for a field. The
137137

138138
The input is a concept called `Binding`, which not only represent field, but also constructor parameter and setter parameter. It contains the necessary information about what is binding, and you can customize how to bind it:
139139

140-
```
140+
```java
141141
public class Binding {
142142
// input
143143
public Class clazz;
@@ -187,7 +187,7 @@ public class MyAnnotationSupport extends EmptyExtension {
187187

188188
Then you can annotate
189189

190-
```
190+
```java
191191
public static class AnnotatedObject {
192192
@JsonProperty("field-1")
193193
public int field1;
@@ -229,7 +229,7 @@ public class CustomizedConstructor {
229229

230230
Using this extension point, `@JsonCreator` annotation support has been implemented. You can mark it on constructor:
231231

232-
```
232+
```java
233233
public static class NoDefaultCtor {
234234
private int field1;
235235

@@ -242,7 +242,7 @@ public static class NoDefaultCtor {
242242

243243
Or, you can mark it on static method:
244244

245-
```
245+
```java
246246
public static class StaticFactory {
247247

248248
private int field1;
@@ -273,7 +273,7 @@ The binding is done in this sequence
273273

274274
By default, methods like `setName(val)` will be caleld with field value from `name`. You can choose to use other kinds of methods as setters. For example
275275

276-
```
276+
```java
277277
public static class WithSetter {
278278

279279
private int field1;
@@ -289,7 +289,7 @@ public static class WithSetter {
289289

290290
This annotation support is implemented by `Extension` as well. The callback is:
291291

292-
```
292+
```java
293293
public interface Extension {
294294
// ...
295295
List<CustomizedSetter> getSetters(Class clazz);
@@ -313,7 +313,7 @@ The setter parameters, constructor parameters and fields are all just bindings.
313313

314314
# Extension & Iterator
315315

316-
```
316+
```java
317317
public interface Extension {
318318
/**
319319
* Customize type decoding
@@ -361,7 +361,7 @@ Also the decoder interface is powered with iterator-api to iterate on the lowest
361361

362362
There is a feature flag of jackson called `ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT`. The intention is to decode input like `[]` as null, as PHP might treat empty object as empty array. To support this feature, we can register a extension
363363

364-
```
364+
```java
365365
JsonIterator.registerExtension(new EmptyExtension() {
366366
@Override
367367
public Decoder createDecoder(final String cacheKey, final Type type) {

0 commit comments

Comments
 (0)