METAGEN-78 Replacing @SupportedSourceVersion(RELEASE_6) with 'public SourceVersion getSupportedSourceVersion()'

This commit is contained in:
Hardy Ferentschik 2012-01-16 12:45:49 +01:00 committed by Strong Liu
parent f88284036f
commit 0f1cc39d9c
4 changed files with 65 additions and 46 deletions

View File

@ -12,41 +12,6 @@
<inceptionYear>2009</inceptionYear>
<dependencies>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>5.8</version>
<classifier>jdk15</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.0.Beta1</version>
<scope>test</scope>
</dependency>
</dependencies>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
@ -100,6 +65,41 @@
</developer>
</developers>
<dependencies>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>5.8</version>
<classifier>jdk15</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.0.Beta1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<defaultGoal>test</defaultGoal>

View File

@ -27,7 +27,7 @@ import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedOptions;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
@ -51,8 +51,6 @@ import org.hibernate.jpamodelgen.util.StringUtil;
import org.hibernate.jpamodelgen.util.TypeUtils;
import org.hibernate.jpamodelgen.xml.XmlParser;
import static javax.lang.model.SourceVersion.RELEASE_6;
/**
* Main annotation processor.
*
@ -63,7 +61,6 @@ import static javax.lang.model.SourceVersion.RELEASE_6;
@SupportedAnnotationTypes({
"javax.persistence.Entity", "javax.persistence.MappedSuperclass", "javax.persistence.Embeddable"
})
@SupportedSourceVersion(RELEASE_6)
@SupportedOptions({
JPAMetaModelEntityProcessor.DEBUG_OPTION,
JPAMetaModelEntityProcessor.PERSISTENCE_XML_OPTION,
@ -84,6 +81,7 @@ public class JPAMetaModelEntityProcessor extends AbstractProcessor {
private Context context;
@Override
public void init(ProcessingEnvironment env) {
super.init( env );
context = new Context( env );
@ -107,6 +105,11 @@ public class JPAMetaModelEntityProcessor extends AbstractProcessor {
}
}
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latestSupported();
}
@Override
public boolean process(final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnvironment) {
// see also METAGEN-45

View File

@ -14,8 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.jpamodelgen.test.arraytype;
import org.testng.annotations.Test;

View File

@ -171,7 +171,7 @@ public class TestUtil {
Type actualType = type.getActualTypeArguments()[1];
if ( expectedType.isArray() ) {
expectedType = expectedType.getComponentType();
actualType = ( ( GenericArrayType ) actualType ).getGenericComponentType();
actualType = getComponentType( actualType );
}
assertEquals(
actualType,
@ -191,7 +191,6 @@ public class TestUtil {
assertEquals( actualMapKeyValue, expectedMapValue, errorString );
}
public static void assertSuperClassRelationShipInMetamodel(Class<?> entityClass, Class<?> superEntityClass) {
String entityModelClassName = entityClass.getName() + META_MODEL_CLASS_POSTFIX;
String superEntityModelClassName = superEntityClass.getName() + META_MODEL_CLASS_POSTFIX;
@ -238,6 +237,25 @@ public class TestUtil {
return getFieldFromMetamodelFor( clazz, fieldName ) != null;
}
private static Type getComponentType(Type actualType) {
if ( actualType instanceof Class ) {
Class<?> clazz = (Class<?>) actualType;
if ( clazz.isArray() ) {
return clazz.getComponentType();
}
else {
fail("Unexpected component type");
}
}
if ( actualType instanceof GenericArrayType ) {
return ( (GenericArrayType) actualType ).getGenericComponentType();
} else {
fail("Unexpected component type");
return null; // making the compiler happy
}
}
private static class MetaModelFilenameFilter implements FileFilter {
@Override
public boolean accept(File pathName) {