Skip to content

Commit 653a200

Browse files
committed
rename JacksonPojoHandle to JacksonDatabindHandle to avoid confusion with the Pojo Facade
1 parent 404fa30 commit 653a200

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

src/main/java/com/marklogic/client/impl/PojoPageImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.fasterxml.jackson.databind.ObjectMapper;
77
import com.marklogic.client.Page;
88
import com.marklogic.client.impl.BasicPage;
9-
import com.marklogic.client.io.JacksonPojoHandle;
9+
import com.marklogic.client.io.JacksonDatabindHandle;
1010
import com.marklogic.client.document.DocumentPage;
1111
import com.marklogic.client.pojo.PojoPage;
1212

@@ -36,7 +36,7 @@ public boolean hasNext() {
3636

3737
@Override
3838
public T next() {
39-
JacksonPojoHandle<T> handle = new JacksonPojoHandle<T>(entityClass);
39+
JacksonDatabindHandle<T> handle = new JacksonDatabindHandle<T>(entityClass);
4040
handle.getMapper().enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.WRAPPER_OBJECT);
4141
return docPage.nextContent(handle).get();
4242
}

src/main/java/com/marklogic/client/impl/PojoRepositoryImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import com.marklogic.client.document.DocumentPage;
99
import com.marklogic.client.io.DocumentMetadataHandle;
1010
import com.marklogic.client.io.Format;
11-
import com.marklogic.client.io.JacksonPojoHandle;
11+
import com.marklogic.client.io.JacksonDatabindHandle;
1212
import com.marklogic.client.io.SearchHandle;
1313
import com.marklogic.client.io.marker.SearchReadHandle;
1414
import com.marklogic.client.pojo.PojoPage;
@@ -75,7 +75,7 @@ public void write(T entity, Transaction transaction) {
7575
}
7676
public void write(T entity, Transaction transaction, String... collections) {
7777
if ( entity == null ) return;
78-
JacksonPojoHandle contentHandle = new JacksonPojoHandle(entity);
78+
JacksonDatabindHandle contentHandle = new JacksonDatabindHandle(entity);
7979
contentHandle.getMapper().enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.WRAPPER_OBJECT);
8080
DocumentMetadataHandle metadataHandle = new DocumentMetadataHandle();
8181
metadataHandle = metadataHandle.withCollections(entityClass.getName());

src/main/java/com/marklogic/client/io/JacksonPojoHandle.java renamed to src/main/java/com/marklogic/client/io/JacksonDatabindHandle.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,19 @@
3636
* JSON content as a Jackson JsonNode for reading or writing. Enables reading and
3737
* writing JSON documents, JSON structured search, and other JSON input and output.
3838
*/
39-
public class JacksonPojoHandle<T>
39+
public class JacksonDatabindHandle<T>
4040
extends JacksonBaseHandle<T>
4141
implements ContentHandle<T>
4242
{
4343
private Class contentClass;
4444
private T content;
4545

4646
/**
47-
* Specify the type of content this JacksonPojoHandle will manage.
47+
* Specify the type of content this JacksonDatabindHandle will manage.
4848
*
49-
* @param contentClass either JsonNode.class or the class of your custom Pojo for databinding
49+
* @param contentClass the class of your custom Pojo for databinding
5050
*/
51-
public JacksonPojoHandle(Class<T> contentClass) {
51+
public JacksonDatabindHandle(Class<T> contentClass) {
5252
super();
5353
this.contentClass = contentClass;
5454
setResendable(true);
@@ -57,7 +57,7 @@ public JacksonPojoHandle(Class<T> contentClass) {
5757
* Provides a handle on JSON content as a Jackson tree.
5858
* @param content the JSON root node of the tree.
5959
*/
60-
public JacksonPojoHandle(T content) {
60+
public JacksonDatabindHandle(T content) {
6161
this((Class<T>) content.getClass());
6262
set(content);
6363
}
@@ -68,7 +68,7 @@ public JacksonPojoHandle(T content) {
6868
* @param format the format of the content
6969
* @return this handle
7070
*/
71-
public JacksonPojoHandle withFormat(Format format) {
71+
public JacksonDatabindHandle withFormat(Format format) {
7272
setFormat(format);
7373
return this;
7474
}
@@ -82,8 +82,8 @@ public T get() {
8282
return content;
8383
}
8484
/**
85-
* Assigns either a JsonNode or your custom Pojo as the content.
86-
* @param content the JSON root node or your custom Pojo
85+
* Assigns your custom Pojo as the content.
86+
* @param content your custom Pojo
8787
*/
8888
@Override
8989
public void set(T content) {
@@ -94,7 +94,7 @@ public void set(T content) {
9494
* @param content the JSON root node.
9595
* @return the handle on the JSON tree.
9696
*/
97-
public JacksonPojoHandle<T> with(T content) {
97+
public JacksonDatabindHandle<T> with(T content) {
9898
set(content);
9999
return this;
100100
}
@@ -125,10 +125,10 @@ public void write(OutputStream out) throws IOException {
125125
getMapper().writeValue(new OutputStreamWriter(out, "UTF-8"), get());
126126
}
127127

128-
static private class JacksonPojoHandleFactory implements ContentHandleFactory {
128+
static private class JacksonDatabindHandleFactory implements ContentHandleFactory {
129129
private Class<?> contentClass;
130130

131-
private JacksonPojoHandleFactory(Class<?> contentClass) {
131+
private JacksonDatabindHandleFactory(Class<?> contentClass) {
132132
super();
133133
this.contentClass = contentClass;
134134
}
@@ -145,7 +145,7 @@ public boolean isHandled(Class<?> type) {
145145
public <C> ContentHandle<C> newHandle(Class<C> type) {
146146
@SuppressWarnings("unchecked")
147147
ContentHandle<C> handle = isHandled(type) ?
148-
(ContentHandle<C>) new JacksonPojoHandle<C>(type) : null;
148+
(ContentHandle<C>) new JacksonDatabindHandle<C>(type) : null;
149149
return handle;
150150
}
151151
}

src/test/java/com/marklogic/client/test/JacksonDatabindTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
import com.marklogic.client.document.JSONDocumentManager;
4444
import com.marklogic.client.document.XMLDocumentManager;
4545
import com.marklogic.client.io.Format;
46-
import com.marklogic.client.io.JacksonPojoHandle;
46+
import com.marklogic.client.io.JacksonDatabindHandle;
4747
import com.marklogic.client.query.DeleteQueryDefinition;
4848
import com.marklogic.client.query.QueryManager;
4949
import com.marklogic.client.test.Common;
@@ -69,7 +69,7 @@ public static void afterClass() {
6969
}
7070

7171
/** Here we're trying to keep it simple and demonstrate how you would use Jackson
72-
* via JacksonPojoHandle to do the most common-case databinding to serialize your
72+
* via JacksonDatabindHandle to do the most common-case databinding to serialize your
7373
* pojos to json. To reuse existing code we're letting BulkReadWriteTest load
7474
* records from a csv file and populate our City pojos. We just manage the
7575
* serialization and persistence logic.
@@ -81,8 +81,8 @@ public class JsonCityWriter implements CityWriter {
8181

8282
public void addCity(City city) {
8383
if ( numCities >= MAX_TO_WRITE ) return;
84-
// instantiate a JacksonPojoHandle ready to serialize this city to json
85-
JacksonPojoHandle handle = new JacksonPojoHandle(city);
84+
// instantiate a JacksonDatabindHandle ready to serialize this city to json
85+
JacksonDatabindHandle handle = new JacksonDatabindHandle(city);
8686
// demonstrate our ability to set advanced configuration on the mapper
8787
// in this case, we're saying wrap our serialization with the name of the pojo class
8888
handle.getMapper().enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.WRAPPER_OBJECT);
@@ -110,7 +110,7 @@ public void testDatabind() throws Exception {
110110

111111
/** We're going to demonstrate the versitility of Jackson by using and XmlMapper
112112
* to serialize instead of the default JsonMapper to serialize to json. Most
113-
* importantly, this points to the ability with JacksonHandle or JacksonPojoHandle
113+
* importantly, this points to the ability with JacksonHandle or JacksonDatabindHandle
114114
* to bring your own mapper and all the power that comes with it.
115115
**/
116116
public static class XmlCityWriter implements CityWriter {
@@ -125,7 +125,7 @@ public static class XmlCityWriter implements CityWriter {
125125

126126
public void addCity(City city) {
127127
if ( numCities >= MAX_TO_WRITE ) return;
128-
JacksonPojoHandle handle = new JacksonPojoHandle(city);
128+
JacksonDatabindHandle handle = new JacksonDatabindHandle(city);
129129
// NOTICE: We've set the mapper to an XmlMapper, showing the versitility of Jackson
130130
handle.setMapper(mapper);
131131
handle.setFormat(Format.XML);
@@ -166,7 +166,7 @@ class ToponymMixIn2 {
166166

167167
/** Demonstrate using Jackson's CSV mapper directly to simplify reading in data, populating a
168168
* third-party pojo (one we cannot annotate) then writing it out
169-
* via JacksonPojoHandle with configuration provided by mix-in annotations.
169+
* via JacksonDatabindHandle with configuration provided by mix-in annotations.
170170
**/
171171
@Test
172172
public void testDatabindingThirdPartyPojoWithMixinAnnotations() throws JsonProcessingException, IOException {
@@ -201,7 +201,7 @@ public void testDatabindingThirdPartyPojoWithMixinAnnotations() throws JsonProce
201201
String line = null;
202202
for (int numWritten = 0; numWritten < MAX_TO_WRITE && (line = cityReader.readLine()) != null; numWritten++ ) {
203203
Toponym city = reader.readValue(line);
204-
JacksonPojoHandle handle = new JacksonPojoHandle(city);
204+
JacksonDatabindHandle handle = new JacksonDatabindHandle(city);
205205
handle.getMapper().addMixInAnnotations(Toponym.class, ToponymMixIn2.class);
206206
set.add(DIRECTORY + "/thirdPartyJsonCities/" + city.getGeoNameId() + ".json", handle);
207207
}

0 commit comments

Comments
 (0)