Skip to content

Commit

Permalink
mapstruct#122 Minor formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
navpil authored and filiphr committed May 20, 2017
1 parent 5dd0097 commit 75fa2fb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
Expand Up @@ -102,9 +102,9 @@ public Builder souceMethod(SourceMethod sourceMethod) {
return setupMethodWithMapping( sourceMethod );
}

public Builder forgedMethod(Method method ) {
public Builder forgedMethod(Method method) {
singleMapping = new EmptySingleMapping();
return setupMethodWithMapping( method );
return setupMethodWithMapping( method );
}

private Builder setupMethodWithMapping(Method sourceMethod) {
Expand Down Expand Up @@ -206,7 +206,8 @@ else if ( !method.isUpdateMethod() && method.getReturnType().isAbstract() ) {
method,
selectionParameters,
ctx,
existingVariableNames );
existingVariableNames
);
List<LifecycleCallbackMethodReference> afterMappingMethods =
LifecycleCallbackFactory.afterMappingMethods( method, selectionParameters, ctx, existingVariableNames );

Expand Down Expand Up @@ -427,7 +428,7 @@ else if ( mapping.getSourceName() != null ) {
unprocessedSourceParameters.remove( sourceRef.getParameter() );
}
else {
errorOccured = true;
errorOccured = true;
}
}

Expand Down
Expand Up @@ -127,7 +127,7 @@ public SourceReference build() {
if ( segments.length > 1 && parameter != null ) {
sourcePropertyNames = Arrays.copyOfRange( segments, 1, segments.length );
entries = getSourceEntries( parameter.getType(), sourcePropertyNames );
foundEntryMatch = (entries.size() == sourcePropertyNames.length);
foundEntryMatch = ( entries.size() == sourcePropertyNames.length );
}
else {
// its only a parameter, no property
Expand All @@ -141,14 +141,14 @@ public SourceReference build() {
sourcePropertyNames = segments;
parameter = method.getSourceParameters().get( 0 );
entries = getSourceEntries( parameter.getType(), sourcePropertyNames );
foundEntryMatch = (entries.size() == sourcePropertyNames.length);
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);
foundEntryMatch = ( entries.size() == sourcePropertyNames.length );
}
else {
// segment[0] cannot be attributed to the parameter name.
Expand All @@ -161,7 +161,8 @@ public SourceReference build() {

if ( parameter != null ) {
reportMappingError( Message.PROPERTYMAPPING_NO_PROPERTY_IN_PARAMETER, parameter.getName(),
Strings.join( Arrays.asList( sourcePropertyNames ), "." ) );
Strings.join( Arrays.asList( sourcePropertyNames ), "." )
);
}
else {
int notFoundPropertyIndex;
Expand Down Expand Up @@ -202,12 +203,15 @@ private List<PropertyEntry> getSourceEntries(Type type, String[] entryNames) {
Map<String, Accessor> sourceReadAccessors = newType.getPropertyReadAccessors();
Map<String, ExecutableElementAccessor> sourcePresenceCheckers = newType.getPropertyPresenceCheckers();

for ( Map.Entry<String, Accessor> getter : sourceReadAccessors.entrySet() ) {
for ( Map.Entry<String, Accessor> getter : sourceReadAccessors.entrySet() ) {
if ( getter.getKey().equals( entryName ) ) {
newType = typeFactory.getReturnType( (DeclaredType) newType.getTypeMirror(),
getter.getValue() );
newType = typeFactory.getReturnType(
(DeclaredType) newType.getTypeMirror(),
getter.getValue()
);
sourceEntries.add( forSourceReference( entryName, getter.getValue(),
sourcePresenceCheckers.get( entryName ), newType ) );
sourcePresenceCheckers.get( entryName ), newType
) );
matchFound = true;
break;
}
Expand All @@ -221,7 +225,8 @@ private List<PropertyEntry> getSourceEntries(Type type, String[] entryNames) {

private void reportMappingError(Message msg, Object... objects) {
messager.printMessage( method.getExecutable(), mapping.getMirror(), mapping.getSourceAnnotationValue(),
msg, objects );
msg, objects
);
}
}

Expand Down

0 comments on commit 75fa2fb

Please sign in to comment.