Skip to content

Commit

Permalink
Start work merging #2241
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 4, 2019
1 parent e7b3baf commit 9aad873
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ public class PropertyNamingStrategy // NOTE: was abstract until 2.7
*/
public static final PropertyNamingStrategy KEBAB_CASE = new KebabCaseStrategy();

/**
* Naming convention widely used as configuration properties name, where words are in
* lower-case letters, separated by dots.
* See {@link LowerDotCaseStrategy} for details.
*
* @since 2.10
*/
public static final PropertyNamingStrategy LOWER_DOT_CASE = new LowerDotCaseStrategy();

/*
/**********************************************************
/* API
Expand Down Expand Up @@ -396,7 +405,26 @@ public String translate(String input)
return result.toString();
}
}


/**
* Naming strategy similar to {@link KebabCaseStrategy}, but instead of hyphens
* as separators, uses dots. Naming convention widely used as configuration properties name.
*
* @since 2.10
*/
public static class LowerDotCaseStrategy extends PropertyNamingStrategyBase {
/*
@Override
public String translate(String input){
return translateLowerCaseWithSeparator(input, '.');
}
*/
@Override
public String translate(String input) {
return input.toLowerCase();
}
}

/*
/**********************************************************
/* Deprecated variants, aliases
Expand Down
13 changes: 6 additions & 7 deletions src/test/java/com/fasterxml/jackson/databind/BaseMapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,13 @@ protected static ObjectMapper newObjectMapper() {
return new ObjectMapper();
}

// @since 2.10s
// @since 2.10
protected static JsonMapper.Builder objectMapperBuilder() {
/* 27-Aug-2018, tatu: Now this is weird -- with Java 7, we seem to need
* explicit type parameters, but not with Java 8.
* This need renders builder-approach pretty much useless for Java 7,
* which is ok for 3.x (where baseline is Java 8), but potentially
* problematic for 2.10. Oh well.
*/
return JsonMapper.builder();
}

// @since 2.10
protected static JsonMapper.Builder jsonMapperBuilder() {
return JsonMapper.builder();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,42 @@ public void testSimpleKebabCase() throws Exception
assertEquals("Billy", result.firstName);
}

/*
/**********************************************************
/* Test methods for LOWER_DOT_CASE
/**********************************************************
*/

/*
public void testLowerCaseWithDotsStrategyStandAlone()
{
assertEquals("some.value",
PropertyNamingStrategy.LOWER_DOT_CASE.nameForField(null, null, "someValue"));
assertEquals("some.value",
PropertyNamingStrategy.LOWER_DOT_CASE.nameForField(null, null, "SomeValue"));
assertEquals("url",
PropertyNamingStrategy.LOWER_DOT_CASE.nameForField(null, null, "URL"));
assertEquals("url.stuff",
PropertyNamingStrategy.LOWER_DOT_CASE.nameForField(null, null, "URLStuff"));
assertEquals("some.url.stuff",
PropertyNamingStrategy.LOWER_DOT_CASE.nameForField(null, null, "SomeURLStuff"));
}
public void testSimpleLowerCaseWithDots() throws Exception
{
final ObjectMapper m = jsonMapperBuilder()
.propertyNamingStrategy(PropertyNamingStrategy.LOWER_DOT_CASE)
.build();
final FirstNameBean input = new FirstNameBean("Bob");
assertEquals(aposToQuotes("{'first.name':'Bob'}"), m.writeValueAsString(input));
FirstNameBean result = m.readValue(aposToQuotes("{'first.name':'Billy'}"),
FirstNameBean.class);
assertEquals("Billy", result.firstName);
}
*/

/*
/**********************************************************
/* Test methods, other
Expand Down

0 comments on commit 9aad873

Please sign in to comment.