View Javadoc
1   package at.rseiler.spbee.core.pojo.annotation;
2   
3   import at.rseiler.spbee.core.annotation.RowMapper;
4   
5   import javax.lang.model.type.MirroredTypeException;
6   import java.io.Serializable;
7   
8   /**
9    * Holds the data of a {@link at.rseiler.spbee.core.annotation.RowMapper} annotation.
10   *
11   * @author Reinhard Seiler {@literal <rseiler.developer@gmail.com>}
12   */
13  public class RowMapperData implements Serializable {
14  
15      private static final long serialVersionUID = 2273627881915262221L;
16  
17      private final String type;
18  
19      public RowMapperData(RowMapper rowMapper) {
20          this.type = getRowMapperType(rowMapper);
21      }
22  
23      public String getType() {
24          return type;
25      }
26  
27      private String getRowMapperType(RowMapper rowMapper) {
28          try {
29              return rowMapper.value().toString().replace("class ", "");
30          } catch (MirroredTypeException mte) {
31              // http://stackoverflow.com/a/10167558
32              return mte.getTypeMirror().toString();
33          }
34      }
35  
36      @Override
37      public String toString() {
38          return "RowMapperData{" +
39                  "type='" + type + '\'' +
40                  '}';
41      }
42  }