allow for _ separator on top of camel case for mapping definitions

This commit is contained in:
kimchy 2010-04-03 21:07:01 +03:00
parent 962ce9a7e6
commit 15bdba30e5
7 changed files with 16 additions and 16 deletions

View File

@ -103,7 +103,7 @@ public class JsonBooleanFieldMapper extends JsonFieldMapper<Boolean> {
Map.Entry<String, JsonNode> entry = propsIt.next(); Map.Entry<String, JsonNode> entry = propsIt.next();
String propName = entry.getKey(); String propName = entry.getKey();
JsonNode propNode = entry.getValue(); JsonNode propNode = entry.getValue();
if (propName.equals("nullValue")) { if (propName.equals("nullValue") || propName.equals("null_value")) {
builder.nullValue(nodeBooleanValue(propNode)); builder.nullValue(nodeBooleanValue(propNode));
} }
} }

View File

@ -92,7 +92,7 @@ public class JsonDateFieldMapper extends JsonNumberFieldMapper<Long> {
Map.Entry<String, JsonNode> entry = propsIt.next(); Map.Entry<String, JsonNode> entry = propsIt.next();
String propName = entry.getKey(); String propName = entry.getKey();
JsonNode propNode = entry.getValue(); JsonNode propNode = entry.getValue();
if (propName.equals("nullValue")) { if (propName.equals("nullValue") || propName.equals("null_value")) {
builder.nullValue(propNode.getValueAsText()); builder.nullValue(propNode.getValueAsText());
} else if (propName.equals("format")) { } else if (propName.equals("format")) {
builder.dateTimeFormatter(parseDateTimeFormatter(propName, propNode)); builder.dateTimeFormatter(parseDateTimeFormatter(propName, propNode));

View File

@ -82,7 +82,7 @@ public class JsonDoubleFieldMapper extends JsonNumberFieldMapper<Double> {
Map.Entry<String, JsonNode> entry = propsIt.next(); Map.Entry<String, JsonNode> entry = propsIt.next();
String propName = entry.getKey(); String propName = entry.getKey();
JsonNode propNode = entry.getValue(); JsonNode propNode = entry.getValue();
if (propName.equals("nullValue")) { if (propName.equals("nullValue") || propName.equals("null_value")) {
builder.nullValue(nodeDoubleValue(propNode)); builder.nullValue(nodeDoubleValue(propNode));
} }
} }

View File

@ -82,7 +82,7 @@ public class JsonFloatFieldMapper extends JsonNumberFieldMapper<Float> {
Map.Entry<String, JsonNode> entry = propsIt.next(); Map.Entry<String, JsonNode> entry = propsIt.next();
String propName = entry.getKey(); String propName = entry.getKey();
JsonNode propNode = entry.getValue(); JsonNode propNode = entry.getValue();
if (propName.equals("nullValue")) { if (propName.equals("nullValue") || propName.equals("null_value")) {
builder.nullValue(nodeFloatValue(propNode)); builder.nullValue(nodeFloatValue(propNode));
} }
} }

View File

@ -169,7 +169,7 @@ public class JsonObjectMapper implements JsonMapper, JsonIncludeInAllMapper {
if (!type.equals("object")) { if (!type.equals("object")) {
throw new MapperParsingException("Trying to parse an object but has a different type [" + type + "] for [" + name + "]"); throw new MapperParsingException("Trying to parse an object but has a different type [" + type + "] for [" + name + "]");
} }
} else if (fieldName.equals("dateFormats")) { } else if (fieldName.equals("dateFormats") || fieldName.equals("date_formats")) {
List<FormatDateTimeFormatter> dateTimeFormatters = newArrayList(); List<FormatDateTimeFormatter> dateTimeFormatters = newArrayList();
if (fieldNode.isArray()) { if (fieldNode.isArray()) {
for (JsonNode node1 : (ArrayNode) fieldNode) { for (JsonNode node1 : (ArrayNode) fieldNode) {
@ -187,11 +187,11 @@ public class JsonObjectMapper implements JsonMapper, JsonIncludeInAllMapper {
} }
} else if (fieldName.equals("enabled")) { } else if (fieldName.equals("enabled")) {
builder.enabled(nodeBooleanValue(fieldNode)); builder.enabled(nodeBooleanValue(fieldNode));
} else if (fieldName.equals("pathType")) { } else if (fieldName.equals("pathType") || fieldName.equals("path_type")) {
builder.pathType(parsePathType(name, fieldNode.getValueAsText())); builder.pathType(parsePathType(name, fieldNode.getValueAsText()));
} else if (fieldName.equals("properties")) { } else if (fieldName.equals("properties")) {
parseProperties(builder, (ObjectNode) fieldNode, parserContext); parseProperties(builder, (ObjectNode) fieldNode, parserContext);
} else if (fieldName.equals("includeInAll")) { } else if (fieldName.equals("includeInAll") || fieldName.equals("include_in_all")) {
builder.includeInAll(nodeBooleanValue(fieldNode)); builder.includeInAll(nodeBooleanValue(fieldNode));
} }
} }

View File

@ -82,7 +82,7 @@ public class JsonShortFieldMapper extends JsonNumberFieldMapper<Short> {
Map.Entry<String, JsonNode> entry = propsIt.next(); Map.Entry<String, JsonNode> entry = propsIt.next();
String propName = entry.getKey(); String propName = entry.getKey();
JsonNode propNode = entry.getValue(); JsonNode propNode = entry.getValue();
if (propName.equals("nullValue")) { if (propName.equals("nullValue") || propName.equals("null_value")) {
builder.nullValue(nodeShortValue(propNode)); builder.nullValue(nodeShortValue(propNode));
} }
} }

View File

@ -42,7 +42,7 @@ public class JsonTypeParsers {
Map.Entry<String, JsonNode> entry = propsIt.next(); Map.Entry<String, JsonNode> entry = propsIt.next();
String propName = entry.getKey(); String propName = entry.getKey();
JsonNode propNode = entry.getValue(); JsonNode propNode = entry.getValue();
if (propName.equals("precisionStep")) { if (propName.equals("precisionStep") || propName.equals("precision_step")) {
builder.precisionStep(nodeIntegerValue(propNode)); builder.precisionStep(nodeIntegerValue(propNode));
} }
} }
@ -53,28 +53,28 @@ public class JsonTypeParsers {
Map.Entry<String, JsonNode> entry = propsIt.next(); Map.Entry<String, JsonNode> entry = propsIt.next();
String propName = entry.getKey(); String propName = entry.getKey();
JsonNode propNode = entry.getValue(); JsonNode propNode = entry.getValue();
if (propName.equals("indexName")) { if (propName.equals("indexName") || propName.equals("index_name")) {
builder.indexName(propNode.getTextValue()); builder.indexName(propNode.getTextValue());
} else if (propName.equals("store")) { } else if (propName.equals("store")) {
builder.store(parseStore(name, propNode.getTextValue())); builder.store(parseStore(name, propNode.getTextValue()));
} else if (propName.equals("index")) { } else if (propName.equals("index")) {
builder.index(parseIndex(name, propNode.getTextValue())); builder.index(parseIndex(name, propNode.getTextValue()));
} else if (propName.equals("termVector")) { } else if (propName.equals("termVector") || propName.equals("term_vector")) {
builder.termVector(parseTermVector(name, propNode.getTextValue())); builder.termVector(parseTermVector(name, propNode.getTextValue()));
} else if (propName.equals("boost")) { } else if (propName.equals("boost")) {
builder.boost(nodeFloatValue(propNode)); builder.boost(nodeFloatValue(propNode));
} else if (propName.equals("omitNorms")) { } else if (propName.equals("omitNorms") || propName.equals("omit_norms")) {
builder.omitNorms(nodeBooleanValue(propNode)); builder.omitNorms(nodeBooleanValue(propNode));
} else if (propName.equals("omitTermFreqAndPositions")) { } else if (propName.equals("omitTermFreqAndPositions") || propName.equals("omit_termFreq_and_positions")) {
builder.omitTermFreqAndPositions(nodeBooleanValue(propNode)); builder.omitTermFreqAndPositions(nodeBooleanValue(propNode));
} else if (propName.equals("indexAnalyzer")) { } else if (propName.equals("indexAnalyzer") || propName.equals("index_analyzer")) {
builder.indexAnalyzer(parserContext.analysisService().analyzer(propNode.getTextValue())); builder.indexAnalyzer(parserContext.analysisService().analyzer(propNode.getTextValue()));
} else if (propName.equals("searchAnalyzer")) { } else if (propName.equals("searchAnalyzer") || propName.equals("search_analyzer")) {
builder.searchAnalyzer(parserContext.analysisService().analyzer(propNode.getTextValue())); builder.searchAnalyzer(parserContext.analysisService().analyzer(propNode.getTextValue()));
} else if (propName.equals("analyzer")) { } else if (propName.equals("analyzer")) {
builder.indexAnalyzer(parserContext.analysisService().analyzer(propNode.getTextValue())); builder.indexAnalyzer(parserContext.analysisService().analyzer(propNode.getTextValue()));
builder.searchAnalyzer(parserContext.analysisService().analyzer(propNode.getTextValue())); builder.searchAnalyzer(parserContext.analysisService().analyzer(propNode.getTextValue()));
} else if (propName.equals("includeInAll")) { } else if (propName.equals("includeInAll") || propName.equals("include_in_all")) {
builder.includeInAll(nodeBooleanValue(propNode)); builder.includeInAll(nodeBooleanValue(propNode));
} }
} }