<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 @Data public class Cat { private int id; private Integer age; private boolean real; } @Data public class CatDto { private Integer id; private long age; private String real; } ``` **2. 映射接口** ```java @Mapper public interface CatMapper { CatMapper INSTANCE = Mappers.getMapper(CatMapper.class); /** * 下面的情況可以不手動處理: * 1) 基本類型及其對應的包裝類之間。如int/Integer、float/Float、long/Long、boolean/Boolean等。 * 2) 任意基本類型與任意包裝類之間。如int/long、byte/Integer等。 * 3) 所有基本類型及包裝類與String之間。如boolean/String、Integer/String、float/String等。 * 4) 枚舉和String之間。 * 5) Java大數類型(java.math.BigInteger, java.math.BigDecimal)和Java基本類型(包括其包裝類)與String之間。 * */ CatDto toDto(Cat source); } ``` **3. 測試** ```java @Test public void testCatMapper() throws ParseException { Cat cat = new Cat(); cat.setId(1001); cat.setAge(25); cat.setReal(true); CatDto catDto = CatMapper.INSTANCE.toDto(cat); //Cat:Cat(id=1001, age=25, real=true) System.out.println("Cat:" + cat.toString()); //CatDto:CatDto(id=1001, age=25, real=true) System.out.println("CatDto:" + catDto.toString()); } ``` **4. 查看映射接口被Mapstruct編譯后的代碼** ```java public class CatMapperImpl implements CatMapper { public CatMapperImpl() { } public CatDto toDto(Cat source) { if (source == null) { return null; } else { CatDto catDto = new CatDto(); catDto.setId(source.getId()); if (source.getAge() != null) { catDto.setAge((long)source.getAge()); } catDto.setReal(String.valueOf(source.isReal())); return catDto; } } } ```
                  <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>

                              哎呀哎呀视频在线观看