HHH-6216 Formatting and removing of obsolete imports and class

This commit is contained in:
Hardy Ferentschik 2011-07-25 14:56:49 +02:00
parent bfa4734521
commit ae8a29bdb2
9 changed files with 126 additions and 158 deletions

View File

@ -23,8 +23,6 @@
*/
package org.hibernate.metamodel.relational;
import java.util.concurrent.atomic.AtomicInteger;
import org.hibernate.dialect.Dialect;
import org.hibernate.internal.util.StringHelper;
@ -41,7 +39,7 @@ public class UniqueKey extends AbstractConstraint implements Constraint {
@Override
public String getExportIdentifier() {
StringBuilder sb = new StringBuilder( getTable().getLoggableValueQualifier());
StringBuilder sb = new StringBuilder( getTable().getLoggableValueQualifier() );
sb.append( ".UK" );
for ( Column column : getColumns() ) {
sb.append( '_' ).append( column.getColumnName().getName() );
@ -71,15 +69,15 @@ public class UniqueKey extends AbstractConstraint implements Constraint {
first = false;
}
else {
buf.append(", ");
buf.append( ", " );
}
if ( ! hadNullableColumn && column.isNullable() ) {
if ( !hadNullableColumn && column.isNullable() ) {
hadNullableColumn = true;
}
buf.append( column.getColumnName().encloseInQuotesIfQuoted( dialect ) );
}
//do not add unique constraint on DB not supporting unique and nullable columns
return ! hadNullableColumn || dialect.supportsNotNullUnique() ?
return !hadNullableColumn || dialect.supportsNotNullUnique() ?
buf.append( ')' ).toString() :
null;
}
@ -95,14 +93,14 @@ public class UniqueKey extends AbstractConstraint implements Constraint {
first = false;
}
else {
buf.append(", ");
buf.append( ", " );
}
if ( ! nullable && column.isNullable() ) {
if ( !nullable && column.isNullable() ) {
nullable = true;
}
buf.append( column.getColumnName().encloseInQuotesIfQuoted( dialect ) );
}
return ! nullable || dialect.supportsNotNullUnique() ?
return !nullable || dialect.supportsNotNullUnique() ?
StringHelper.replace( buf.append( ')' ).toString(), "primary key", "unique" ) :
//TODO: improve this hack!
null;

View File

@ -1,133 +0,0 @@
/*
* 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.relational.state;
import org.hibernate.MappingException;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.metamodel.relational.Column;
import org.hibernate.metamodel.relational.DerivedValue;
import org.hibernate.metamodel.relational.SimpleValue;
import org.hibernate.metamodel.relational.TableSpecification;
import org.hibernate.metamodel.relational.Tuple;
import org.hibernate.metamodel.relational.Value;
/**
* @author Gail Badner
*/
public class ValueCreator {
public static Column createColumn(
TableSpecification table,
String attributeName,
ColumnRelationalState state,
boolean forceNonNullable,
boolean forceUnique) {
final String explicitName = state.getExplicitColumnName();
final String logicalColumnName = state.getNamingStrategy().logicalColumnName( explicitName, attributeName );
String columnName =
explicitName == null ?
state.getNamingStrategy().propertyToColumnName( attributeName ) :
state.getNamingStrategy().columnName( explicitName );
// todo : find out the purpose of these logical bindings
// mappings.addColumnBinding( logicalColumnName, column, table );
if ( columnName == null ) {
throw new IllegalArgumentException( "columnName must be non-null." );
}
if ( state.isGloballyQuotedIdentifiers() ) {
columnName = StringHelper.quote( columnName );
}
Column value = table.locateOrCreateColumn( columnName );
value.initialize( state, forceNonNullable, forceUnique );
return value;
}
public static DerivedValue createDerivedValue(
TableSpecification table,
DerivedValueRelationalState state) {
return table.locateOrCreateDerivedValue( state.getFormula() );
}
public static SimpleValue createSimpleValue(
TableSpecification table,
String attributeName,
SimpleValueRelationalState state,
boolean forceNonNullable,
boolean forceUnique) {
if ( state instanceof ColumnRelationalState ) {
ColumnRelationalState columnRelationalState = ColumnRelationalState.class.cast( state );
return createColumn( table, attributeName, columnRelationalState, forceNonNullable, forceUnique );
}
else if ( state instanceof DerivedValueRelationalState ) {
return createDerivedValue( table, DerivedValueRelationalState.class.cast( state ) );
}
else {
throw new MappingException( "unknown relational state:" + state.getClass().getName() );
}
}
public static Tuple createTuple(
TableSpecification table,
String attributeName,
TupleRelationalState state,
boolean forceNonNullable,
boolean forceUnique) {
Tuple tuple = table.createTuple( "[" + attributeName + "]" );
for ( SimpleValueRelationalState valueState : state.getRelationalStates() ) {
tuple.addValue( createSimpleValue( table, attributeName, valueState, forceNonNullable, forceUnique ) );
}
return tuple;
}
public static Value createValue(
TableSpecification table,
String attributeName,
ValueRelationalState state,
boolean forceNonNullable,
boolean forceUnique) {
Value value = null;
if ( SimpleValueRelationalState.class.isInstance( state ) ) {
value = createSimpleValue(
table,
attributeName,
SimpleValueRelationalState.class.cast( state ),
forceNonNullable,
forceUnique
);
}
else if ( TupleRelationalState.class.isInstance( state ) ) {
value = createTuple(
table,
attributeName,
TupleRelationalState.class.cast( state ),
forceNonNullable,
forceUnique
);
}
else {
throw new MappingException( "Unexpected type of RelationalState" + state.getClass().getName() );
}
return value;
}
}

View File

@ -28,7 +28,7 @@ import org.jboss.jandex.DotName;
import org.hibernate.metamodel.source.annotations.JPADotNames;
/**
* An enum defining the type of mapped attribute.
* An enum defining the type of a mapped attribute.
*
* @author Hardy Ferentschik
*/

View File

@ -41,12 +41,11 @@ import org.hibernate.metamodel.source.annotations.JPADotNames;
import org.hibernate.metamodel.source.annotations.JandexHelper;
/**
* Represent a mapped attribute (explicitly or implicitly mapped). Also used for synthetic attributes like a
* discriminator column.
* Represent a mapped attribute (explicitly or implicitly mapped).
*
* @author Hardy Ferentschik
*/
public class SimpleAttribute extends MappedAttribute {
public class BasicAttribute extends MappedAttribute {
/**
* Is this property an id property (or part thereof).
*/
@ -89,11 +88,11 @@ public class SimpleAttribute extends MappedAttribute {
private final String customReadFragment;
private final String checkCondition;
public static SimpleAttribute createSimpleAttribute(String name, Class<?> attributeType, Map<DotName, List<AnnotationInstance>> annotations, String accessType) {
return new SimpleAttribute( name, attributeType, accessType, annotations );
public static BasicAttribute createSimpleAttribute(String name, Class<?> attributeType, Map<DotName, List<AnnotationInstance>> annotations, String accessType) {
return new BasicAttribute( name, attributeType, accessType, annotations );
}
SimpleAttribute(String name, Class<?> attributeType, String accessType, Map<DotName, List<AnnotationInstance>> annotations) {
BasicAttribute(String name, Class<?> attributeType, String accessType, Map<DotName, List<AnnotationInstance>> annotations) {
super( name, attributeType, accessType, annotations );
AnnotationInstance idAnnotation = JandexHelper.getSingleAnnotation( annotations, JPADotNames.ID );

View File

@ -0,0 +1,62 @@
/*
* 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.binder;
/**
* Contract describing source of table information
*
* @author Steve Ebersole
*/
public interface ConstraintSource {
/**
* Obtain the supplied schema name
*
* @return The schema name. If {@code null}, the binder will apply the default.
*/
public String getExplicitSchemaName();
/**
* Obtain the supplied catalog name
*
* @return The catalog name. If {@code null}, the binder will apply the default.
*/
public String getExplicitCatalogName();
/**
* Obtain the supplied table name.
*
* @return The table name.
*/
public String getExplicitTableName();
/**
* Obtain the logical name of the table. This value is used to uniquely reference the table when binding
* values to the binding model.
*
* @return The logical name. Can be {@code null} in the case of the "primary table".
*
* @see org.hibernate.metamodel.source.binder.RelationalValueSource#getContainingTableName()
*/
public String getLogicalName();
}

View File

@ -28,6 +28,6 @@ package org.hibernate.metamodel.source.binder;
*/
public interface PluralAttributeSource extends AttributeSource {
public PluralAttributeNature getPluralAttributeNature();
public PluralAttributeElementNature getPluralAttributeElementNature();
public PluralAttributeElementNature getPluralAttributeElementNature();
}

View File

@ -27,15 +27,12 @@ package org.hibernate.metamodel.source.binder;
* Unifying interface for {@link ColumnSource} and {@link DerivedValueSource}.
*
* @author Steve Ebersole
*
* @see ColumnSource
* @see DerivedValueSource
*/
public interface RelationalValueSource {
/**
* Obtain the name of the table that contains this value.
*
* @return
* @return returns the name of the table that contains this value.
*/
public String getContainingTableName();
}

View File

@ -32,14 +32,14 @@ public interface TableSource {
/**
* Obtain the supplied schema name
*
* @return The schema name. If {@code null}, the binder will apply the default.
* @return The schema name. If {@code null}, the binder will apply the default.
*/
public String getExplicitSchemaName();
/**
* Obtain the supplied catalog name
*
* @return The catalog name. If {@code null}, the binder will apply the default.
* @return The catalog name. If {@code null}, the binder will apply the default.
*/
public String getExplicitCatalogName();
@ -54,7 +54,7 @@ public interface TableSource {
* Obtain the logical name of the table. This value is used to uniquely reference the table when binding
* values to the binding model.
*
* @return The logical name. Can be {@code null} in the case of the "primary table".
* @return The logical name. Can be {@code null} in the case of the "primary table".
*
* @see RelationalValueSource#getContainingTableName()
*/

View File

@ -0,0 +1,45 @@
/*
* 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.binder;
/**
* Contract describing source of table constraints
*
* @author Hardy Ferentschik
*/
public interface UniqueConstraintSource {
/**
* @return returns the name of the constraint or {@code null} in case a generated name should be used
*/
public String name();
/**
* Obtain the logical name of the table for this constraint.
*
* @return The logical table name. Can be {@code null} in the case of the "primary table".
*
*/
public String getTableName();
}