From d86ce7e68ae2ffc27bd7ea769dfb080eb10bef35 Mon Sep 17 00:00:00 2001 From: Hardy Ferentschik Date: Fri, 24 Jun 2011 16:48:10 +0200 Subject: [PATCH] HHH-6173 formatting --- .../hibernate/engine/spi/CascadeStyle.java | 80 +++++++++++++------ .../metamodel/binding/EntityBinding.java | 9 ++- .../metamodel/domain/AttributeContainer.java | 5 ++ 3 files changed, 65 insertions(+), 29 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/CascadeStyle.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/CascadeStyle.java index 4cd5554d91..bbcdcf487b 100755 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/CascadeStyle.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/CascadeStyle.java @@ -33,9 +33,8 @@ import org.hibernate.internal.util.collections.ArrayHelper; /** * A contract for defining the aspects of cascading various persistence actions. * - * @see CascadingAction - * * @author Gavin King + * @see CascadingAction */ public abstract class CascadeStyle implements Serializable { @@ -43,6 +42,7 @@ public abstract class CascadeStyle implements Serializable { * For this style, should the given action be cascaded? * * @param action The action to be checked for cascade-ability. + * * @return True if the action should be cascaded under this style; false otherwise. */ public abstract boolean doCascade(CascadingAction action); @@ -57,18 +57,19 @@ public abstract class CascadeStyle implements Serializable { * control this seperately. * * @param action The action to be checked for cascade-ability. + * * @return True if the action should be really cascaded under this style; - * false otherwise. + * false otherwise. */ public boolean reallyDoCascade(CascadingAction action) { - return doCascade(action); + return doCascade( action ); } /** * Do we need to delete orphaned collection elements? * * @return True if this style need to account for orphan delete - * operations; false othwerwise. + * operations; false othwerwise. */ public boolean hasOrphanDelete() { return false; @@ -76,27 +77,38 @@ public abstract class CascadeStyle implements Serializable { public static final class MultipleCascadeStyle extends CascadeStyle { private final CascadeStyle[] styles; + public MultipleCascadeStyle(CascadeStyle[] styles) { this.styles = styles; } + public boolean doCascade(CascadingAction action) { - for (int i=0; i STYLES = new HashMap(); static { STYLES.put( "all", ALL ); @@ -280,12 +307,13 @@ public abstract class CascadeStyle implements Serializable { * Factory method for obtaining named cascade styles * * @param cascade The named cascade style name. + * * @return The appropriate CascadeStyle */ public static CascadeStyle getCascadeStyle(String cascade) { - CascadeStyle style = (CascadeStyle) STYLES.get(cascade); - if (style==null) { - throw new MappingException("Unsupported cascade style: " + cascade); + CascadeStyle style = STYLES.get( cascade ); + if ( style == null ) { + throw new MappingException( "Unsupported cascade style: " + cascade ); } else { return style; diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/binding/EntityBinding.java b/hibernate-core/src/main/java/org/hibernate/metamodel/binding/EntityBinding.java index 3e0f001b36..eff727850c 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/binding/EntityBinding.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/binding/EntityBinding.java @@ -40,7 +40,6 @@ import org.hibernate.metamodel.relational.TableSpecification; import org.hibernate.metamodel.source.spi.BindingContext; import org.hibernate.metamodel.source.spi.MetaAttributeContext; import org.hibernate.persister.entity.EntityPersister; -import org.hibernate.service.classloading.spi.ClassLoaderService; import org.hibernate.tuple.entity.EntityTuplizer; /** @@ -100,7 +99,11 @@ public class EntityBinding { public EntityBinding initialize(BindingContext bindingContext, EntityBindingState state) { // todo : Entity will need both entityName and className to be effective - this.entity = new Entity( state.getEntityName(), state.getSuperType(), bindingContext.makeJavaType( state.getClassName() ) ); + this.entity = new Entity( + state.getEntityName(), + state.getSuperType(), + bindingContext.makeJavaType( state.getClassName() ) + ); this.isRoot = state.isRoot(); this.entityInheritanceType = state.getEntityInheritanceType(); @@ -242,7 +245,7 @@ public class EntityBinding { // TODO: fix this after HHH-6337 and HHH-6360 are fixed. for now, just return the identifier binding // if this is not a root, then need to include the superclass attribute bindings //return getAttributeBindings(); - Set set = Collections.singleton( ( AttributeBinding ) entityIdentifier.getValueBinding() ); + Set set = Collections.singleton( (AttributeBinding) entityIdentifier.getValueBinding() ); return set; } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/domain/AttributeContainer.java b/hibernate-core/src/main/java/org/hibernate/metamodel/domain/AttributeContainer.java index b2e9cedc1d..2500eb6337 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/domain/AttributeContainer.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/domain/AttributeContainer.java @@ -40,10 +40,15 @@ public interface AttributeContainer extends Type { public Set getAttributes(); public SingularAttribute getOrCreateSingularAttribute(String name); + public PluralAttribute getOrCreatePluralAttribute(String name, PluralAttributeNature nature); + public PluralAttribute getOrCreateBag(String name); + public PluralAttribute getOrCreateSet(String name); + public IndexedPluralAttribute getOrCreateList(String name); + public IndexedPluralAttribute getOrCreateMap(String name); /**