METAGEN-101 Adding checkstyle plugin and making some style fixes (not 100% Hibernate ORM compatible yet)

This commit is contained in:
Hardy Ferentschik 2013-10-22 15:55:07 +02:00 committed by Strong Liu
parent 0c6b601006
commit fdbfbd03ec
109 changed files with 376 additions and 155 deletions

View File

@ -4,6 +4,7 @@ apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'maven-publish-auth'
apply plugin: 'jdocbook'
apply plugin: 'checkstyle'
task wrapper(type: Wrapper) {
gradleVersion = '1.7'
@ -158,6 +159,13 @@ test {
}
}
checkstyle {
configFile = rootProject.file( 'src/config/checkstyle/checkstyle.xml' )
showViolations = true
ignoreFailures = true
}
checkstyleMain.exclude '**/jaxb/**'
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Javadocs
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -173,7 +181,7 @@ task javadocs(type: Javadoc) {
classpath = files( configurations.compile, "${buildDir}/classes/main" )
maxMemory = '512m'
configure( options ) {
stylesheetFile = rootProject.file( 'src/main/javadoc/stylesheet.css' )
stylesheetFile = rootProject.file( 'src/config/javadoc/stylesheet.css' )
windowTitle = 'Hibernate JPA 2 Metamodel Generator JavaDocs'
docTitle = "Hibernate JPA 2 Metamodel Generator JavaDocs ($project.version)"
bottom = "Copyright &copy; 2001-$copyrightYear <a href=\"http://redhat.com\">Red Hat, Inc.</a> All Rights Reserved."
@ -183,7 +191,7 @@ task javadocs(type: Javadoc) {
doLast {
copy {
from rootProject.file( 'src/main/javadoc/images' )
from rootProject.file( 'src/config/javadoc/images' )
into new File( javadocDir, "/images" )
}
}
@ -298,21 +306,19 @@ publishing {
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Artifact deploy
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
task sourcesJar(type: Jar, dependsOn: compileJava) {
from sourceSets.main.allSource
from sourceSets.main.allSource
classifier = 'sources'
}
artifacts {
archives sourcesJar
archives sourcesJar
}
uploadArchives.dependsOn sourcesJar
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Release
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -0,0 +1,194 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ Copyright (c) 2013, 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
-->
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.1//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<module name="Checker">
<module name="TreeWalker">
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
General regex checks as part of the TreeWalker
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<module name="RegexpSinglelineJava">
<property name="ignoreComments" value="true" />
<property name="format" value="^\t* +\t*\S" />
<property name="message" value="Line has leading space characters; indentation should be performed with tabs only." />
</module>
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Annotation checks
See http://checkstyle.sourceforge.net/config_annotation.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<module name="MissingDeprecated" />
<module name="MissingOverride" />
<module name="PackageAnnotation" />
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Block checks
See http://checkstyle.sourceforge.net/config_blocks.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<module name="AvoidNestedBlocks">
<property name="allowInSwitchCase" value="true" />
<property name="severity" value="warning" />
</module>
<module name="NeedBraces" />
<module name="LeftCurly">
<property name="option" value="eol" />
</module>
<module name="RightCurly">
<property name="option" value="alone" />
</module>
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Design checks
See http://checkstyle.sourceforge.net/config_design.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<module name="HideUtilityClassConstructor" />
<module name="MutableException" />
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Coding checks
See http://checkstyle.sourceforge.net/config_coding.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<module name="EmptyStatement" />
<module name="EqualsHashCode" />
<module name="MissingSwitchDefault" />
<module name="SimplifyBooleanExpression" />
<module name="SimplifyBooleanReturn" />
<module name="StringLiteralEquality" />
<module name="NoFinalizer" />
<module name="ExplicitInitialization" />
<module name="MissingSwitchDefault" />
<module name="DefaultComesLast" />
<module name="FallThrough" />
<module name="OneStatementPerLine" />
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Import checks
See http://checkstyle.sourceforge.net/config_imports.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<module name="AvoidStarImport" />
<module name="RedundantImport" />
<module name="UnusedImports" />
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Misc checks
See http://checkstyle.sourceforge.net/config_misc.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<module name="UpperEll" />
<module name="ArrayTypeStyle" />
<module name="TrailingComment">
<property name="severity" value="warning" />
</module>
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Modifier checks
See http://checkstyle.sourceforge.net/config_modifier.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<module name="ModifierOrder"/>
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Naming checks
See http://checkstyle.sourceforge.net/config_naming.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<module name="AbstractClassName">
<!-- we are just using this to make sure that classes matching the pattern (Abstract*) have the abstract modifier -->
<property name="format" value="^Abstract.*$" />
<property name="ignoreName" value="true" />
</module>
<module name="ConstantName">
<property name="format" value="^[A-Z](_?[A-Z0-9]+)*$|log" />
</module>
<module name="LocalFinalVariableName" />
<module name="LocalVariableName" />
<module name="MemberName" />
<!--
The org.hibernate.engine.spi.ManagedEntity method names (prefixed with '&&_') muck with this
<module name="MethodName" />
-->
<module name="MethodTypeParameterName" />
<module name="PackageName" />
<module name="ParameterName" />
<module name="StaticVariableName" />
<module name="TypeName" />
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Whitespace checks
See http://checkstyle.sourceforge.net/config_whitespace.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<module name="MethodParamPad" />
<module name="TypecastParenPad" />
<module name="ParenPad">
<property name="tokens" value="CTOR_CALL, METHOD_CALL, SUPER_CTOR_CALL" />
<property name="option" value="space" />
</module>
</module>
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Misc checks
See http://checkstyle.sourceforge.net/config_misc.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<module name="NewlineAtEndOfFile" />
</module>

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 270 B

After

Width:  |  Height:  |  Size: 270 B

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -64,7 +64,7 @@ public final class Context {
* Whether all mapping files are xml-mapping-metadata-complete. In this case no annotation processing will take
* place.
*/
private Boolean fullyXmlConfigured = null;
private Boolean fullyXmlConfigured;
private boolean addGeneratedAnnotation = true;
private boolean addGenerationDate;
private boolean addSuppressWarningsAnnotation;

View File

@ -37,7 +37,7 @@ public class ImportContextImpl implements ImportContext {
private String basePackage = "";
private static String LINE_SEPARATOR = System.getProperty( "line.separator" );
private static final String LINE_SEPARATOR = System.getProperty( "line.separator" );
private static final Map<String, String> PRIMITIVES = new HashMap<String, String>();
static {
@ -110,7 +110,7 @@ public class ImportContextImpl implements ImportContext {
if ( inSamePackage( fqcn ) || ( imports.contains( pureFqcn ) && canBeSimple ) ) {
result = unqualify( result ); // de-qualify
result = unqualify( result );
}
else if ( inJavaLang( fqcn ) ) {
result = result.substring( "java.lang.".length() );

View File

@ -80,7 +80,7 @@ public abstract class AnnotationMetaAttribute implements MetaAttribute {
return parent;
}
abstract public String getMetaType();
public abstract String getMetaType();
public String getTypeDeclaration() {
return type;

View File

@ -28,13 +28,16 @@ public class AnnotationMetaMap extends AnnotationMetaCollection {
private final String keyType;
public AnnotationMetaMap(AnnotationMetaEntity parent, Element element, String collectionType,
String keyType, String elementType) {
String keyType, String elementType) {
super( parent, element, collectionType, elementType );
this.keyType = keyType;
}
public String getDeclarationString() {
return "public static volatile " + getHostingEntity().importType( getMetaType() ) + "<" + getHostingEntity().importType( getHostingEntity().getQualifiedName() ) + ", " + getHostingEntity()
.importType( keyType ) + ", " + getHostingEntity().importType( getTypeDeclaration() ) + "> " + getPropertyName() + ";";
return "public static volatile " + getHostingEntity().importType( getMetaType() )
+ "<" + getHostingEntity().importType( getHostingEntity().getQualifiedName() )
+ ", " + getHostingEntity().importType( keyType ) + ", "
+ getHostingEntity().importType( getTypeDeclaration() ) + "> "
+ getPropertyName() + ";";
}
}

View File

@ -40,4 +40,4 @@ public interface ImportContext {
String staticImport(String fqcn, String member);
String generateImports();
}
}

View File

@ -41,7 +41,7 @@ public final class Constants {
public static final String ELEMENT_COLLECTION = "javax.persistence.ElementCollection";
public static final String ACCESS = "javax.persistence.Access";
public static Map<String, String> COLLECTIONS = new HashMap<String, String>();
public static final Map<String, String> COLLECTIONS = new HashMap<String, String>();
static {
COLLECTIONS.put( java.util.Collection.class.getName(), "javax.persistence.metamodel.CollectionAttribute" );
@ -54,7 +54,7 @@ public final class Constants {
COLLECTIONS.put( java.util.SortedMap.class.getName(), "javax.persistence.metamodel.MapAttribute" );
}
public static List<String> BASIC_TYPES = new ArrayList<String>();
public static final List<String> BASIC_TYPES = new ArrayList<String>();
static {
BASIC_TYPES.add( java.lang.String.class.getName() );
@ -76,7 +76,7 @@ public final class Constants {
BASIC_TYPES.add( java.sql.Blob.class.getName() );
}
public static List<String> BASIC_ARRAY_TYPES = new ArrayList<String>();
public static final List<String> BASIC_ARRAY_TYPES = new ArrayList<String>();
static {
BASIC_ARRAY_TYPES.add( java.lang.Character.class.getName() );

View File

@ -44,7 +44,7 @@ public class FileTimeStampChecker implements Serializable {
return false;
}
FileTimeStampChecker that = ( FileTimeStampChecker ) o;
FileTimeStampChecker that = (FileTimeStampChecker) o;
if ( !lastModifiedCache.equals( that.lastModifiedCache ) ) {
return false;

View File

@ -55,9 +55,9 @@ public class XmlParserHelper {
*/
private static final int NUMBER_OF_SCHEMAS = 4;
private static final XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
private static final XMLInputFactory XML_INPUT_FACTORY = XMLInputFactory.newInstance();
private static final ConcurrentMap<String, Schema> schemaCache = new ConcurrentHashMap<String, Schema>(
private static final ConcurrentMap<String, Schema> SCHEMA_CACHE = new ConcurrentHashMap<String, Schema>(
NUMBER_OF_SCHEMAS
);
@ -102,14 +102,14 @@ public class XmlParserHelper {
}
public Schema getSchema(String schemaResource) throws XmlParsingException {
Schema schema = schemaCache.get( schemaResource );
Schema schema = SCHEMA_CACHE.get( schemaResource );
if ( schema != null ) {
return schema;
}
schema = loadSchema( schemaResource );
Schema previous = schemaCache.putIfAbsent( schemaResource, schema );
Schema previous = SCHEMA_CACHE.putIfAbsent( schemaResource, schema );
return previous != null ? previous : schema;
}
@ -147,7 +147,7 @@ public class XmlParserHelper {
}
private synchronized XMLEventReader createXmlEventReader(InputStream xmlStream) throws XMLStreamException {
return xmlInputFactory.createXMLEventReader( xmlStream );
return XML_INPUT_FACTORY.createXMLEventReader( xmlStream );
}
private String getPackage(String resourceName) {

View File

@ -450,6 +450,8 @@ public class JpaDescriptorParser {
case PROPERTY: {
return AccessType.PROPERTY;
}
default: {
}
}
return null;
}

View File

@ -55,7 +55,7 @@ public abstract class XmlMetaAttribute implements MetaAttribute {
}
@Override
abstract public String getMetaType();
public abstract String getMetaType();
@Override
public String toString() {

View File

@ -23,15 +23,15 @@ import org.hibernate.jpamodelgen.model.MetaCollection;
*/
public class XmlMetaCollection extends XmlMetaAttribute implements MetaCollection {
private String collectionType;
private String collectionType;
public XmlMetaCollection(XmlMetaEntity parent, String propertyName, String type, String collectionType) {
super(parent, propertyName, type);
this.collectionType = collectionType;
}
public XmlMetaCollection(XmlMetaEntity parent, String propertyName, String type, String collectionType) {
super( parent, propertyName, type );
this.collectionType = collectionType;
}
@Override
@Override
public String getMetaType() {
return collectionType;
}
}
}

View File

@ -61,7 +61,7 @@ import org.hibernate.jpamodelgen.xml.jaxb.OneToOne;
*/
public class XmlMetaEntity implements MetaEntity {
static Map<String, String> COLLECTIONS = new HashMap<String, String>();
static final Map<String, String> COLLECTIONS = new HashMap<String, String>();
static {
COLLECTIONS.put( "java.util.Collection", "javax.persistence.metamodel.CollectionAttribute" );
@ -354,6 +354,8 @@ public class XmlMetaEntity implements MetaEntity {
case TYPEVAR: {
return mirror.toString();
}
default: {
}
}
}

View File

@ -45,4 +45,4 @@ public class XmlMetaMap extends XmlMetaCollection {
.append( ";" )
.toString();
}
}
}

View File

@ -23,12 +23,12 @@ import org.hibernate.jpamodelgen.model.MetaSingleAttribute;
*/
public class XmlMetaSingleAttribute extends XmlMetaAttribute implements MetaSingleAttribute {
public XmlMetaSingleAttribute(XmlMetaEntity parent, String propertyName, String type) {
super(parent, propertyName, type);
}
public XmlMetaSingleAttribute(XmlMetaEntity parent, String propertyName, String type) {
super( parent, propertyName, type );
}
@Override
public String getMetaType() {
return "javax.persistence.metamodel.SingularAttribute";
}
public String getMetaType() {
return "javax.persistence.metamodel.SingularAttribute";
}
}

View File

@ -47,4 +47,4 @@ public class StringUtilTest {
public void testHashCodeNotAProperty() {
assertFalse( StringUtil.isPropertyName( "hashCode" ) );
}
}
}

View File

@ -37,4 +37,4 @@ public class Hotel {
public void setWebmaster(User webmaster) {
this.webmaster = webmaster;
}
}
}

View File

@ -37,4 +37,4 @@ public class HotelRoom extends Room {
public void setHotel(Hotel hotel) {
this.hotel = hotel;
}
}
}

View File

@ -23,8 +23,6 @@ import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import org.hibernate.jpamodelgen.test.accesstype.Product;
/**
*
* @author Max Andersen
@ -34,49 +32,49 @@ import org.hibernate.jpamodelgen.test.accesstype.Product;
@Entity
public class Item {
long _id;
long id;
int _quantity;
int quantity;
Product _product;
Product product;
Order _order;
Order order;
Detail detail;
@Id
public long getId() {
return _id;
return id;
}
public void setId(long id) {
this._id = id;
this.id = id;
}
public int getQuantity() {
return _quantity;
return quantity;
}
public void setQuantity(int quantity) {
this._quantity = quantity;
this.quantity = quantity;
}
@ManyToOne
public Product getProduct() {
return _product;
return product;
}
public void setProduct(Product product) {
this._product = product;
this.product = product;
}
@ManyToOne
public Order getOrder() {
return _order;
return order;
}
public void setOrder(Order order) {
this._order = order;
this.order = order;
}
@OneToMany

View File

@ -18,38 +18,33 @@ package org.hibernate.jpamodelgen.test.accesstype;
import java.math.BigDecimal;
import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import org.hibernate.jpamodelgen.test.accesstype.Item;
import org.hibernate.jpamodelgen.test.accesstype.Shop;
/**
*
* @author Max Andersen
* @author Hardy Ferentschik
* @author Emmanuel Bernard
*/
@Entity
@Entity
public class Product {
transient String nonPersistent;
static String nonPersistent2;
@Id
long id;
int test;
int test;
String description;
BigDecimal price;
@ManyToOne
Shop shop;
@OneToMany
Set<Item> items;
}

View File

@ -36,4 +36,4 @@ public class Room {
public void setId(Integer id) {
this.id = id;
}
}
}

View File

@ -20,15 +20,15 @@ import javax.persistence.Entity;
import javax.persistence.Id;
/**
*
* @author Max Andersen
* @author Hardy Ferentschik
* @author Emmanuel Bernard
*/
@Entity
@Entity
public class Shop {
@Id
long id;
String name;
}

View File

@ -46,4 +46,4 @@ public class ArrayTest extends CompilationTest {
protected String getPackageNameOfCurrentTest() {
return Image.class.getPackage().getName();
}
}
}

View File

@ -42,4 +42,4 @@ public class Image {
public void setData(byte[] data) {
this.data = data;
}
}
}

View File

@ -32,4 +32,4 @@ public class TemperatureSamples {
public void setSamples(Integer[] samples) {
this.samples = samples;
}
}
}

View File

@ -40,4 +40,4 @@ public class BlobTest extends CompilationTest {
protected String getPackageNameOfCurrentTest() {
return BlobTest.class.getPackage().getName();
}
}
}

View File

@ -44,4 +44,4 @@ public class Cleaner {
public void setName(String name) {
this.name = name;
}
}
}

View File

@ -81,4 +81,4 @@ public class ElementCollectionTest extends CompilationTest {
ormFiles.add( TestUtil.fcnToPath( ElementCollectionTest.class.getPackage().getName() ) + "/hostel.xml" );
return ormFiles;
}
}
}

View File

@ -46,4 +46,4 @@ public class Hostel {
public void setCleaners(Map cleaners) {
this.cleaners = cleaners;
}
}
}

View File

@ -63,4 +63,4 @@ public class Hotel {
public void setCleaners(Map cleaners) {
this.cleaners = cleaners;
}
}
}

View File

@ -22,6 +22,6 @@ import javax.persistence.MappedSuperclass;
@MappedSuperclass
public class Base {
@Id
protected String uuid;
@Id
protected String uuid;
}

View File

@ -40,4 +40,4 @@ public class EmbeddableAccessTypeTest extends CompilationTest {
protected String getPackageNameOfCurrentTest() {
return EmbeddableAccessTypeTest.class.getPackage().getName();
}
}
}

View File

@ -21,6 +21,6 @@ import javax.persistence.Entity;
@Entity
public class MyEntity extends Base {
@Embedded
private EmbeddableEntity emb;
@Embedded
private EmbeddableEntity emb;
}

View File

@ -5,7 +5,7 @@ import java.io.Serializable;
/**
* @author Hardy Ferentschik
*/
public class AbstractRef implements Serializable {
public abstract class AbstractRef implements Serializable {
private final int id;
protected AbstractRef() {

View File

@ -51,4 +51,4 @@ public class EmbeddedIdWithInheritanceTest extends CompilationTest {
ormFiles.add( dir + "/orm.xml" );
return ormFiles;
}
}
}

View File

@ -65,4 +65,4 @@ public class EmbeddedIdNoInheritanceTest extends CompilationTest {
ormFiles.add( dir + "/orm.xml" );
return ormFiles;
}
}
}

View File

@ -45,4 +45,4 @@ public class GeneratedAnnotationTest extends CompilationTest {
protected String getPackageNameOfCurrentTest() {
return GeneratedAnnotationTest.class.getPackage().getName();
}
}
}

View File

@ -59,4 +59,4 @@ public class GenerationDateTest extends CompilationTest {
protected String getPackageNameOfCurrentTest() {
return GenerationDateTest.class.getPackage().getName();
}
}
}

View File

@ -19,11 +19,10 @@ package org.hibernate.jpamodelgen.test.generatedannotation;
import java.util.HashMap;
import java.util.Map;
import org.testng.annotations.Test;
import org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor;
import org.hibernate.jpamodelgen.test.util.CompilationTest;
import org.hibernate.jpamodelgen.test.util.TestForIssue;
import org.testng.annotations.Test;
import static org.hibernate.jpamodelgen.test.util.TestUtil.assertMetamodelClassGeneratedFor;
import static org.hibernate.jpamodelgen.test.util.TestUtil.getMetaModelSourceAsString;
@ -54,4 +53,4 @@ public class SkipGeneratedAnnotationTest extends CompilationTest {
protected String getPackageNameOfCurrentTest() {
return SkipGeneratedAnnotationTest.class.getPackage().getName();
}
}
}

View File

@ -37,4 +37,4 @@ public class GenericsTest extends CompilationTest {
protected String getPackageNameOfCurrentTest() {
return GenericsTest.class.getPackage().getName();
}
}
}

View File

@ -16,10 +16,9 @@
*/
package org.hibernate.jpamodelgen.test.hashcode;
import org.testng.annotations.Test;
import org.hibernate.jpamodelgen.test.util.CompilationTest;
import org.hibernate.jpamodelgen.test.util.TestForIssue;
import org.testng.annotations.Test;
import static org.hibernate.jpamodelgen.test.util.TestUtil.assertAbsenceOfFieldInMetamodelFor;
import static org.hibernate.jpamodelgen.test.util.TestUtil.assertMetamodelClassGeneratedFor;
@ -43,4 +42,4 @@ public class HashCodeTest extends CompilationTest {
protected String getPackageNameOfCurrentTest() {
return HashCodeTest.class.getPackage().getName();
}
}
}

View File

@ -31,4 +31,4 @@ public abstract class AbstractEntity<T> {
public AbstractEntity() {
}
}
}

View File

@ -55,4 +55,4 @@ public class Area {
public void setHeight(int height) {
this.height = height;
}
}
}

View File

@ -34,4 +34,4 @@ public class Building extends Area {
}
private Date builtIn;
}
}

View File

@ -23,4 +23,4 @@ import javax.persistence.Entity;
*/
@Entity
public class Customer extends User {
}
}

View File

@ -34,4 +34,4 @@ public class House extends Building {
public void setId(Long id) {
this.id = id;
}
}
}

View File

@ -59,3 +59,4 @@ public class InheritanceTest extends CompilationTest {
return InheritanceTest.class.getPackage().getName();
}
}

View File

@ -36,4 +36,4 @@ public class Person extends AbstractEntity<String> {
public void setName(String name) {
this.name = name;
}
}
}

View File

@ -54,4 +54,4 @@ public class User {
public void setName(String name) {
this.name = name;
}
}
}

View File

@ -25,7 +25,7 @@ import javax.persistence.MappedSuperclass;
@Embeddable
@MappedSuperclass
public class EmbeddableAndMappedSuperClass {
}

View File

@ -40,4 +40,4 @@ public class EmbeddableMappedSuperClassTest extends CompilationTest {
protected String getPackageNameOfCurrentTest() {
return EmbeddableMappedSuperClassTest.class.getPackage().getName();
}
}
}

View File

@ -37,4 +37,4 @@ public class TypesMappedSuperclassTest extends CompilationTest {
protected String getPackageNameOfCurrentTest() {
return TypesMappedSuperclassTest.class.getPackage().getName();
}
}
}

View File

@ -39,3 +39,4 @@ public class Car extends Vehicle {
}

View File

@ -24,7 +24,8 @@ import javax.persistence.Embeddable;
@Embeddable
public class Coordinates {
public float longitude;
public float latitude;
public float latitude;
}

View File

@ -107,4 +107,4 @@ public class MixedConfigurationTest extends CompilationTest {
ormFiles.add( dir + "/coordinates.xml" );
return ormFiles;
}
}
}

View File

@ -45,4 +45,4 @@ public class Person {
public void setName(String name) {
this.name = name;
}
}
}

View File

@ -67,4 +67,4 @@ public class RentalCar extends Car {
enum CURRENTLY_HIRED {
YES, NO
}
}
}

View File

@ -46,4 +46,4 @@ public class RentalCompany {
public void setName(String name) {
this.name = name;
}
}
}

View File

@ -37,4 +37,4 @@ public class Truck extends Vehicle {
public void setMake(String make) {
this.make = make;
}
}
}

View File

@ -49,4 +49,4 @@ public class XmlMetaCompleteTest extends CompilationTest {
ormFiles.add( TestUtil.fcnToPath( XmlMetaCompleteTest.class.getPackage().getName() ) + "/orm.xml" );
return ormFiles;
}
}
}

View File

@ -37,4 +37,4 @@ public class ZeroCoordinates {
public void setLongitude(float longitude) {
}
}
}

View File

@ -75,4 +75,4 @@ public class DeskWithRawType implements java.io.Serializable {
public void setEmployees(Collection employees) {
this.employees = employees;
}
}
}

View File

@ -67,3 +67,4 @@ public class EmployeeWithRawType implements java.io.Serializable {
this.desks = desks;
}
}

View File

@ -37,4 +37,4 @@ public class RawTypesTest extends CompilationTest {
protected String getPackageNameOfCurrentTest() {
return DeskWithRawType.class.getPackage().getName();
}
}
}

View File

@ -42,4 +42,4 @@ public class SortedCollectionTest extends CompilationTest {
protected String getPackageNameOfCurrentTest() {
return SortedCollectionTest.class.getPackage().getName();
}
}
}

View File

@ -60,4 +60,4 @@ public class SuppressWarningsAnnotationGeneratedTest extends CompilationTest {
protected String getPackageNameOfCurrentTest() {
return SuppressWarningsAnnotationGeneratedTest.class.getPackage().getName();
}
}
}

View File

@ -47,4 +47,4 @@ public class SuppressWarningsAnnotationNotGeneratedTest extends CompilationTest
protected String getPackageNameOfCurrentTest() {
return SuppressWarningsAnnotationNotGeneratedTest.class.getPackage().getName();
}
}
}

View File

@ -49,4 +49,4 @@ public class TargetAnnotationTest extends CompilationTest {
protected String getPackageNameOfCurrentTest() {
return TargetAnnotationTest.class.getPackage().getName();
}
}
}

View File

@ -41,4 +41,4 @@ public class UserTypeTest extends CompilationTest {
protected String getPackageNameOfCurrentTest() {
return UserTypeTest.class.getPackage().getName();
}
}
}

View File

@ -49,8 +49,8 @@ public abstract class CompilationTest {
private static final String ANNOTATION_PROCESSOR_OPTION_PREFIX = "-A";
private static final String SOURCE_BASE_DIR_PROPERTY = "sourceBaseDir";
private static final String OUT_BASE_DIR_PROPERTY = "outBaseDir";
private static final String sourceBaseDir;
private static final String outBaseDir;
private static final String SOURCE_BASE_DIR;
private static final String OUT_BASE_DIR;
public static final String DIRECTORY_SEPARATOR = File.separator;
@ -61,13 +61,13 @@ public abstract class CompilationTest {
if ( tmp == null ) {
fail( "The system property sourceBaseDir has to be set and point to the base directory of the test java sources." );
}
sourceBaseDir = tmp;
SOURCE_BASE_DIR = tmp;
tmp = System.getProperty( OUT_BASE_DIR_PROPERTY );
if ( tmp == null ) {
fail( "The system property outBaseDir has to be set and point to the base directory of the test output directory." );
}
outBaseDir = tmp;
OUT_BASE_DIR = tmp;
}
public CompilationTest() {
@ -79,14 +79,14 @@ public abstract class CompilationTest {
}
public static String getSourceBaseDir() {
return sourceBaseDir;
return SOURCE_BASE_DIR;
}
@BeforeClass
protected void compileAllTestEntities() throws Exception {
List<File> sourceFiles = getCompilationUnits( sourceBaseDir, getPackageNameOfCurrentTest() );
List<File> sourceFiles = getCompilationUnits( SOURCE_BASE_DIR, getPackageNameOfCurrentTest() );
// make sure there are no relics from previous runs
TestUtil.deleteGeneratedSourceFiles( new File( outBaseDir ) );
TestUtil.deleteGeneratedSourceFiles( new File( OUT_BASE_DIR ) );
compile( sourceFiles );
}
@ -134,7 +134,7 @@ public abstract class CompilationTest {
return javaFiles;
}
abstract protected String getPackageNameOfCurrentTest();
protected abstract String getPackageNameOfCurrentTest();
protected Map<String, String> getProcessorOptions() {
return Collections.emptyMap();
@ -157,7 +157,7 @@ public abstract class CompilationTest {
private List<String> createJavaOptions() {
List<String> options = new ArrayList<String>();
options.add( "-d" );
options.add( outBaseDir );
options.add( OUT_BASE_DIR );
// pass orm files if specified
if ( !getOrmFiles().isEmpty() ) {

View File

@ -46,14 +46,14 @@ public class TestUtil {
private static final String PATH_SEPARATOR = System.getProperty( "file.separator" );
private static final String PACKAGE_SEPARATOR = ".";
private static final String META_MODEL_CLASS_POSTFIX = "_";
private static final String outBaseDir;
private static final String OUT_BASE_DIR;
static {
String tmp = System.getProperty( "outBaseDir" );
if ( tmp == null ) {
fail( "The system property outBaseDir has to be set and point to the base directory of the test output directory." );
}
outBaseDir = tmp;
OUT_BASE_DIR = tmp;
}
private TestUtil() {
@ -112,7 +112,7 @@ public class TestUtil {
// generate the file name
String fileName = metaModelClassName.replace( PACKAGE_SEPARATOR, PATH_SEPARATOR );
fileName = fileName.concat( ".java" );
return new File( outBaseDir + PATH_SEPARATOR + fileName );
return new File( OUT_BASE_DIR + PATH_SEPARATOR + fileName );
}
public static String getMetaModelSourceAsString(Class<?> clazz) {
@ -122,7 +122,7 @@ public class TestUtil {
try {
BufferedReader input = new BufferedReader( new FileReader( sourceFile ) );
try {
String line = null; //not declared within while loop
String line = null;
/*
* readLine is a bit quirky :
* it returns the content of a line MINUS the newline.
@ -281,7 +281,7 @@ public class TestUtil {
}
else {
fail( "Unexpected component type" );
return null; // making the compiler happy
return null;
}
}

View File

@ -30,3 +30,4 @@ public abstract class BusinessEntity<T extends Serializable> implements Serializ
}

View File

@ -70,4 +70,4 @@ public class EmbeddableConfiguredInXmlTest extends CompilationTest {
ormFiles.add( packageName + "/orm.xml" );
return ormFiles;
}
}
}

View File

@ -47,4 +47,4 @@ public class Address {
public void setCountry(String country) {
this.country = country;
}
}
}

View File

@ -16,8 +16,8 @@
*/
package org.hibernate.jpamodelgen.test.xmlmapped;
import org.hibernate.jpamodelgen.test.accesstype.*;
import org.hibernate.jpamodelgen.test.accesstype.Address;
import org.hibernate.jpamodelgen.test.accesstype.Area;
/**
* @author Hardy Ferentschik
@ -32,4 +32,4 @@ public class Building extends Area {
public void setAddress(org.hibernate.jpamodelgen.test.accesstype.Address address) {
this.address = address;
}
}
}

View File

@ -20,4 +20,4 @@ package org.hibernate.jpamodelgen.test.xmlmapped;
* @author Hardy Ferentschik
*/
public class FakeHero {
}
}

View File

@ -30,7 +30,8 @@ import static org.hibernate.jpamodelgen.test.util.TestUtil.assertMetamodelClassG
/**
* @author Hardy Ferentschik
*/
public class IgnoreInvalidXmlTest extends CompilationTest {
public class
IgnoreInvalidXmlTest extends CompilationTest {
@Test
public void testInvalidXmlFilesGetIgnored() {
// this is only a indirect test, but if the invalid xml files would cause the processor to abort the
@ -53,4 +54,4 @@ public class IgnoreInvalidXmlTest extends CompilationTest {
ormFiles.add( packageName + "/non-existend-class.xml" );
return ormFiles;
}
}
}

View File

@ -33,4 +33,4 @@ public class LivingBeing {
public int nonPersistent() {
return 0;
}
}
}

View File

@ -38,4 +38,4 @@ public class Mammal extends LivingBeing {
public void setSubclass(String subclass) {
this.subclass = subclass;
}
}
}

View File

@ -109,4 +109,4 @@ public class XmlMappingTest extends CompilationTest {
);
return properties;
}
}
}

View File

@ -57,3 +57,4 @@ public class XmlMetaDataCompleteMultiplePersistenceUnitsTest extends Compilation
return properties;
}
}

Some files were not shown because too many files have changed in this diff Show More