HHH-6133 Formatting and applying missing licence header

This commit is contained in:
Hardy Ferentschik 2011-05-12 11:07:10 +02:00
parent 0e20d34cd8
commit 095e858f77
38 changed files with 372 additions and 93 deletions

View File

@ -23,6 +23,7 @@
*/ */
package org.hibernate.metamodel.source.annotations.xml.filter; package org.hibernate.metamodel.source.annotations.xml.filter;
import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -40,13 +41,10 @@ abstract class AbstractAnnotationFilter implements IndexedAnnotationFilter {
protected static final DotName[] EMPTY_DOTNAME_ARRAY = new DotName[0]; protected static final DotName[] EMPTY_DOTNAME_ARRAY = new DotName[0];
private Set<DotName> candidates; private Set<DotName> candidates;
private boolean match(DotName annName) { private boolean match(DotName annName) {
if ( candidates == null ) { if ( candidates == null ) {
candidates = new HashSet<DotName>(); candidates = new HashSet<DotName>();
for ( DotName name : targetAnnotation() ) { candidates.addAll( Arrays.asList( targetAnnotation() ) );
candidates.add( name );
}
} }
return candidates.contains( annName ); return candidates.contains( annName );
} }

View File

@ -1,3 +1,26 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc..
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations.xml.filter; package org.hibernate.metamodel.source.annotations.xml.filter;
import java.util.List; import java.util.List;
@ -32,5 +55,4 @@ class NameAnnotationFilter extends AbstractAnnotationFilter {
ENTITY_LISTENERS ENTITY_LISTENERS
}; };
} }
} }

View File

@ -89,9 +89,6 @@ class NameTargetAnnotationFilter extends AbstractAnnotationFilter {
MAP_KEY_CLASS, MAP_KEY_CLASS,
MAP_KEY_COLUMN, MAP_KEY_COLUMN,
MAP_KEY_ENUMERATED MAP_KEY_ENUMERATED
}; };
} }
} }

View File

@ -52,7 +52,8 @@ abstract class AbstractEntityObjectMocker extends AnnotationMocker {
AbstractEntityObjectMocker(IndexBuilder indexBuilder, EntityMappingsMocker.Default defaults) { AbstractEntityObjectMocker(IndexBuilder indexBuilder, EntityMappingsMocker.Default defaults) {
super( indexBuilder, defaults ); super( indexBuilder, defaults );
} }
private boolean isPreProcessCalled=false;
private boolean isPreProcessCalled = false;
final void preProcess() { final void preProcess() {
applyDefaults(); applyDefaults();
@ -64,7 +65,7 @@ abstract class AbstractEntityObjectMocker extends AnnotationMocker {
} }
final void process() { final void process() {
if(!isPreProcessCalled){ if ( !isPreProcessCalled ) {
throw new AssertionFailure( "preProcess should be called before process" ); throw new AssertionFailure( "preProcess should be called before process" );
} }
if ( getAccessType() == null ) { if ( getAccessType() == null ) {
@ -177,6 +178,4 @@ abstract class AbstractEntityObjectMocker extends AnnotationMocker {
protected AnnotationTarget getTarget() { protected AnnotationTarget getTarget() {
return classInfo; return classInfo;
} }
} }

View File

@ -51,6 +51,8 @@ import org.hibernate.metamodel.source.annotation.xml.XMLUniqueConstraint;
import org.hibernate.metamodel.source.annotations.JPADotNames; import org.hibernate.metamodel.source.annotations.JPADotNames;
/** /**
* Base class for the mock jandex annotations created from orm.xml.
*
* @author Strong Liu * @author Strong Liu
*/ */
abstract class AbstractMocker implements JPADotNames { abstract class AbstractMocker implements JPADotNames {
@ -60,7 +62,6 @@ abstract class AbstractMocker implements JPADotNames {
this.indexBuilder = indexBuilder; this.indexBuilder = indexBuilder;
} }
abstract protected EntityMappingsMocker.Default getDefaults(); abstract protected EntityMappingsMocker.Default getDefaults();
/** /**
@ -119,9 +120,8 @@ abstract class AbstractMocker implements JPADotNames {
} }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//@Column //@Column
protected AnnotationInstance parserColumn(XMLColumn column, AnnotationTarget target) { protected AnnotationInstance parserColumn(XMLColumn column, AnnotationTarget target) {
if ( column == null ) { if ( column == null ) {
return null; return null;
@ -558,7 +558,6 @@ abstract class AbstractMocker implements JPADotNames {
return create( JOIN_COLUMN, target, annotationValueList ); return create( JOIN_COLUMN, target, annotationValueList );
} }
protected AnnotationInstance parserLob(XMLLob lob, AnnotationTarget target) { protected AnnotationInstance parserLob(XMLLob lob, AnnotationTarget target) {
if ( lob == null ) { if ( lob == null ) {
return null; return null;

View File

@ -40,8 +40,8 @@ import org.hibernate.metamodel.source.annotations.util.JandexHelper;
/** /**
* @author Strong Liu * @author Strong Liu
*/ */
class AccessHelper implements JPADotNames { class AccessHelper implements JPADotNames {
static XMLAccessType getAccessFromIdPosition(DotName className, IndexBuilder indexBuilder) { static XMLAccessType getAccessFromIdPosition(DotName className, IndexBuilder indexBuilder) {
Map<DotName, List<AnnotationInstance>> indexedAnnotations = indexBuilder.getIndexedAnnotations( className ); Map<DotName, List<AnnotationInstance>> indexedAnnotations = indexBuilder.getIndexedAnnotations( className );
Map<DotName, List<AnnotationInstance>> ormAnnotations = indexBuilder.getClassInfoAnnotationsMap( className ); Map<DotName, List<AnnotationInstance>> ormAnnotations = indexBuilder.getClassInfoAnnotationsMap( className );
XMLAccessType accessType = getAccessFromIdPosition( ormAnnotations ); XMLAccessType accessType = getAccessFromIdPosition( ormAnnotations );
@ -93,11 +93,11 @@ import org.hibernate.metamodel.source.annotations.util.JandexHelper;
return accessType; return accessType;
} }
static XMLAccessType annotationTargetToAccessType(AnnotationTarget target) { static XMLAccessType annotationTargetToAccessType(AnnotationTarget target) {
return ( target instanceof MethodInfo ) ? XMLAccessType.PROPERTY : XMLAccessType.FIELD; return ( target instanceof MethodInfo ) ? XMLAccessType.PROPERTY : XMLAccessType.FIELD;
} }
static XMLAccessType getEntityAccess(DotName className, IndexBuilder indexBuilder) { static XMLAccessType getEntityAccess(DotName className, IndexBuilder indexBuilder) {
Map<DotName, List<AnnotationInstance>> indexedAnnotations = indexBuilder.getIndexedAnnotations( className ); Map<DotName, List<AnnotationInstance>> indexedAnnotations = indexBuilder.getIndexedAnnotations( className );
Map<DotName, List<AnnotationInstance>> ormAnnotations = indexBuilder.getClassInfoAnnotationsMap( className ); Map<DotName, List<AnnotationInstance>> ormAnnotations = indexBuilder.getClassInfoAnnotationsMap( className );
XMLAccessType accessType = getAccess( ormAnnotations ); XMLAccessType accessType = getAccess( ormAnnotations );
@ -138,7 +138,7 @@ import org.hibernate.metamodel.source.annotations.util.JandexHelper;
.containsKey( EMBEDDABLE ); .containsKey( EMBEDDABLE );
} }
static XMLAccessType getAccessFromAttributeAnnotation(DotName className, String attributeName, IndexBuilder indexBuilder) { static XMLAccessType getAccessFromAttributeAnnotation(DotName className, String attributeName, IndexBuilder indexBuilder) {
Map<DotName, List<AnnotationInstance>> indexedAnnotations = indexBuilder.getIndexedAnnotations( className ); Map<DotName, List<AnnotationInstance>> indexedAnnotations = indexBuilder.getIndexedAnnotations( className );
if ( indexedAnnotations != null && indexedAnnotations.containsKey( ACCESS ) ) { if ( indexedAnnotations != null && indexedAnnotations.containsKey( ACCESS ) ) {
List<AnnotationInstance> annotationInstances = indexedAnnotations.get( ACCESS ); List<AnnotationInstance> annotationInstances = indexedAnnotations.get( ACCESS );

View File

@ -27,10 +27,8 @@ package org.hibernate.metamodel.source.annotations.xml.mocker;
* @author Strong Liu * @author Strong Liu
*/ */
abstract class AnnotationMocker extends AbstractMocker { abstract class AnnotationMocker extends AbstractMocker {
private EntityMappingsMocker.Default defaults; private EntityMappingsMocker.Default defaults;
AnnotationMocker(IndexBuilder indexBuilder, EntityMappingsMocker.Default defaults) { AnnotationMocker(IndexBuilder indexBuilder, EntityMappingsMocker.Default defaults) {
super( indexBuilder ); super( indexBuilder );
this.defaults = defaults; this.defaults = defaults;

View File

@ -106,6 +106,4 @@ class AttributesBuilder extends AbstractAttributesBuilder {
XMLEmbeddedId getEmbeddedId() { XMLEmbeddedId getEmbeddedId() {
return attributes.getEmbeddedId(); return attributes.getEmbeddedId();
} }
} }

View File

@ -66,9 +66,9 @@ class BasicMocker extends PropertyMocker {
protected XMLAccessType getAccessType() { protected XMLAccessType getAccessType() {
return basic.getAccess(); return basic.getAccess();
} }
@Override
@Override
protected void setAccessType(XMLAccessType accessType) { protected void setAccessType(XMLAccessType accessType) {
basic.setAccess( accessType ); basic.setAccess( accessType );
} }
} }

View File

@ -71,8 +71,6 @@ class ElementCollectionMocker extends PropertyMocker {
parserMapKeyClass( elementCollection.getMapKeyClass(), getTarget() ); parserMapKeyClass( elementCollection.getMapKeyClass(), getTarget() );
parserMapKeyEnumerated( elementCollection.getMapKeyEnumerated(), getTarget() ); parserMapKeyEnumerated( elementCollection.getMapKeyEnumerated(), getTarget() );
parserMapKeyTemporal( elementCollection.getMapKeyTemporal(), getTarget() ); parserMapKeyTemporal( elementCollection.getMapKeyTemporal(), getTarget() );
} }
@Override @Override
@ -84,7 +82,8 @@ class ElementCollectionMocker extends PropertyMocker {
protected XMLAccessType getAccessType() { protected XMLAccessType getAccessType() {
return elementCollection.getAccess(); return elementCollection.getAccess();
} }
@Override
@Override
protected void setAccessType(XMLAccessType accessType) { protected void setAccessType(XMLAccessType accessType) {
elementCollection.setAccess( accessType ); elementCollection.setAccess( accessType );
} }

View File

@ -107,6 +107,4 @@ class EmbeddableAttributesBuilder extends AbstractAttributesBuilder {
XMLEmbeddedId getEmbeddedId() { XMLEmbeddedId getEmbeddedId() {
return null; return null;
} }
} }

View File

@ -41,6 +41,7 @@ import org.hibernate.metamodel.source.annotation.xml.XMLPreUpdate;
/** /**
* Mock <embeddable> to {@link javax.persistence.Embeddable @Embeddable} * Mock <embeddable> to {@link javax.persistence.Embeddable @Embeddable}
*
* @author Strong Liu * @author Strong Liu
*/ */
class EmbeddableMocker extends AbstractEntityObjectMocker { class EmbeddableMocker extends AbstractEntityObjectMocker {
@ -78,7 +79,6 @@ class EmbeddableMocker extends AbstractEntityObjectMocker {
embeddable.setMetadataComplete( getDefaults().getMetadataComplete() ); embeddable.setMetadataComplete( getDefaults().getMetadataComplete() );
} }
LOG.debugf( "Adding XML overriding information for %s", className ); LOG.debugf( "Adding XML overriding information for %s", className );
} }
@Override @Override

View File

@ -53,7 +53,8 @@ class EmbeddedIdMocker extends PropertyMocker {
protected XMLAccessType getAccessType() { protected XMLAccessType getAccessType() {
return embeddedId.getAccess(); return embeddedId.getAccess();
} }
@Override
@Override
protected void setAccessType(XMLAccessType accessType) { protected void setAccessType(XMLAccessType accessType) {
embeddedId.setAccess( accessType ); embeddedId.setAccess( accessType );
} }

View File

@ -251,9 +251,5 @@ public class EntityMappingsMocker {
} }
} }
} }
} }
} }

View File

@ -1,3 +1,26 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc..
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations.xml.mocker; package org.hibernate.metamodel.source.annotations.xml.mocker;
import java.util.ArrayList; import java.util.ArrayList;
@ -30,8 +53,6 @@ import org.hibernate.metamodel.source.annotation.xml.XMLPreRemove;
import org.hibernate.metamodel.source.annotation.xml.XMLPreUpdate; import org.hibernate.metamodel.source.annotation.xml.XMLPreUpdate;
import org.hibernate.metamodel.source.annotation.xml.XMLSecondaryTable; import org.hibernate.metamodel.source.annotation.xml.XMLSecondaryTable;
import org.hibernate.metamodel.source.annotation.xml.XMLTable; import org.hibernate.metamodel.source.annotation.xml.XMLTable;
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
/** /**
* Mock <entity> to {@link javax.persistence.Entity @Entity} * Mock <entity> to {@link javax.persistence.Entity @Entity}
@ -313,6 +334,4 @@ class EntityMocker extends AbstractEntityObjectMocker {
return MockHelper.EMPTY_ANNOTATION_VALUE_ARRAY; return MockHelper.EMPTY_ANNOTATION_VALUE_ARRAY;
} }
} }

View File

@ -1,3 +1,26 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc..
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations.xml.mocker; package org.hibernate.metamodel.source.annotations.xml.mocker;
import java.util.ArrayList; import java.util.ArrayList;
@ -118,7 +141,6 @@ class GlobalAnnotations implements JPADotNames {
for ( AnnotationInstance annotationInstance : indexedAnnotationInstanceList ) { for ( AnnotationInstance annotationInstance : indexedAnnotationInstanceList ) {
pushIfNotExist( annotationInstance ); pushIfNotExist( annotationInstance );
} }
} }
private void pushIfNotExist(AnnotationInstance annotationInstance) { private void pushIfNotExist(AnnotationInstance annotationInstance) {
@ -142,7 +164,6 @@ class GlobalAnnotations implements JPADotNames {
if ( isNotExist ) { if ( isNotExist ) {
push( annName, annotationInstance ); push( annName, annotationInstance );
} }
} }
void collectGlobalMappings(XMLEntityMappings entityMappings, EntityMappingsMocker.Default defaults) { void collectGlobalMappings(XMLEntityMappings entityMappings, EntityMappingsMocker.Default defaults) {
@ -225,6 +246,4 @@ class GlobalAnnotations implements JPADotNames {
} }
return generator; return generator;
} }
} }

View File

@ -46,6 +46,7 @@ import org.hibernate.metamodel.source.annotation.xml.XMLTableGenerator;
/** /**
* note: Global Configurations {@link org.hibernate.metamodel.source.annotations.xml.filter.IndexedAnnotationFilter.GLOBAL_ANNOTATIONS} * note: Global Configurations {@link org.hibernate.metamodel.source.annotations.xml.filter.IndexedAnnotationFilter.GLOBAL_ANNOTATIONS}
* in the new build Index has no target * in the new build Index has no target
*
* @author Strong Liu * @author Strong Liu
*/ */
class GlobalConfigurationMocker extends AbstractMocker { class GlobalConfigurationMocker extends AbstractMocker {
@ -165,7 +166,9 @@ class GlobalConfigurationMocker extends AbstractMocker {
"", annotationInstance "", annotationInstance
); );
} }
MockHelper.addToCollectionIfNotNull( annotationValueList, AnnotationValue.createArrayValue( name, values ) ); MockHelper.addToCollectionIfNotNull(
annotationValueList, AnnotationValue.createArrayValue( name, values )
);
} }
} }
@ -183,7 +186,9 @@ class GlobalConfigurationMocker extends AbstractMocker {
"", annotationInstance "", annotationInstance
); );
} }
MockHelper.addToCollectionIfNotNull( annotationValueList, AnnotationValue.createArrayValue( name, values ) ); MockHelper.addToCollectionIfNotNull(
annotationValueList, AnnotationValue.createArrayValue( name, values )
);
} }
} }
@ -205,7 +210,9 @@ class GlobalConfigurationMocker extends AbstractMocker {
"", annotationInstance "", annotationInstance
); );
} }
MockHelper.addToCollectionIfNotNull( annotationValueList, AnnotationValue.createArrayValue( name, values ) ); MockHelper.addToCollectionIfNotNull(
annotationValueList, AnnotationValue.createArrayValue( name, values )
);
} }
} }
@ -290,7 +297,9 @@ class GlobalConfigurationMocker extends AbstractMocker {
"", annotationInstance "", annotationInstance
); );
} }
MockHelper.addToCollectionIfNotNull( annotationValueList, AnnotationValue.createArrayValue( name, values ) ); MockHelper.addToCollectionIfNotNull(
annotationValueList, AnnotationValue.createArrayValue( name, values )
);
} }
} }

View File

@ -25,17 +25,12 @@ package org.hibernate.metamodel.source.annotations.xml.mocker;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget; import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.AnnotationValue; import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.ClassInfo; import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.jandex.MethodInfo;
import org.hibernate.AnnotationException;
import org.hibernate.HibernateException;
import org.hibernate.metamodel.source.annotation.xml.XMLAccessType; import org.hibernate.metamodel.source.annotation.xml.XMLAccessType;
import org.hibernate.metamodel.source.annotation.xml.XMLGeneratedValue; import org.hibernate.metamodel.source.annotation.xml.XMLGeneratedValue;
import org.hibernate.metamodel.source.annotation.xml.XMLId; import org.hibernate.metamodel.source.annotation.xml.XMLId;
@ -86,6 +81,4 @@ class IdMocker extends PropertyMocker {
protected void setAccessType(XMLAccessType accessType) { protected void setAccessType(XMLAccessType accessType) {
id.setAccess( accessType ); id.setAccess( accessType );
} }
} }

View File

@ -157,7 +157,8 @@ public class IndexBuilder {
public ClassInfo getClassInfo(DotName name) { public ClassInfo getClassInfo(DotName name) {
return classes.get( name ); return classes.get( name );
} }
public ClassInfo getIndexedClassInfo(DotName name){
public ClassInfo getIndexedClassInfo(DotName name) {
return index.getClassByName( name ); return index.getClassByName( name );
} }
@ -303,6 +304,4 @@ public class IndexBuilder {
} }
} }
} }
} }

View File

@ -66,7 +66,7 @@ class ListenerMocker extends AbstractMocker {
parser( listener ); parser( listener );
} }
MockHelper.classArrayValue( "value", clazzNameList, annotationValueList,indexBuilder.getServiceRegistry() ); MockHelper.classArrayValue( "value", clazzNameList, annotationValueList, indexBuilder.getServiceRegistry() );
return create( ENTITY_LISTENERS, annotationValueList ); return create( ENTITY_LISTENERS, annotationValueList );
} }
@ -81,7 +81,7 @@ class ListenerMocker extends AbstractMocker {
builder.parser( listener.getPrePersist() ); builder.parser( listener.getPrePersist() );
builder.parser( listener.getPreRemove() ); builder.parser( listener.getPreRemove() );
builder.parser( listener.getPreUpdate() ); builder.parser( listener.getPreUpdate() );
indexBuilder.finishEntityObject( tempClassInfo.name(),null ); indexBuilder.finishEntityObject( tempClassInfo.name(), null );
} }
//@PrePersist //@PrePersist

View File

@ -63,8 +63,8 @@ class ManyToManyMocker extends PropertyMocker {
parserMapKeyTemporal( manyToMany.getMapKeyTemporal(), getTarget() ); parserMapKeyTemporal( manyToMany.getMapKeyTemporal(), getTarget() );
parserMapKeyEnumerated( manyToMany.getMapKeyEnumerated(), getTarget() ); parserMapKeyEnumerated( manyToMany.getMapKeyEnumerated(), getTarget() );
parserMapKey( manyToMany.getMapKey(), getTarget() ); parserMapKey( manyToMany.getMapKey(), getTarget() );
parserAttributeOverrides( manyToMany.getMapKeyAttributeOverride(),getTarget() ); parserAttributeOverrides( manyToMany.getMapKeyAttributeOverride(), getTarget() );
parserMapKeyJoinColumnList( manyToMany.getMapKeyJoinColumn(),getTarget() ); parserMapKeyJoinColumnList( manyToMany.getMapKeyJoinColumn(), getTarget() );
parserOrderColumn( manyToMany.getOrderColumn(), getTarget() ); parserOrderColumn( manyToMany.getOrderColumn(), getTarget() );
parserJoinTable( manyToMany.getJoinTable(), getTarget() ); parserJoinTable( manyToMany.getJoinTable(), getTarget() );
if ( manyToMany.getOrderBy() != null ) { if ( manyToMany.getOrderBy() != null ) {
@ -76,7 +76,8 @@ class ManyToManyMocker extends PropertyMocker {
protected XMLAccessType getAccessType() { protected XMLAccessType getAccessType() {
return manyToMany.getAccess(); return manyToMany.getAccess();
} }
@Override
@Override
protected void setAccessType(XMLAccessType accessType) { protected void setAccessType(XMLAccessType accessType) {
manyToMany.setAccess( accessType ); manyToMany.setAccess( accessType );
} }

View File

@ -72,9 +72,9 @@ class ManyToOneMocker extends PropertyMocker {
protected XMLAccessType getAccessType() { protected XMLAccessType getAccessType() {
return manyToOne.getAccess(); return manyToOne.getAccess();
} }
@Override
@Override
protected void setAccessType(XMLAccessType accessType) { protected void setAccessType(XMLAccessType accessType) {
manyToOne.setAccess( accessType ); manyToOne.setAccess( accessType );
} }
} }

View File

@ -41,6 +41,7 @@ import org.hibernate.metamodel.source.annotation.xml.XMLPreUpdate;
/** /**
* Mock <mapped-superclass> to {@link javax.persistence.MappedSuperclass @MappedSuperClass} * Mock <mapped-superclass> to {@link javax.persistence.MappedSuperclass @MappedSuperClass}
*
* @author Strong Liu * @author Strong Liu
*/ */
class MappedSuperclassMocker extends AbstractEntityObjectMocker { class MappedSuperclassMocker extends AbstractEntityObjectMocker {
@ -54,6 +55,7 @@ class MappedSuperclassMocker extends AbstractEntityObjectMocker {
super( indexBuilder, defaults ); super( indexBuilder, defaults );
this.mappedSuperclass = mappedSuperclass; this.mappedSuperclass = mappedSuperclass;
} }
@Override @Override
protected void applyDefaults() { protected void applyDefaults() {
String className = MockHelper.buildSafeClassName( mappedSuperclass.getClazz(), getDefaults().getPackageName() ); String className = MockHelper.buildSafeClassName( mappedSuperclass.getClazz(), getDefaults().getPackageName() );
@ -142,6 +144,4 @@ class MappedSuperclassMocker extends AbstractEntityObjectMocker {
protected XMLPostLoad getPostLoad() { protected XMLPostLoad getPostLoad() {
return mappedSuperclass.getPostLoad(); return mappedSuperclass.getPostLoad();
} }
} }

View File

@ -60,7 +60,7 @@ class OneToManyMocker extends PropertyMocker {
MockHelper.cascadeValue( "cascade", oneToMany.getCascade(), isDefaultCascadePersist(), annotationValueList ); MockHelper.cascadeValue( "cascade", oneToMany.getCascade(), isDefaultCascadePersist(), annotationValueList );
create( ONE_TO_MANY, getTarget(), annotationValueList ); create( ONE_TO_MANY, getTarget(), annotationValueList );
parserAttributeOverrides( oneToMany.getMapKeyAttributeOverride(), getTarget() ); parserAttributeOverrides( oneToMany.getMapKeyAttributeOverride(), getTarget() );
parserMapKeyJoinColumnList( oneToMany.getMapKeyJoinColumn(),getTarget() ); parserMapKeyJoinColumnList( oneToMany.getMapKeyJoinColumn(), getTarget() );
parserMapKey( oneToMany.getMapKey(), getTarget() ); parserMapKey( oneToMany.getMapKey(), getTarget() );
parserMapKeyColumn( oneToMany.getMapKeyColumn(), getTarget() ); parserMapKeyColumn( oneToMany.getMapKeyColumn(), getTarget() );
parserMapKeyClass( oneToMany.getMapKeyClass(), getTarget() ); parserMapKeyClass( oneToMany.getMapKeyClass(), getTarget() );
@ -78,7 +78,8 @@ class OneToManyMocker extends PropertyMocker {
protected XMLAccessType getAccessType() { protected XMLAccessType getAccessType() {
return oneToMany.getAccess(); return oneToMany.getAccess();
} }
@Override
@Override
protected void setAccessType(XMLAccessType accessType) { protected void setAccessType(XMLAccessType accessType) {
oneToMany.setAccess( accessType ); oneToMany.setAccess( accessType );
} }

View File

@ -76,7 +76,8 @@ class OneToOneMocker extends PropertyMocker {
protected XMLAccessType getAccessType() { protected XMLAccessType getAccessType() {
return oneToOne.getAccess(); return oneToOne.getAccess();
} }
@Override
@Override
protected void setAccessType(XMLAccessType accessType) { protected void setAccessType(XMLAccessType accessType) {
oneToOne.setAccess( accessType ); oneToOne.setAccess( accessType );
} }

View File

@ -53,7 +53,8 @@ class TransientMocker extends PropertyMocker {
protected XMLAccessType getAccessType() { protected XMLAccessType getAccessType() {
return XMLAccessType.FIELD; return XMLAccessType.FIELD;
} }
@Override
@Override
protected void setAccessType(XMLAccessType accessType) { protected void setAccessType(XMLAccessType accessType) {
//ignore //ignore
} }

View File

@ -55,10 +55,9 @@ class VersionMocker extends PropertyMocker {
protected XMLAccessType getAccessType() { protected XMLAccessType getAccessType() {
return version.getAccess(); return version.getAccess();
} }
@Override
@Override
protected void setAccessType(XMLAccessType accessType) { protected void setAccessType(XMLAccessType accessType) {
version.setAccess( accessType ); version.setAccess( accessType );
} }
} }

View File

@ -50,5 +50,4 @@ class XMLAssociationOverrideProxy extends XMLAssociationOverride {
void setJoinTableAnnotationValue(AnnotationValue joinTableAnnotationValue) { void setJoinTableAnnotationValue(AnnotationValue joinTableAnnotationValue) {
this.joinTableAnnotationValue = joinTableAnnotationValue; this.joinTableAnnotationValue = joinTableAnnotationValue;
} }
} }

View File

@ -0,0 +1,28 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations.xml.mocker;
/**
* Mocker classes to create mock JPA annotations from orm.xml
*/

View File

@ -1,3 +1,26 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc..
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations.xml.mocker; package org.hibernate.metamodel.source.annotations.xml.mocker;
import java.io.IOException; import java.io.IOException;

View File

@ -1,3 +1,26 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc..
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations.xml.mocker; package org.hibernate.metamodel.source.annotations.xml.mocker;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -1,3 +1,26 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc..
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations.xml.mocker; package org.hibernate.metamodel.source.annotations.xml.mocker;
import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationInstance;

View File

@ -1,3 +1,26 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc..
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations.xml.mocker; package org.hibernate.metamodel.source.annotations.xml.mocker;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -1,3 +1,26 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc..
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations.xml.mocker; package org.hibernate.metamodel.source.annotations.xml.mocker;
import org.jboss.jandex.ClassInfo; import org.jboss.jandex.ClassInfo;

View File

@ -1,3 +1,26 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc..
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations.xml.mocker; package org.hibernate.metamodel.source.annotations.xml.mocker;
/** /**

View File

@ -1,3 +1,26 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc..
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations.xml.mocker; package org.hibernate.metamodel.source.annotations.xml.mocker;
/** /**

View File

@ -1,3 +1,26 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc..
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations.xml.mocker; package org.hibernate.metamodel.source.annotations.xml.mocker;
import java.util.List; import java.util.List;
@ -31,7 +54,6 @@ public class OverrideTest extends AbstractMockerTest {
}; };
} }
@Test @Test
public void testPersistenceUnitMetadataMetadataComplete() { public void testPersistenceUnitMetadataMetadataComplete() {
XMLEntity author = new XMLEntity(); XMLEntity author = new XMLEntity();
@ -51,24 +73,25 @@ public class OverrideTest extends AbstractMockerTest {
@Test @Test
public void testEntityMetadataComplete() { public void testEntityMetadataComplete() {
Index index =getMockedIndex( "entity-metadata-complete.xml" ); Index index = getMockedIndex( "entity-metadata-complete.xml" );
DotName authorName = DotName.createSimple( Author.class.getName() ); DotName authorName = DotName.createSimple( Author.class.getName() );
ClassInfo authorClassInfo= index.getClassByName( authorName ); ClassInfo authorClassInfo = index.getClassByName( authorName );
assertHasAnnotation( index,authorName,JPADotNames.ENTITY ); assertHasAnnotation( index, authorName, JPADotNames.ENTITY );
assertHasAnnotation( index, authorName, JPADotNames.ID_CLASS ); assertHasAnnotation( index, authorName, JPADotNames.ID_CLASS );
assertEquals( 2, authorClassInfo.annotations().size() ); assertEquals( 2, authorClassInfo.annotations().size() );
DotName bookName = DotName.createSimple( Book.class.getName() ); DotName bookName = DotName.createSimple( Book.class.getName() );
assertHasAnnotation( index,bookName,JPADotNames.ENTITY ); assertHasAnnotation( index, bookName, JPADotNames.ENTITY );
} }
@Test @Test
public void testOverrideToMappedSuperClass(){ public void testOverrideToMappedSuperClass() {
Index index =getMockedIndex( "override-to-mappedsuperclass.xml" ); Index index = getMockedIndex( "override-to-mappedsuperclass.xml" );
index.printAnnotations(); index.printAnnotations();
DotName authorName = DotName.createSimple( Author.class.getName() ); DotName authorName = DotName.createSimple( Author.class.getName() );
assertHasAnnotation( index,authorName,JPADotNames.ENTITY ); assertHasAnnotation( index, authorName, JPADotNames.ENTITY );
assertHasNoAnnotation( index, authorName, JPADotNames.TABLE ); assertHasNoAnnotation( index, authorName, JPADotNames.TABLE );
DotName bookName = DotName.createSimple( Book.class.getName() ); DotName bookName = DotName.createSimple( Book.class.getName() );
assertHasAnnotation( index,bookName,JPADotNames.MAPPED_SUPERCLASS ); assertHasAnnotation( index, bookName, JPADotNames.MAPPED_SUPERCLASS );
assertHasNoAnnotation( index, bookName, JPADotNames.TABLE ); assertHasNoAnnotation( index, bookName, JPADotNames.TABLE );
} }
@ -93,7 +116,7 @@ public class OverrideTest extends AbstractMockerTest {
@Test @Test
public void testPersistenceUnitDefaultsCascadePersistInXML() { public void testPersistenceUnitDefaultsCascadePersistInXML() {
Index index =getMockedIndex( "AttributeOverride.xml" ); Index index = getMockedIndex( "AttributeOverride.xml" );
DotName className = DotName.createSimple( Author.class.getName() ); DotName className = DotName.createSimple( Author.class.getName() );
assertAnnotationValue( assertAnnotationValue(
index, index,
@ -129,7 +152,7 @@ public class OverrideTest extends AbstractMockerTest {
*/ */
@Test @Test
public void testAttributeOverride() { public void testAttributeOverride() {
Index index =getMockedIndex( "AttributeOverride.xml" ); Index index = getMockedIndex( "AttributeOverride.xml" );
DotName className = DotName.createSimple( Book.class.getName() ); DotName className = DotName.createSimple( Book.class.getName() );
index.printAnnotations(); index.printAnnotations();
assertHasNoAnnotation( assertHasNoAnnotation(
@ -140,7 +163,7 @@ public class OverrideTest extends AbstractMockerTest {
assertAnnotationValue( assertAnnotationValue(
index, index,
className, className,
JPADotNames.ATTRIBUTE_OVERRIDES, new AnnotationValueChecker() { JPADotNames.ATTRIBUTE_OVERRIDES, new AnnotationValueChecker() {
@Override @Override
public void check(AnnotationInstance annotationInstance) { public void check(AnnotationInstance annotationInstance) {
AnnotationValue value = annotationInstance.value(); AnnotationValue value = annotationInstance.value();
@ -167,7 +190,7 @@ public class OverrideTest extends AbstractMockerTest {
@Test @Test
public void testSchemaInPersistenceMetadata() { public void testSchemaInPersistenceMetadata() {
Index index =getMockedIndex( "default-schema.xml" ); Index index = getMockedIndex( "default-schema.xml" );
index.printAnnotations(); index.printAnnotations();
//Global Configuration should be accessed like this, not from ClassInfo //Global Configuration should be accessed like this, not from ClassInfo
List<AnnotationInstance> annotationInstanceList = index.getAnnotations( JPADotNames.TABLE_GENERATOR ); List<AnnotationInstance> annotationInstanceList = index.getAnnotations( JPADotNames.TABLE_GENERATOR );
@ -201,7 +224,7 @@ public class OverrideTest extends AbstractMockerTest {
@Test @Test
public void testSchemaInEntityMapping() { public void testSchemaInEntityMapping() {
Index index =getMockedIndex( "default-schema2.xml" ); Index index = getMockedIndex( "default-schema2.xml" );
index.printAnnotations(); index.printAnnotations();
//Global Configuration should be accessed like this, not from ClassInfo //Global Configuration should be accessed like this, not from ClassInfo
List<AnnotationInstance> annotationInstanceList = index.getAnnotations( JPADotNames.TABLE_GENERATOR ); List<AnnotationInstance> annotationInstanceList = index.getAnnotations( JPADotNames.TABLE_GENERATOR );
@ -226,6 +249,4 @@ public class OverrideTest extends AbstractMockerTest {
assertEquals( 0, annotationInstanceList.size() ); assertEquals( 0, annotationInstanceList.size() );
} }
} }

View File

@ -1,3 +1,26 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc..
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations.xml.mocker; package org.hibernate.metamodel.source.annotations.xml.mocker;
import javax.persistence.Embeddable; import javax.persistence.Embeddable;