#65 Formatting

This commit is contained in:
Gunnar Morling 2014-11-05 22:43:09 +01:00
parent 160af62acf
commit 1d35f2f70c
11 changed files with 75 additions and 84 deletions

View File

@ -18,16 +18,15 @@
*/
package org.mapstruct.ap.test.nestedsourceproperties;
import org.mapstruct.ap.test.nestedsourceproperties.source.Song;
import org.mapstruct.ap.test.nestedsourceproperties.source.Chart;
import org.mapstruct.ap.test.nestedsourceproperties.target.ChartEntry;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.ap.test.nestedsourceproperties.source.Chart;
import org.mapstruct.ap.test.nestedsourceproperties.source.Song;
import org.mapstruct.ap.test.nestedsourceproperties.target.ChartEntry;
import org.mapstruct.factory.Mappers;
/**
*
* @author Sjaak Derksen
*/
@Mapper
@ -35,34 +34,34 @@ public interface ArtistToChartEntry {
ArtistToChartEntry MAPPER = Mappers.getMapper( ArtistToChartEntry.class );
@Mappings( {
@Mapping( target = "chartName", source = "chart.name" ),
@Mapping( target = "title", source = "song.title" ),
@Mapping( target = "artistName", source = "song.artist.name" ),
@Mapping( target = "recordedAt", source = "song.artist.label.studio.name" ),
@Mapping( target = "city", source = "song.artist.label.studio.city" ),
@Mapping( target = "position", source = "position" )
} )
ChartEntry map( Chart chart, Song song, Integer position );
@Mappings({
@Mapping(target = "chartName", source = "chart.name"),
@Mapping(target = "title", source = "song.title"),
@Mapping(target = "artistName", source = "song.artist.name"),
@Mapping(target = "recordedAt", source = "song.artist.label.studio.name"),
@Mapping(target = "city", source = "song.artist.label.studio.city"),
@Mapping(target = "position", source = "position")
})
ChartEntry map(Chart chart, Song song, Integer position);
@Mappings( {
@Mapping( target = "chartName", ignore = true ),
@Mapping( target = "title", source = "title" ),
@Mapping( target = "artistName", source = "artist.name" ),
@Mapping( target = "recordedAt", source = "artist.label.studio.name" ),
@Mapping( target = "city", source = "artist.label.studio.city" ),
@Mapping( target = "position", ignore = true )
} )
ChartEntry map( Song song );
@Mappings({
@Mapping(target = "chartName", ignore = true),
@Mapping(target = "title", source = "title"),
@Mapping(target = "artistName", source = "artist.name"),
@Mapping(target = "recordedAt", source = "artist.label.studio.name"),
@Mapping(target = "city", source = "artist.label.studio.city"),
@Mapping(target = "position", ignore = true)
})
ChartEntry map(Song song);
@Mappings( {
@Mapping( target = "chartName", source = "name" ),
@Mapping( target = "title", ignore = true ),
@Mapping( target = "artistName", ignore = true ),
@Mapping( target = "recordedAt", ignore = true ),
@Mapping( target = "city", ignore = true ),
@Mapping( target = "position", ignore = true )
} )
ChartEntry map( Chart name );
@Mappings({
@Mapping(target = "chartName", source = "name"),
@Mapping(target = "title", ignore = true),
@Mapping(target = "artistName", ignore = true),
@Mapping(target = "recordedAt", ignore = true),
@Mapping(target = "city", ignore = true),
@Mapping(target = "position", ignore = true)
})
ChartEntry map(Chart name);
}

View File

@ -19,23 +19,23 @@
package org.mapstruct.ap.test.nestedsourceproperties;
import org.mapstruct.CollectionMappingStrategy;
import org.mapstruct.ap.test.nestedsourceproperties.source.Chart;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.ap.test.nestedsourceproperties.source.Chart;
import org.mapstruct.ap.test.nestedsourceproperties.target.ChartPositions;
import org.mapstruct.factory.Mappers;
/**
*
* @author Sjaak Derksen
*/
@Mapper( collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED )
@Mapper(collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED)
public interface ArtistToChartEntryAdder {
ArtistToChartEntryAdder MAPPER = Mappers.getMapper( ArtistToChartEntryAdder.class );
@Mappings( {
@Mapping( target = "positions", source = "chart.song.positions" ), } )
ChartPositions map( Chart chart );
@Mappings({
@Mapping(target = "positions", source = "chart.song.positions"),
})
ChartPositions map(Chart chart);
}

View File

@ -18,15 +18,14 @@
*/
package org.mapstruct.ap.test.nestedsourceproperties;
import org.mapstruct.ap.test.nestedsourceproperties.source.Chart;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.ap.test.nestedsourceproperties.source.Chart;
import org.mapstruct.ap.test.nestedsourceproperties.target.ChartPositions;
import org.mapstruct.factory.Mappers;
/**
*
* @author Sjaak Derksen
*/
@Mapper
@ -34,7 +33,8 @@ public interface ArtistToChartEntryGetter {
ArtistToChartEntryGetter MAPPER = Mappers.getMapper( ArtistToChartEntryGetter.class );
@Mappings( {
@Mapping( target = "positions", source = "chart.song.positions" ), } )
ChartPositions map( Chart chart );
@Mappings({
@Mapping(target = "positions", source = "chart.song.positions"),
})
ChartPositions map(Chart chart);
}

View File

@ -18,10 +18,6 @@
*/
package org.mapstruct.ap.test.nestedsourceproperties;
import static org.fest.assertions.Assertions.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import org.junit.Test;
@ -38,17 +34,20 @@ import org.mapstruct.ap.testutil.IssueKey;
import org.mapstruct.ap.testutil.WithClasses;
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
import static org.fest.assertions.Assertions.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
*
* @author Sjaak Derksen
*/
@WithClasses( { Song.class, Artist.class, Chart.class, Label.class, Studio.class, ChartEntry.class } )
@IssueKey( "65" )
@RunWith( AnnotationProcessorTestRunner.class )
@WithClasses({ Song.class, Artist.class, Chart.class, Label.class, Studio.class, ChartEntry.class })
@IssueKey("65")
@RunWith(AnnotationProcessorTestRunner.class)
public class NestedSourcePropertiesTest {
@Test
@WithClasses( { ArtistToChartEntry.class } )
@Test
@WithClasses({ ArtistToChartEntry.class })
public void shouldGenerateImplementationForPropertyNamesOnly() {
Studio studio = new Studio();
@ -79,7 +78,7 @@ public class NestedSourcePropertiesTest {
}
@Test
@WithClasses( { ArtistToChartEntry.class } )
@WithClasses({ ArtistToChartEntry.class })
public void shouldGenerateImplementationForMultipleParam() {
Studio studio = new Studio();
@ -114,7 +113,7 @@ public class NestedSourcePropertiesTest {
}
@Test
@WithClasses( { ArtistToChartEntry.class } )
@WithClasses({ ArtistToChartEntry.class })
public void shouldPickPropertyNameOverParameterName() {
Chart chart = new Chart();
@ -133,12 +132,12 @@ public class NestedSourcePropertiesTest {
}
@Test
@WithClasses( { ArtistToChartEntryAdder.class, ChartPositions.class, AdderUsageObserver.class } )
@WithClasses({ ArtistToChartEntryAdder.class, ChartPositions.class, AdderUsageObserver.class })
public void shouldUseAddAsTargetAccessor() {
AdderUsageObserver.setUsed( false );
Song song = new Song();
song.setPositions( Arrays.asList( 3, 5) );
song.setPositions( Arrays.asList( 3, 5 ) );
Chart chart = new Chart();
chart.setSong( song );
@ -151,12 +150,12 @@ public class NestedSourcePropertiesTest {
}
@Test
@WithClasses( { ArtistToChartEntryGetter.class, ChartPositions.class, AdderUsageObserver.class } )
@WithClasses({ ArtistToChartEntryGetter.class, ChartPositions.class, AdderUsageObserver.class })
public void shouldUseGetAsTargetAccessor() {
AdderUsageObserver.setUsed( false );
Song song = new Song();
song.setPositions( Arrays.asList( 3, 5) );
song.setPositions( Arrays.asList( 3, 5 ) );
Chart chart = new Chart();
chart.setSong( song );

View File

@ -19,7 +19,6 @@
package org.mapstruct.ap.test.nestedsourceproperties.source;
/**
*
* @author Sjaak Derksen
*/
public class Artist {
@ -32,7 +31,7 @@ public class Artist {
return name;
}
public void setName( String name ) {
public void setName(String name) {
this.name = name;
}
@ -40,7 +39,7 @@ public class Artist {
return label;
}
public void setLabel( Label label ) {
public void setLabel(Label label) {
this.label = label;
}

View File

@ -19,7 +19,6 @@
package org.mapstruct.ap.test.nestedsourceproperties.source;
/**
*
* @author Sjaak Derksen
*/
public class Chart {
@ -32,7 +31,7 @@ public class Chart {
return type;
}
public void setType( String type ) {
public void setType(String type) {
this.type = type;
}
@ -40,7 +39,7 @@ public class Chart {
return name;
}
public void setName( String name ) {
public void setName(String name) {
this.name = name;
}
@ -48,7 +47,7 @@ public class Chart {
return song;
}
public void setSong( Song song ) {
public void setSong(Song song) {
this.song = song;
}
}

View File

@ -19,7 +19,6 @@
package org.mapstruct.ap.test.nestedsourceproperties.source;
/**
*
* @author Sjaak Derksen
*/
public class Label {
@ -31,7 +30,7 @@ public class Label {
return name;
}
public void setName( String name ) {
public void setName(String name) {
this.name = name;
}
@ -39,7 +38,7 @@ public class Label {
return studio;
}
public void setStudio( Studio studio ) {
public void setStudio(Studio studio) {
this.studio = studio;
}
}

View File

@ -22,7 +22,6 @@ import java.util.List;
/**
*
* @author Sjaak Derksen
*/
public class Song {
@ -35,7 +34,7 @@ public class Song {
return artist;
}
public void setArtist( Artist artist ) {
public void setArtist(Artist artist) {
this.artist = artist;
}
@ -43,7 +42,7 @@ public class Song {
return title;
}
public void setTitle( String title ) {
public void setTitle(String title) {
this.title = title;
}
@ -51,7 +50,7 @@ public class Song {
return positions;
}
public void setPositions( List<Integer> positions ) {
public void setPositions(List<Integer> positions) {
this.positions = positions;
}
}

View File

@ -19,7 +19,6 @@
package org.mapstruct.ap.test.nestedsourceproperties.source;
/**
*
* @author Sjaak Derksen
*/
public class Studio {
@ -31,7 +30,7 @@ public class Studio {
return city;
}
public void setCity( String city ) {
public void setCity(String city) {
this.city = city;
}
@ -39,7 +38,7 @@ public class Studio {
return name;
}
public void setName( String name ) {
public void setName(String name) {
this.name = name;
}
}

View File

@ -19,7 +19,6 @@
package org.mapstruct.ap.test.nestedsourceproperties.target;
/**
*
* @author Sjaak Derksen
*/
public class ChartEntry {
@ -35,7 +34,7 @@ public class ChartEntry {
return chartName;
}
public void setChartName( String chartName ) {
public void setChartName(String chartName) {
this.chartName = chartName;
}
@ -43,7 +42,7 @@ public class ChartEntry {
return title;
}
public void setTitle( String title ) {
public void setTitle(String title) {
this.title = title;
}
@ -51,7 +50,7 @@ public class ChartEntry {
return artistName;
}
public void setArtistName( String artistName ) {
public void setArtistName(String artistName) {
this.artistName = artistName;
}
@ -59,7 +58,7 @@ public class ChartEntry {
return recordedAt;
}
public void setRecordedAt( String recordedAt ) {
public void setRecordedAt(String recordedAt) {
this.recordedAt = recordedAt;
}
@ -67,7 +66,7 @@ public class ChartEntry {
return city;
}
public void setCity( String city ) {
public void setCity(String city) {
this.city = city;
}
@ -75,7 +74,7 @@ public class ChartEntry {
return position;
}
public void setPosition( int position ) {
public void setPosition(int position) {
this.position = position;
}
}

View File

@ -19,7 +19,6 @@ import java.util.ArrayList;
import java.util.List;
/**
*
* @author Sjaak Derksen
*/
public class ChartPositions {
@ -30,7 +29,7 @@ public class ChartPositions {
return positions;
}
public Long addPosition( Long position ) {
public Long addPosition(Long position) {
AdderUsageObserver.setUsed( true );
positions.add( position );
return position;