Skip to content
This repository was archived by the owner on Jan 22, 2019. It is now read-only.

Commit 1fb4e27

Browse files
committed
cleaning up schema compatibility handling, to reduce ObjectMapper overrides
1 parent c545978 commit 1fb4e27

File tree

2 files changed

+9
-49
lines changed

2 files changed

+9
-49
lines changed

src/main/java/com/fasterxml/jackson/dataformat/csv/CsvFactory.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,12 @@ public Version version() {
8585

8686
/*
8787
/**********************************************************
88-
/* Format detection functionality (since 1.8)
88+
/* Format detection functionality
8989
/**********************************************************
9090
*/
9191

9292
@Override
93-
public String getFormatName()
94-
{
93+
public String getFormatName() {
9594
return FORMAT_NAME_CSV;
9695
}
9796

@@ -104,7 +103,12 @@ public MatchStrength hasFormat(InputAccessor acc) throws IOException
104103
// !!! TBI -- but how?
105104
return MatchStrength.INCONCLUSIVE;
106105
}
107-
106+
107+
@Override
108+
public boolean canUseSchema(FormatSchema schema) {
109+
return (schema instanceof CsvSchema);
110+
}
111+
108112
/*
109113
/**********************************************************
110114
/* Configuration, parser settings

src/main/java/com/fasterxml/jackson/dataformat/csv/CsvMapper.java

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.fasterxml.jackson.dataformat.csv;
22

3-
import com.fasterxml.jackson.core.*;
4-
53
import com.fasterxml.jackson.databind.*;
64
import com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition;
75
import com.fasterxml.jackson.core.type.TypeReference;
@@ -14,7 +12,7 @@
1412
*/
1513
public class CsvMapper extends ObjectMapper
1614
{
17-
private static final long serialVersionUID = 898121211926121724L;
15+
private static final long serialVersionUID = -4573529235914611523L;
1816

1917
/**
2018
* Simple caching for schema instances, given that they are relatively expensive
@@ -93,29 +91,6 @@ public final CsvFactory getFactory() {
9391
return (CsvFactory) _jsonFactory;
9492
}
9593

96-
/**
97-
* Overridden with more specific type, since factory we have
98-
* is always of type {@link CsvFactory}
99-
*
100-
* @deprecated Since 2.1 use {@link #getFactory()}
101-
*/
102-
@Deprecated
103-
@Override
104-
public final CsvFactory getJsonFactory() {
105-
return getCsvFactory();
106-
}
107-
108-
/**
109-
* Type-safe accessor for accessing underlying CSV-specific
110-
* {@link JsonFactory} implementation
111-
*
112-
* @deprecated Since 2.1 use {@link #getFactory()}, it is co-variant
113-
*/
114-
@Deprecated
115-
public final CsvFactory getCsvFactory() {
116-
return (CsvFactory) _jsonFactory;
117-
}
118-
11994
/*
12095
/**********************************************************************
12196
/* CsvSchema construction; overrides, new methods
@@ -160,24 +135,6 @@ public final CsvSchema typedSchemaFor(Class<?> pojoType) {
160135
public final CsvSchema typedSchemaFor(TypeReference<?> pojoTypeRef) {
161136
return _schemaFor(constructType(pojoTypeRef.getType()), _typedSchemas, true);
162137
}
163-
164-
@Override
165-
public ObjectReader reader(FormatSchema schema)
166-
{
167-
if ((schema != null) && !(schema instanceof CsvSchema)) {
168-
throw new IllegalArgumentException("Schema to set must be of type CsvSchema");
169-
}
170-
return super.reader(schema);
171-
}
172-
173-
@Override
174-
public ObjectWriter writer(FormatSchema schema)
175-
{
176-
if ((schema != null) && !(schema instanceof CsvSchema)) {
177-
throw new IllegalArgumentException("Schema to set must be of type CsvSchema");
178-
}
179-
return super.writer(schema);
180-
}
181138

182139
/**
183140
* Convenience method which is functionally equivalent to:
@@ -276,5 +233,4 @@ protected CsvSchema.ColumnType _determineType(Class<?> propType)
276233
// but in general we will just do what we can:
277234
return CsvSchema.ColumnType.NUMBER_OR_STRING;
278235
}
279-
280236
}

0 commit comments

Comments
 (0)