-
-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2828 from ebean-orm/feature/jackson-mapper-module
Extract jackson mapper module
- Loading branch information
Showing
20 changed files
with
290 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
ebean-core-type/src/main/java/io/ebean/core/type/ScalarJsonManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.ebean.core.type; | ||
|
||
import io.ebean.annotation.MutationDetection; | ||
|
||
/** | ||
* Holds the configured mapper and default mutation detection mode to be used. | ||
*/ | ||
public interface ScalarJsonManager { | ||
|
||
/** | ||
* Return the default mutation detection mode. | ||
*/ | ||
MutationDetection mutationDetection(); | ||
|
||
/** | ||
* Return the object mapper supplied in DatabaseConfig. | ||
*/ | ||
Object mapper(); | ||
|
||
/** | ||
* Return the Postgres type given the jdbc type. | ||
*/ | ||
String postgresType(int dbType); | ||
} |
23 changes: 23 additions & 0 deletions
23
ebean-core-type/src/main/java/io/ebean/core/type/ScalarJsonMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.ebean.core.type; | ||
|
||
import io.avaje.lang.Nullable; | ||
|
||
import java.lang.annotation.Annotation; | ||
|
||
/** | ||
* Supports JSON bean properties that use something like Jackson ObjectMapper to convert between | ||
* JSON content and the logical bean property value. | ||
*/ | ||
public interface ScalarJsonMapper { | ||
|
||
/** | ||
* Return a ScalarType for the given JSON property. | ||
*/ | ||
ScalarType<?> createType(ScalarJsonRequest request); | ||
|
||
/** | ||
* Return a marker annotation to detect when the JSON mapper should be used explicitly. | ||
*/ | ||
@Nullable | ||
<A extends Annotation> Class<A> markerAnnotation(); | ||
} |
67 changes: 67 additions & 0 deletions
67
ebean-core-type/src/main/java/io/ebean/core/type/ScalarJsonRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package io.ebean.core.type; | ||
|
||
import io.ebean.annotation.MutationDetection; | ||
|
||
/** | ||
* A request to create a ScalarType for a bean property (typically annotated with {@code @DbJson}). | ||
*/ | ||
public final class ScalarJsonRequest { | ||
|
||
private final ScalarJsonManager manager; | ||
private final int dbType; | ||
private final DocPropertyType docType; | ||
private final Class<?> beanType; | ||
private final MutationDetection mode; | ||
private final String name; | ||
|
||
public ScalarJsonRequest(ScalarJsonManager manager, int dbType, DocPropertyType docType, Class<?> beanType, MutationDetection mode, String name) { | ||
this.manager = manager; | ||
this.dbType = dbType; | ||
this.docType = docType; | ||
this.beanType = beanType; | ||
this.mode = mode; | ||
this.name = name; | ||
} | ||
|
||
/** | ||
* Return the manager. | ||
*/ | ||
public ScalarJsonManager manager() { | ||
return manager; | ||
} | ||
|
||
/** | ||
* Return the jdbc type this property maps to (e.g. JSON, JSONB etc). | ||
*/ | ||
public int dbType() { | ||
return dbType; | ||
} | ||
|
||
/** | ||
* Return the document store docType. | ||
*/ | ||
public DocPropertyType docType() { | ||
return docType; | ||
} | ||
|
||
/** | ||
* Return the type of the bean that this property belongs to. | ||
*/ | ||
public Class<?> beanType() { | ||
return beanType; | ||
} | ||
|
||
/** | ||
* Return the mutation detection mode the property should use. | ||
*/ | ||
public MutationDetection mode() { | ||
return mode; | ||
} | ||
|
||
/** | ||
* Return the property name. | ||
*/ | ||
public String name() { | ||
return name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 12 additions & 21 deletions
33
ebean-core/src/main/java/io/ebeaninternal/server/type/TypeJsonManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.