public class

HyphenatedNameMapper

extends Object
implements NameMapper
java.lang.Object
   ↳ org.apache.commons.betwixt.strategy.HyphenatedNameMapper

Class Overview

A name mapper which converts types to a hypenated String. So a bean type of FooBar will be converted to the element name "foo-bar". The name mapper can be configured to convert to upper case and to use a different separator via the separator and upperCase properties, so that FooBar can be converted to FOO_BAR if needed, by calling the constructor new HyphenatedNameMapper(true, "_").

Summary

Public Constructors
HyphenatedNameMapper()
Construct a hyphenated name mapper that converts the name to lower case and uses the default separator.
HyphenatedNameMapper(boolean upperCase)
Construct a hyphenated name mapper with default separator.
HyphenatedNameMapper(boolean upperCase, String separator)
Construct a hyphenated name mapper.
Public Methods
String getSeparator()
This separator will be inserted between the words in the bean name.
boolean isUpperCase()

Should the bean name be converted to upper case?

Otherwise, it will be converted to lower case.

String mapTypeToElementName(String typeName)

The words within the bean name are deduced assuming the first-letter-capital (for example camel's hump) naming convention.

void setSeparator(String separator)
Sets the separator used to seperate words, which defaults to '-'
void setUpperCase(boolean upperCase)
Sets whether upper or lower case conversions should be performed, which defaults to false for lower case.
String toString()
Outputs brief description.
Protected Methods
char convertChar(char ch)
Performs type conversion on the given character based on whether upper or lower case conversions are being used
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.apache.commons.betwixt.strategy.NameMapper

Public Constructors

public HyphenatedNameMapper ()

Construct a hyphenated name mapper that converts the name to lower case and uses the default separator.

public HyphenatedNameMapper (boolean upperCase)

Construct a hyphenated name mapper with default separator.

Parameters
upperCase should the type name be converted (entirely) to upper case

public HyphenatedNameMapper (boolean upperCase, String separator)

Construct a hyphenated name mapper.

Parameters
upperCase should the type name be converted (entirely) to upper case
separator use this string to separate the words in the name returned. The words in the bean name are deduced by relying on the standard camel's hump property naming convention.

Public Methods

public String getSeparator ()

This separator will be inserted between the words in the bean name.

Returns
  • the separator used to seperate words, which defaults to '-'

public boolean isUpperCase ()

Should the bean name be converted to upper case?

Otherwise, it will be converted to lower case.

Returns
  • whether upper or lower case conversions should be performed, which defaults to false for lower case

public String mapTypeToElementName (String typeName)

The words within the bean name are deduced assuming the first-letter-capital (for example camel's hump) naming convention. For example, the words in FooBar are foo and bar.

Next convert all letter in the bean name to either upper case or lower case based on the isUpperCase() property value.

Then the getSeparator() property value is inserted so that it separates each word.

Parameters
typeName The name string to convert. If a JavaBean class name, should included only the last part of the name rather than the fully qualified name (e.g. FooBar rather than org.example.FooBar).
Returns
  • the bean name converted to either upper or lower case with words separated by the separator.

public void setSeparator (String separator)

Sets the separator used to seperate words, which defaults to '-'

Parameters
separator the string inserted to separate words

public void setUpperCase (boolean upperCase)

Sets whether upper or lower case conversions should be performed, which defaults to false for lower case.

Parameters
upperCase whether the name is to be converted to upper case

public String toString ()

Outputs brief description.

Protected Methods

protected char convertChar (char ch)

Performs type conversion on the given character based on whether upper or lower case conversions are being used

Parameters
ch the character to be converted
Returns
  • converted to upper case if isUpperCase() otherwise to lower case