Package org.jmock.lib
Class LastWordNamingScheme
- java.lang.Object
-
- org.jmock.lib.LastWordNamingScheme
-
- All Implemented Interfaces:
MockObjectNamingScheme
public class LastWordNamingScheme extends java.lang.Object implements MockObjectNamingScheme
A naming scheme in which the implicit name for a mock object is the last word of the mocked type's name in lower case. E.g. A mock object of type HelloWorld would be named "world". If the type name is an acronym it is completely lowercased. For example, the type URL would be named "url". Digits and other non-letter characters are left on the end of the word. For example, the type NMEA0183 would be named "nmea0183".
-
-
Field Summary
Fields Modifier and Type Field Description static MockObjectNamingSchemeINSTANCE
-
Constructor Summary
Constructors Modifier Constructor Description privateLastWordNamingScheme()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringdefaultNameFor(java.lang.Class<?> typeToMock)Derive a name for a mock object from the name of the given type.private intindexOfLastLetter(java.lang.String simpleName)private intindexOfLastLowerCaseChar(java.lang.String simpleName, int wordEnd)private intindexOfLastUpperCaseChar(java.lang.String simpleName, int wordEnd)
-
-
-
Field Detail
-
INSTANCE
public static MockObjectNamingScheme INSTANCE
-
-
Method Detail
-
defaultNameFor
public java.lang.String defaultNameFor(java.lang.Class<?> typeToMock)
Description copied from interface:MockObjectNamingSchemeDerive a name for a mock object from the name of the given type.- Specified by:
defaultNameForin interfaceMockObjectNamingScheme- Parameters:
typeToMock- The type being mocked.- Returns:
- The default name for a mock object of the given type.
-
indexOfLastLetter
private int indexOfLastLetter(java.lang.String simpleName)
-
indexOfLastUpperCaseChar
private int indexOfLastUpperCaseChar(java.lang.String simpleName, int wordEnd)
-
indexOfLastLowerCaseChar
private int indexOfLastLowerCaseChar(java.lang.String simpleName, int wordEnd)
-
-