<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                **1. 映射類** ```java /** * 映射類可以用接口也可以用抽象類,這里我想用抽象類來演示 */ @Mapper public abstract class BeforeWithAfterMapper { public static BeforeWithAfterMapper INSTANCE = Mappers.getMapper(BeforeWithAfterMapper.class); /** * 映射前執行的方法 */ @BeforeMapping protected void beforeMapping() { System.out.println("映射前執行的方法!"); } @Mapping(source = "carId", target = "carDtoId") @Mapping(source = "carName", target = "carDtoName") public abstract CarDto toDto(Car source1); /** * 完成映射后執行的方法 */ @AfterMapping protected void afterMapping() { System.out.println("完成映射后執行的方法!"); } } ``` **2. 測試** ```java @Test public void testBeforeWithAfterMapper() { Car car = new Car(); car.setCarId(1001); car.setCarName("紅旗"); CarDto carDto = BeforeWithAfterMapper.INSTANCE.toDto(car); System.out.println(carDto); } ``` 控制臺打印的順序如下,可見被注解`@BeforeMapping`和`@AfterMapping`標注的方法先后被執行了。 ``` 映射前執行的方法! 完成映射后執行的方法! CarDto(carDtoId=1001, carDtoName=紅旗) ``` **3. 查看MapStruct編譯后的代碼** ```java public class BeforeWithAfterMapperImpl extends BeforeWithAfterMapper { public BeforeWithAfterMapperImpl() { } public CarDto toDto(Car source1) { this.beforeMapping(); if (source1 == null) { return null; } else { CarDto carDto = new CarDto(); carDto.setCarDtoId(source1.getCarId()); carDto.setCarDtoName(source1.getCarName()); this.afterMapping(); return carDto; } } } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看