View Javadoc
1   /*
2    * Copyright 2018 Andrew Rucker Jones.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package com.opencsv.bean.mocks.join;
17  
18  import com.opencsv.bean.CsvBindAndJoinByPosition;
19  import com.opencsv.bean.CsvDate;
20  import java.util.Date;
21  import org.apache.commons.collections4.MultiValuedMap;
22  import org.apache.commons.collections4.multimap.ArrayListValuedHashMap;
23  import org.apache.commons.collections4.multimap.HashSetValuedHashMap;
24  
25  /**
26   *
27   * @author Andrew Rucker Jones
28   */
29  public class GoodJoinByPositionAnnotations {
30      
31      @CsvBindAndJoinByPosition(position = "0", elementType = Integer.class, required = true, capture = "couldn't possibly match (anything)")
32      private MultiValuedMap<Integer, Integer> map1;
33      
34      @CsvBindAndJoinByPosition(position = "1,16-", elementType = Date.class, locale = "de-DE", required = true)
35      @CsvDate(value = "dd. MMM yyyy")
36      private MultiValuedMap<Integer, Date> map2;
37      
38      @CsvBindAndJoinByPosition(position = "3-2", elementType = Integer.class, mapType = HashSetValuedHashMap.class, capture = "\\|([0-9]+)\\|")
39      private MultiValuedMap<Integer, Integer> map3;
40      
41      @CsvBindAndJoinByPosition(position = "4-6 , 7 - 9,8-10,12,13,15", elementType = String.class)
42      private ArrayListValuedHashMap<Integer, String> map4;
43      
44      @CsvBindAndJoinByPosition(position = "11", elementType = Integer.class, locale = "de")
45      private MultiValuedMap<Integer, Integer> map5;
46      
47      public GoodJoinByPositionAnnotations() {
48          map1 = new ArrayListValuedHashMap<>();
49          map1.put(Integer.MAX_VALUE, Integer.MIN_VALUE);
50      }
51      
52      public MultiValuedMap<Integer, Integer> getMap1() {
53          return map1;
54      }
55  
56      public void setMap1(MultiValuedMap<Integer, Integer> map1) {
57          this.map1 = map1;
58      }
59  
60      /**
61       * Specifically renamed so it can't be used as an accessor.
62       * @return The value of {@link #map2}
63       */
64      public MultiValuedMap<Integer, Date> showMeTheSecondMap() {
65          return map2;
66      }
67  
68      public void setMap2(MultiValuedMap<Integer, Date> map2) {
69          this.map2 = map2;
70      }
71  
72      public MultiValuedMap<Integer, Integer> getMap3() {
73          return map3;
74      }
75  
76      // Assignment method intentionally unavailable
77  //    public void setMap3(MultiValuedMap<Integer, Integer> map3) {
78  //        this.map3 = map3;
79  //    }
80  
81      public ArrayListValuedHashMap<Integer, String> getMap4() {
82          return map4;
83      }
84  
85      public void setMap4(ArrayListValuedHashMap<Integer, String> map4) {
86          this.map4 = map4;
87      }
88  
89      public MultiValuedMap<Integer, Integer> getMap5() {
90          return map5;
91      }
92  
93      public void setMap5(MultiValuedMap<Integer, Integer> map5) {
94          this.map5 = map5;
95      }
96  
97  }