#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; 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.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
import org.mapstruct.Mappings; 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; import org.mapstruct.factory.Mappers;
/** /**
*
* @author Sjaak Derksen * @author Sjaak Derksen
*/ */
@Mapper @Mapper
@ -35,34 +34,34 @@ public interface ArtistToChartEntry {
ArtistToChartEntry MAPPER = Mappers.getMapper( ArtistToChartEntry.class ); ArtistToChartEntry MAPPER = Mappers.getMapper( ArtistToChartEntry.class );
@Mappings( { @Mappings({
@Mapping( target = "chartName", source = "chart.name" ), @Mapping(target = "chartName", source = "chart.name"),
@Mapping( target = "title", source = "song.title" ), @Mapping(target = "title", source = "song.title"),
@Mapping( target = "artistName", source = "song.artist.name" ), @Mapping(target = "artistName", source = "song.artist.name"),
@Mapping( target = "recordedAt", source = "song.artist.label.studio.name" ), @Mapping(target = "recordedAt", source = "song.artist.label.studio.name"),
@Mapping( target = "city", source = "song.artist.label.studio.city" ), @Mapping(target = "city", source = "song.artist.label.studio.city"),
@Mapping( target = "position", source = "position" ) @Mapping(target = "position", source = "position")
} ) })
ChartEntry map( Chart chart, Song song, Integer position ); ChartEntry map(Chart chart, Song song, Integer position);
@Mappings( { @Mappings({
@Mapping( target = "chartName", ignore = true ), @Mapping(target = "chartName", ignore = true),
@Mapping( target = "title", source = "title" ), @Mapping(target = "title", source = "title"),
@Mapping( target = "artistName", source = "artist.name" ), @Mapping(target = "artistName", source = "artist.name"),
@Mapping( target = "recordedAt", source = "artist.label.studio.name" ), @Mapping(target = "recordedAt", source = "artist.label.studio.name"),
@Mapping( target = "city", source = "artist.label.studio.city" ), @Mapping(target = "city", source = "artist.label.studio.city"),
@Mapping( target = "position", ignore = true ) @Mapping(target = "position", ignore = true)
} ) })
ChartEntry map( Song song ); ChartEntry map(Song song);
@Mappings( { @Mappings({
@Mapping( target = "chartName", source = "name" ), @Mapping(target = "chartName", source = "name"),
@Mapping( target = "title", ignore = true ), @Mapping(target = "title", ignore = true),
@Mapping( target = "artistName", ignore = true ), @Mapping(target = "artistName", ignore = true),
@Mapping( target = "recordedAt", ignore = true ), @Mapping(target = "recordedAt", ignore = true),
@Mapping( target = "city", ignore = true ), @Mapping(target = "city", ignore = true),
@Mapping( target = "position", ignore = true ) @Mapping(target = "position", ignore = true)
} ) })
ChartEntry map( Chart name ); ChartEntry map(Chart name);
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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