Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.ap.test.superbuilder;

public abstract class AbstractVehicle {

private final int amountOfTires;
private final Passenger passenger;

protected AbstractVehicle(AbstractVehicleBuilder<?, ?> b) {
this.amountOfTires = b.amountOfTires;
this.passenger = b.passenger;
}

public int getAmountOfTires() {
return this.amountOfTires;
}

public Passenger getPassenger() {
return this.passenger;
}

public abstract static class AbstractVehicleBuilder<C extends AbstractVehicle,
B extends AbstractVehicleBuilder<C, B>> {

private int amountOfTires;
private Passenger passenger;

public B amountOfTires(int amountOfTires) {
this.amountOfTires = amountOfTires;
return self();
}

public B passenger(Passenger passenger) {
this.passenger = passenger;
return self();
}

protected abstract B self();

public abstract C build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.ap.test.superbuilder;

public abstract class AbstractVehicleDto {

private final int amountOfTires;

public AbstractVehicleDto(int amountOfTires) {
this.amountOfTires = amountOfTires;
}

public int getAmountOfTires() {
return amountOfTires;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.ap.test.superbuilder;

public class Car extends Vehicle {

private final String manufacturer;
private final Passenger passenger;

protected Car(CarBuilder<?, ?> b) {
super( b );
this.manufacturer = b.manufacturer;
this.passenger = b.passenger;
}

public static CarBuilder<?, ?> builder() {
return new CarBuilderImpl();
}

public String getManufacturer() {
return this.manufacturer;
}

public Passenger getPassenger() {
return this.passenger;
}

public abstract static class CarBuilder<C extends Car, B extends CarBuilder<C, B>> extends VehicleBuilder<C, B> {

private String manufacturer;
private Passenger passenger;

public B manufacturer(String manufacturer) {
this.manufacturer = manufacturer;
return self();
}

public B passenger(Passenger passenger) {
this.passenger = passenger;
return self();
}

protected abstract B self();

public abstract C build();
}

private static final class CarBuilderImpl extends CarBuilder<Car, CarBuilderImpl> {
private CarBuilderImpl() {
}

protected CarBuilderImpl self() {
return this;
}

public Car build() {
return new Car( this );
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.ap.test.superbuilder;

public class CarDto extends VehicleDto {

private final String manufacturer;

public CarDto(int amountOfTires, String manufacturer, PassengerDto passenger) {
super( amountOfTires, passenger );
this.manufacturer = manufacturer;
}

public String getManufacturer() {
return manufacturer;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.ap.test.superbuilder;

import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

@Mapper
public interface CarMapper {

CarMapper INSTANCE = Mappers.getMapper( CarMapper.class );

@Mapping(target = "amountOfTires", source = "tireCount")
Car carDtoToCar(CarDto source);

@InheritInverseConfiguration(name = "carDtoToCar")
CarDto carToCarDto(Car source);

@Mapping(target = "amountOfTires", source = "tireCount")
ChainedAccessorsCar carDtoToChainedAccessorsCar(CarDto source);

@InheritInverseConfiguration(name = "carDtoToChainedAccessorsCar")
CarDto chainedAccessorsCarToCarDto(ChainedAccessorsCar source);

@Mapping(target = "amountOfTires", source = "tireCount")
InheritedAbstractCar carDtoToInheritedAbstractCar(CarDto source);

@InheritInverseConfiguration(name = "carDtoToInheritedAbstractCar")
CarDto inheritedAbstractCarToCarDto(InheritedAbstractCar source);

@Mapping(target = "amountOfTires", source = "tireCount")
@Mapping(target = "horsePower", constant = "140.5f")
MuscleCar carDtoToMuscleCar(CarDto source);

@InheritInverseConfiguration(name = "carDtoToMuscleCar")
CarDto muscleCarToCarDto(MuscleCar source);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.ap.test.superbuilder;

public class ChainedAccessorsCar extends ChainedAccessorsVehicle {

private String manufacturer;

protected ChainedAccessorsCar(ChainedAccessorsCarBuilder<?, ?> b) {
super( b );
this.manufacturer = b.manufacturer;
}

public static ChainedAccessorsCarBuilder<?, ?> builder() {
return new ChainedAccessorsCarBuilderImpl();
}

public String getManufacturer() {
return this.manufacturer;
}

public ChainedAccessorsCar setManufacturer(String manufacturer) {
this.manufacturer = manufacturer;
return this;
}

public abstract static class ChainedAccessorsCarBuilder<C extends ChainedAccessorsCar,
B extends ChainedAccessorsCarBuilder<C, B>> extends ChainedAccessorsVehicleBuilder<C, B> {

private String manufacturer;

public B manufacturer(String manufacturer) {
this.manufacturer = manufacturer;
return self();
}

protected abstract B self();

public abstract C build();
}

private static final class ChainedAccessorsCarBuilderImpl
extends ChainedAccessorsCarBuilder<ChainedAccessorsCar, ChainedAccessorsCarBuilderImpl> {
private ChainedAccessorsCarBuilderImpl() {
}

protected ChainedAccessorsCarBuilderImpl self() {
return this;
}

public ChainedAccessorsCar build() {
return new ChainedAccessorsCar( this );
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.ap.test.superbuilder;

public class ChainedAccessorsVehicle {
private int amountOfTires;
private Passenger passenger;

protected ChainedAccessorsVehicle(ChainedAccessorsVehicleBuilder<?, ?> b) {
this.amountOfTires = b.amountOfTires;
this.passenger = b.passenger;
}

public static ChainedAccessorsVehicleBuilder<?, ?> builder() {
return new ChainedAccessorsVehicleBuilderImpl();
}

public int getAmountOfTires() {
return this.amountOfTires;
}

public Passenger getPassenger() {
return this.passenger;
}

public ChainedAccessorsVehicle setAmountOfTires(int amountOfTires) {
this.amountOfTires = amountOfTires;
return this;
}

public ChainedAccessorsVehicle setPassenger(Passenger passenger) {
this.passenger = passenger;
return this;
}

public abstract static class ChainedAccessorsVehicleBuilder<C extends ChainedAccessorsVehicle,
B extends ChainedAccessorsVehicleBuilder<C, B>> {
private int amountOfTires;
private Passenger passenger;

public B amountOfTires(int amountOfTires) {
this.amountOfTires = amountOfTires;
return self();
}

public B passenger(Passenger passenger) {
this.passenger = passenger;
return self();
}

protected abstract B self();

public abstract C build();
}

private static final class ChainedAccessorsVehicleBuilderImpl
extends ChainedAccessorsVehicleBuilder<ChainedAccessorsVehicle, ChainedAccessorsVehicleBuilderImpl> {
private ChainedAccessorsVehicleBuilderImpl() {
}

protected ChainedAccessorsVehicleBuilderImpl self() {
return this;
}

public ChainedAccessorsVehicle build() {
return new ChainedAccessorsVehicle( this );
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.ap.test.superbuilder;

public class InheritedAbstractCar extends AbstractVehicle {

private final String manufacturer;

protected InheritedAbstractCar(InheritedAbstractCarBuilder<?, ?> b) {
super( b );
this.manufacturer = b.manufacturer;
}

public static InheritedAbstractCarBuilder<?, ?> builder() {
return new InheritedAbstractCarBuilderImpl();
}

public String getManufacturer() {
return this.manufacturer;
}

public abstract static class InheritedAbstractCarBuilder<C extends InheritedAbstractCar,
B extends InheritedAbstractCarBuilder<C, B>>

extends AbstractVehicleBuilder<C, B> {
private String manufacturer;

public B manufacturer(String manufacturer) {
this.manufacturer = manufacturer;
return self();
}

protected abstract B self();

public abstract C build();
}

private static final class InheritedAbstractCarBuilderImpl
extends InheritedAbstractCarBuilder<InheritedAbstractCar, InheritedAbstractCarBuilderImpl> {
private InheritedAbstractCarBuilderImpl() {
}

protected InheritedAbstractCarBuilderImpl self() {
return this;
}

public InheritedAbstractCar build() {
return new InheritedAbstractCar( this );
}
}
}
Loading