boolean isValid = true;
boolean foundEntryMatch;
String[] sourcePropertyNames = new String[0];
String[] segments = sourceName.split( "\\." );
Parameter parameter = null;
List<PropertyEntry> entries = new ArrayList<PropertyEntry>();
if ( method.getSourceParameters().size() > 1 ) {
// parameterName is mandatory for multiple source parameters
if ( segments.length > 0 ) {
String sourceParameterName = segments[0];
parameter = method.getSourceParameter( sourceParameterName );
if ( parameter == null ) {
reportMappingError( "Method has no parameter named \"%s\".", sourceParameterName );
isValid = false;
}
}
if ( segments.length > 1 && parameter != null ) {
sourcePropertyNames = Arrays.copyOfRange( segments, 1, segments.length );
entries = getSourceEntries( parameter.getType(), sourcePropertyNames );
foundEntryMatch = ( entries.size() == sourcePropertyNames.length );
}
else {
// its only a parameter, no property
foundEntryMatch = true;
}
}
else {
// parameter name is not mandatory for single source parameter
sourcePropertyNames = segments;
parameter = method.getSourceParameters().get( 0 );
entries = getSourceEntries( parameter.getType(), sourcePropertyNames );
foundEntryMatch = ( entries.size() == sourcePropertyNames.length );
if ( !foundEntryMatch ) {
//Lets see if the expression contains the parameterName, so parameterName.propName1.propName2
if ( parameter.getName().equals( segments[0] ) ) {
sourcePropertyNames = Arrays.copyOfRange( segments, 1, segments.length );
entries = getSourceEntries( parameter.getType(), sourcePropertyNames );
foundEntryMatch = ( entries.size() == sourcePropertyNames.length );
}
else {
// segment[0] cannot be attributed to the parameter name.
parameter = null;
}
}
}
if ( !foundEntryMatch ) {
if ( parameter != null ) {
reportMappingError(
"The type of parameter \"%s\" has no property named \"%s\".",
parameter.getName(),
Strings.join( Arrays.asList( sourcePropertyNames ), "." )
);
}
else {
reportMappingError(