diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundProperty.java b/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundProperty.java index c572bc5f8..86dd0a8b7 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundProperty.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundProperty.java @@ -5,78 +5,76 @@ import com.avaje.ebean.config.CompoundTypeProperty; /** * Wraps a CompoundTypeProperty with it's type and parent for nested compound * types. - * - * @author rbygrave */ public class CtCompoundProperty { - private final String relativeName; + private final String relativeName; - private final CtCompoundProperty parent; + private final CtCompoundProperty parent; - private final CtCompoundType> compoundType; + private final CtCompoundType> compoundType; - @SuppressWarnings({ "rawtypes" }) - private final CompoundTypeProperty property; + @SuppressWarnings({"rawtypes"}) + private final CompoundTypeProperty property; - public CtCompoundProperty(String relativeName, CtCompoundProperty parent, CtCompoundType> ctType, - CompoundTypeProperty, ?> property) { + public CtCompoundProperty(String relativeName, CtCompoundProperty parent, CtCompoundType> ctType, + CompoundTypeProperty, ?> property) { - this.relativeName = relativeName; - this.parent = parent; - this.compoundType = ctType; - this.property = property; + this.relativeName = relativeName; + this.parent = parent; + this.compoundType = ctType; + this.property = property; + } + + /** + * The property name relative to the root of the compound type. + */ + public String getRelativeName() { + return relativeName; + } + + /** + * The property name local to its type. + */ + public String getPropertyName() { + return property.getName(); + } + + public String toString() { + return relativeName; + } + + @SuppressWarnings("unchecked") + public Object getValue(Object valueObject) { + if (valueObject == null) { + return null; } - - /** - * The property name relative to the root of the compound type. - */ - public String getRelativeName() { - return relativeName; + if (parent != null) { + valueObject = parent.getValue(valueObject); } + return property.getValue(valueObject); + } - /** - * The property name local to its type. - */ - public String getPropertyName() { - return property.getName(); - } + /** + * Set a scalar value that is used to build the immutable compound value + * object. + *
+ * When all the scalar values have been collected then the compound value + * object is built and this can be recursive for nested compound types. + *
+ */ + public Object setValue(Object bean, Object value) { - public String toString() { - return relativeName; - } + // compoundType and propertyName should be correct depth + Object compoundValue = ImmutableCompoundTypeBuilder.set(compoundType, property.getName(), value); - @SuppressWarnings("unchecked") - public Object getValue(Object valueObject) { - if (valueObject == null) { - return null; - } - if (parent != null) { - valueObject = parent.getValue(valueObject); - } - return property.getValue(valueObject); - } + if (compoundValue != null && parent != null) { + // Continue up the tree + return parent.setValue(bean, compoundValue); - /** - * Set a scalar value that is used to build the immutable compound value - * object. - *- * When all the scalar values have been collected then the compound value - * object is built and this can be recursive for nested compound types. - *
- */ - public Object setValue(Object bean, Object value) { - - // compoundType and propertyName should be correct depth - Object compoundValue = ImmutableCompoundTypeBuilder.set(compoundType, property.getName(), value); - - if (compoundValue != null && parent != null) { - // Continue up the tree - return parent.setValue(bean, compoundValue); - - } else { - return compoundValue; - } + } else { + return compoundValue; } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundType.java b/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundType.java index 356d976c4..25c04ba21 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundType.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundType.java @@ -1,214 +1,193 @@ package com.avaje.ebeaninternal.server.type; -import java.io.IOException; -import java.sql.SQLException; -import java.util.LinkedHashMap; -import java.util.Map; - import com.avaje.ebean.config.CompoundType; import com.avaje.ebean.config.CompoundTypeProperty; import com.avaje.ebeaninternal.server.text.json.WriteJson; +import java.io.IOException; +import java.sql.SQLException; +import java.util.Map; + /** * The internal representation of a Compound Type (Immutable Compound Value Object). - * - * @param