17 changed files with 386 additions and 16 deletions
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
package com.moparisthebest.jdbc.codegen; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
import static com.moparisthebest.jdbc.codegen.JdbcMapperProcessor.baseTypeMirrorString; |
||||
import static org.junit.Assert.*; |
||||
|
||||
public class JdbcMapperProcessorTest { |
||||
|
||||
@Test |
||||
public void baseTypeMirrorStringTest() { |
||||
// generics
|
||||
assertEquals("java.util.List", baseTypeMirrorString("java.util.List<java.util.Map<java.lang.String,java.lang.String>>")); |
||||
assertEquals("java.util.Map", baseTypeMirrorString("java.util.Map<java.lang.String,java.lang.String>")); |
||||
assertEquals("java.util.Map", baseTypeMirrorString("java.util.Map<java.lang.String,java.util.List<com.moparisthebest.jdbc.dto.FieldPerson>>")); |
||||
// how java 8 formats TYPE_USE annotations
|
||||
assertEquals("java.lang.String", baseTypeMirrorString("(@com.moparisthebest.jdbc.TypeUseAnnotation :: java.lang.String)")); |
||||
assertEquals("java.util.Date", baseTypeMirrorString("(@com.moparisthebest.jdbc.TypeUseAnnotation :: java.util.Date)")); |
||||
// how java 13 formats TYPE_USE annotations
|
||||
assertEquals("java.lang.String", baseTypeMirrorString("@com.moparisthebest.jdbc.TypeUseAnnotation java.lang.String")); |
||||
assertEquals("java.util.Date", baseTypeMirrorString("@com.moparisthebest.jdbc.TypeUseAnnotation java.util.Date")); |
||||
} |
||||
} |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
package com.moparisthebest.jdbc; |
||||
|
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.Target; |
||||
|
||||
import static java.lang.annotation.ElementType.*; |
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME; |
||||
|
||||
@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER |
||||
//IFJAVA8_START
|
||||
, TYPE_USE |
||||
//IFJAVA8_END
|
||||
}) |
||||
@Retention(RUNTIME) |
||||
public @interface TypeUseAnnotation { |
||||
} |
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
package com.moparisthebest.jdbc.dto; |
||||
|
||||
import com.moparisthebest.jdbc.TypeUseAnnotation; |
||||
|
||||
import java.util.Date; |
||||
|
||||
public class TypeUsePerson implements Person { |
||||
|
||||
public long personNo; |
||||
|
||||
@TypeUseAnnotation |
||||
public Date birthDate; |
||||
@TypeUseAnnotation |
||||
public String firstName, lastName; |
||||
|
||||
public long getPersonNo() { |
||||
return personNo; |
||||
} |
||||
|
||||
public Date getBirthDate() { |
||||
return birthDate; |
||||
} |
||||
|
||||
public String getFirstName() { |
||||
return firstName; |
||||
} |
||||
|
||||
public String getLastName() { |
||||
return lastName; |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(final Object o) { |
||||
return PersonEqualsHashCode.equals(this, o); |
||||
} |
||||
|
||||
@Override |
||||
public int hashCode() { |
||||
return PersonEqualsHashCode.hashCode(this); |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return this.getClass().getSimpleName()+"{" + |
||||
"personNo=" + personNo + |
||||
", birthDate=" + birthDate + |
||||
", firstName='" + firstName + '\'' + |
||||
", lastName='" + lastName + '\'' + |
||||
'}'; |
||||
} |
||||
} |
Loading…
Reference in new issue