Repository: incubator-juneau Updated Branches: refs/heads/master 1ebd4abf5 -> b3521f770
Remove generics from BeanPropertyMeta class. Project: http://git-wip-us.apache.org/repos/asf/incubator-juneau/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-juneau/commit/b095bd88 Tree: http://git-wip-us.apache.org/repos/asf/incubator-juneau/tree/b095bd88 Diff: http://git-wip-us.apache.org/repos/asf/incubator-juneau/diff/b095bd88 Branch: refs/heads/master Commit: b095bd88340366e48b4e0b991da2a7c312a2cdee Parents: 1ebd4ab Author: jamesbognar <[email protected]> Authored: Thu Aug 25 11:38:55 2016 -0400 Committer: jamesbognar <[email protected]> Committed: Thu Aug 25 11:38:55 2016 -0400 ---------------------------------------------------------------------- .../main/java/org/apache/juneau/BeanMap.java | 33 +++++---- .../java/org/apache/juneau/BeanMapEntry.java | 14 ++-- .../main/java/org/apache/juneau/BeanMeta.java | 70 ++++++++++---------- .../org/apache/juneau/BeanMetaFiltered.java | 6 +- .../org/apache/juneau/BeanPropertyMeta.java | 41 ++++++------ .../org/apache/juneau/BeanPropertyValue.java | 6 +- .../org/apache/juneau/BeanRuntimeException.java | 10 +++ 7 files changed, 96 insertions(+), 84 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b095bd88/juneau-core/src/main/java/org/apache/juneau/BeanMap.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/BeanMap.java b/juneau-core/src/main/java/org/apache/juneau/BeanMap.java index 28bee46..6150526 100644 --- a/juneau-core/src/main/java/org/apache/juneau/BeanMap.java +++ b/juneau-core/src/main/java/org/apache/juneau/BeanMap.java @@ -106,7 +106,7 @@ public class BeanMap<T> extends AbstractMap<String,Object> implements Delegate<T for (Map.Entry<String,List<?>> e : arrayPropertyCache.entrySet()) { String key = e.getKey(); List<?> value = e.getValue(); - BeanPropertyMeta<T> bpm = getPropertyMeta(key); + BeanPropertyMeta bpm = getPropertyMeta(key); try { bpm.setArray(b, value); } catch (Exception e1) { @@ -217,7 +217,7 @@ public class BeanMap<T> extends AbstractMap<String,Object> implements Delegate<T */ @Override /* Map */ public Object put(String property, Object value) { - BeanPropertyMeta<T> p = meta.properties.get(property); + BeanPropertyMeta p = meta.properties.get(property); if (p == null) { if (meta.ctx.ignoreUnknownBeanProperties) return null; @@ -251,7 +251,7 @@ public class BeanMap<T> extends AbstractMap<String,Object> implements Delegate<T * @param value The value to add to the collection or array. */ public void add(String property, Object value) { - BeanPropertyMeta<T> p = meta.properties.get(property); + BeanPropertyMeta p = meta.properties.get(property); if (p == null) { if (meta.ctx.ignoreUnknownBeanProperties) return; @@ -301,7 +301,7 @@ public class BeanMap<T> extends AbstractMap<String,Object> implements Delegate<T */ @Override /* Map */ public Object get(Object property) { - BeanPropertyMeta<T> p = meta.properties.get(property); + BeanPropertyMeta p = meta.properties.get(property); if (p == null) return null; if (meta.transform != null && property != null) @@ -385,11 +385,11 @@ public class BeanMap<T> extends AbstractMap<String,Object> implements Delegate<T * @param propertyName The name of the property to look up. * @return The bean property, or null if the bean has no such property. */ - public BeanMapEntry<T> getProperty(String propertyName) { - BeanPropertyMeta<T> p = meta.properties.get(propertyName); + public BeanMapEntry getProperty(String propertyName) { + BeanPropertyMeta p = meta.properties.get(propertyName); if (p == null) return null; - return new BeanMapEntry<T>(this, p); + return new BeanMapEntry(this, p); } /** @@ -398,7 +398,7 @@ public class BeanMap<T> extends AbstractMap<String,Object> implements Delegate<T * @param propertyName The name of the bean property. * @return Metadata on the specified property, or <jk>null</jk> if that property does not exist. */ - public BeanPropertyMeta<T> getPropertyMeta(String propertyName) { + public BeanPropertyMeta getPropertyMeta(String propertyName) { return meta.properties.get(propertyName); } @@ -422,12 +422,12 @@ public class BeanMap<T> extends AbstractMap<String,Object> implements Delegate<T * @return The list of all bean property values. */ public List<BeanPropertyValue> getValues(final boolean addClassAttr, final boolean ignoreNulls) { - Collection<BeanPropertyMeta<T>> properties = getProperties(); + Collection<BeanPropertyMeta> properties = getProperties(); int capacity = (ignoreNulls && properties.size() > 10) ? 10 : properties.size() + (addClassAttr ? 1 : 0); List<BeanPropertyValue> l = new ArrayList<BeanPropertyValue>(capacity); if (addClassAttr) l.add(new BeanPropertyValue(meta.getClassProperty(), meta.c.getName(), null)); - for (BeanPropertyMeta<T> bpm : properties) { + for (BeanPropertyMeta bpm : properties) { try { Object val = bpm.get(this); if (val != null || ! ignoreNulls) @@ -446,7 +446,7 @@ public class BeanMap<T> extends AbstractMap<String,Object> implements Delegate<T * Returns a simple collection of properties for this bean map. * @return A simple collection of properties for this bean map. */ - protected Collection<BeanPropertyMeta<T>> getProperties() { + protected Collection<BeanPropertyMeta> getProperties() { return meta.properties.values(); } @@ -464,7 +464,7 @@ public class BeanMap<T> extends AbstractMap<String,Object> implements Delegate<T // Note that the HashMap.values() method caches results, so this collection // will really only be constructed once per bean type since the underlying // map never changes. - final Collection<BeanPropertyMeta<T>> pSet = getProperties(); + final Collection<BeanPropertyMeta> pSet = getProperties(); @Override /* Set */ public Iterator<java.util.Map.Entry<String, Object>> iterator() { @@ -474,7 +474,7 @@ public class BeanMap<T> extends AbstractMap<String,Object> implements Delegate<T // collection objects. return new Iterator<Entry<String,Object>>() { - final Iterator<BeanPropertyMeta<T>> pIterator = pSet.iterator(); + final Iterator<BeanPropertyMeta> pIterator = pSet.iterator(); @Override /* Iterator */ public boolean hasNext() { @@ -483,7 +483,7 @@ public class BeanMap<T> extends AbstractMap<String,Object> implements Delegate<T @Override /* Iterator */ public Map.Entry<String, Object> next() { - return new BeanMapEntry<T>(BeanMap.this, pIterator.next()); + return new BeanMapEntry(BeanMap.this, pIterator.next()); } @Override /* Iterator */ @@ -501,4 +501,9 @@ public class BeanMap<T> extends AbstractMap<String,Object> implements Delegate<T return s; } + + @SuppressWarnings("unchecked") + void setBean(Object bean) { + this.bean = (T)bean; + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b095bd88/juneau-core/src/main/java/org/apache/juneau/BeanMapEntry.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/BeanMapEntry.java b/juneau-core/src/main/java/org/apache/juneau/BeanMapEntry.java index 34aad38..7e6910d 100644 --- a/juneau-core/src/main/java/org/apache/juneau/BeanMapEntry.java +++ b/juneau-core/src/main/java/org/apache/juneau/BeanMapEntry.java @@ -41,12 +41,10 @@ import org.apache.juneau.transform.*; * </p> * * @author James Bognar ([email protected]) - * - * @param <T> The bean type. */ -public class BeanMapEntry<T> implements Map.Entry<String,Object> { - private final BeanMap<T> beanMap; - private final BeanPropertyMeta<T> meta; +public class BeanMapEntry implements Map.Entry<String,Object> { + private final BeanMap<?> beanMap; + private final BeanPropertyMeta meta; /** * Constructor. @@ -54,7 +52,7 @@ public class BeanMapEntry<T> implements Map.Entry<String,Object> { * @param beanMap The bean map that this entry belongs to. * @param property The bean property. */ - protected BeanMapEntry(BeanMap<T> beanMap, BeanPropertyMeta<T> property) { + protected BeanMapEntry(BeanMap<?> beanMap, BeanPropertyMeta property) { this.beanMap = beanMap; this.meta = property; } @@ -105,7 +103,7 @@ public class BeanMapEntry<T> implements Map.Entry<String,Object> { * * @return The bean map that contains this property. */ - public BeanMap<T> getBeanMap() { + public BeanMap<?> getBeanMap() { return this.beanMap; } @@ -114,7 +112,7 @@ public class BeanMapEntry<T> implements Map.Entry<String,Object> { * * @return Metadata about this bean property. */ - public BeanPropertyMeta<T> getMeta() { + public BeanPropertyMeta getMeta() { return this.meta; } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b095bd88/juneau-core/src/main/java/org/apache/juneau/BeanMeta.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/BeanMeta.java b/juneau-core/src/main/java/org/apache/juneau/BeanMeta.java index 8d4d631..5ea06a8 100644 --- a/juneau-core/src/main/java/org/apache/juneau/BeanMeta.java +++ b/juneau-core/src/main/java/org/apache/juneau/BeanMeta.java @@ -70,7 +70,7 @@ public class BeanMeta<T> { protected Class<T> c; /** The properties on the target class. */ - protected Map<String,BeanPropertyMeta<T>> properties; + protected Map<String,BeanPropertyMeta> properties; /** The getter properties on the target class. */ protected Map<Method,String> getterProps = new HashMap<Method,String>(); @@ -97,10 +97,10 @@ public class BeanMeta<T> { protected XmlBeanMeta<T> xmlMeta; // Other fields - BeanPropertyMeta<T> uriProperty; // The property identified as the URI for this bean (annotated with @BeanProperty.beanUri). - BeanPropertyMeta<T> subTypeIdProperty; // The property indentified as the sub type differentiator property (identified by @Bean.subTypeProperty annotation). + BeanPropertyMeta uriProperty; // The property identified as the URI for this bean (annotated with @BeanProperty.beanUri). + BeanPropertyMeta subTypeIdProperty; // The property indentified as the sub type differentiator property (identified by @Bean.subTypeProperty annotation). PropertyNamer propertyNamer; // Class used for calculating bean property names. - BeanPropertyMeta<T> classProperty; // "_class" mock bean property. + BeanPropertyMeta classProperty; // "_class" mock bean property. BeanMeta() {} @@ -115,7 +115,7 @@ public class BeanMeta<T> { this.classMeta = classMeta; this.ctx = ctx; this.transform = transform; - this.classProperty = new BeanPropertyMeta<T>(this, "_class", ctx.string()); + this.classProperty = new BeanPropertyMeta(this, "_class", ctx.string()); this.c = classMeta.getInnerClass(); } @@ -154,7 +154,7 @@ public class BeanMeta<T> { if (stopClass == null) stopClass = Object.class; - Map<String,BeanPropertyMeta<T>> normalProps = new LinkedHashMap<String,BeanPropertyMeta<T>>(); + Map<String,BeanPropertyMeta> normalProps = new LinkedHashMap<String,BeanPropertyMeta>(); /// See if this class matches one the patterns in the exclude-class list. if (ctx.isNotABean(c)) @@ -217,7 +217,7 @@ public class BeanMeta<T> { // First populate the properties with those specified in the bean annotation to // ensure that ordering first. for (String name : fixedBeanProps) - normalProps.put(name, new BeanPropertyMeta<T>(this, name)); + normalProps.put(name, new BeanPropertyMeta(this, name)); if (ctx.useJavaBeanIntrospector) { BeanInfo bi = null; @@ -229,7 +229,7 @@ public class BeanMeta<T> { for (PropertyDescriptor pd : bi.getPropertyDescriptors()) { String name = pd.getName(); if (! normalProps.containsKey(name)) - normalProps.put(name, new BeanPropertyMeta<T>(this, name)); + normalProps.put(name, new BeanPropertyMeta(this, name)); normalProps.get(name).setGetter(pd.getReadMethod()).setSetter(pd.getWriteMethod()); } } @@ -240,7 +240,7 @@ public class BeanMeta<T> { String name = findPropertyName(f, fixedBeanProps); if (name != null) { if (! normalProps.containsKey(name)) - normalProps.put(name, new BeanPropertyMeta<T>(this, name)); + normalProps.put(name, new BeanPropertyMeta(this, name)); normalProps.get(name).setField(f); } } @@ -252,8 +252,8 @@ public class BeanMeta<T> { String pn = bm.propertyName; Method m = bm.method; if (! normalProps.containsKey(pn)) - normalProps.put(pn, new BeanPropertyMeta<T>(this, pn)); - BeanPropertyMeta<?> bpm = normalProps.get(pn); + normalProps.put(pn, new BeanPropertyMeta(this, pn)); + BeanPropertyMeta bpm = normalProps.get(pn); if (! bm.isSetter) bpm.setGetter(m); } @@ -261,7 +261,7 @@ public class BeanMeta<T> { // Now iterate through all the setters. for (BeanMethod bm : bms) { if (bm.isSetter) { - BeanPropertyMeta<?> bpm = normalProps.get(bm.propertyName); + BeanPropertyMeta bpm = normalProps.get(bm.propertyName); if (bm.matchesPropertyType(bpm)) bpm.setSetter(bm.method); } @@ -274,8 +274,8 @@ public class BeanMeta<T> { typeVarImpls = null; // Eliminate invalid properties, and set the contents of getterProps and setterProps. - for (Iterator<BeanPropertyMeta<T>> i = normalProps.values().iterator(); i.hasNext();) { - BeanPropertyMeta<T> p = i.next(); + for (Iterator<BeanPropertyMeta> i = normalProps.values().iterator(); i.hasNext();) { + BeanPropertyMeta p = i.next(); try { if (p.validate()) { @@ -303,7 +303,7 @@ public class BeanMeta<T> { // Mark constructor arg properties. for (String fp : constructorArgs) { - BeanPropertyMeta<T> m = normalProps.get(fp); + BeanPropertyMeta m = normalProps.get(fp); if (m == null) throw new BeanRuntimeException(c, "The property ''{0}'' was defined on the @BeanConstructor(properties=X) annotation but was not found on the class definition.", fp); m.setAsConstructorArg(); @@ -315,7 +315,7 @@ public class BeanMeta<T> { boolean sortProperties = (ctx.sortProperties || (transform != null && transform.isSortProperties())) && fixedBeanProps.isEmpty(); - properties = sortProperties ? new TreeMap<String,BeanPropertyMeta<T>>() : new LinkedHashMap<String,BeanPropertyMeta<T>>(); + properties = sortProperties ? new TreeMap<String,BeanPropertyMeta>() : new LinkedHashMap<String,BeanPropertyMeta>(); if (transform != null && transform.getSubTypeProperty() != null) { String subTypeProperty = transform.getSubTypeProperty(); @@ -338,7 +338,7 @@ public class BeanMeta<T> { // Only include specified properties if BeanTransform.includeKeys is specified. // Note that the order must match includeKeys. } else if (includeKeys != null) { - Map<String,BeanPropertyMeta<T>> properties2 = new LinkedHashMap<String,BeanPropertyMeta<T>>(); + Map<String,BeanPropertyMeta> properties2 = new LinkedHashMap<String,BeanPropertyMeta>(); for (String k : includeKeys) { if (properties.containsKey(k)) properties2.put(k, properties.get(k)); @@ -368,7 +368,7 @@ public class BeanMeta<T> { * * @return The meta property for the sub type property, or <jk>null</jk> if no subtype is defined for this bean. */ - public BeanPropertyMeta<T> getSubTypeIdProperty() { + public BeanPropertyMeta getSubTypeIdProperty() { return subTypeIdProperty; } @@ -396,7 +396,7 @@ public class BeanMeta<T> { * * @return The URI property, or <jk>null</jk> if no URI property exists on this bean. */ - public BeanPropertyMeta<T> getBeanUriProperty() { + public BeanPropertyMeta getBeanUriProperty() { return uriProperty; } @@ -406,7 +406,7 @@ public class BeanMeta<T> { * * @return The class name property. */ - public BeanPropertyMeta<T> getClassProperty() { + public BeanPropertyMeta getClassProperty() { return classProperty; } @@ -433,7 +433,7 @@ public class BeanMeta<T> { * Returns true if this method matches the class type of the specified property. * Only meant to be used for setters. */ - boolean matchesPropertyType(BeanPropertyMeta<?> b) { + boolean matchesPropertyType(BeanPropertyMeta b) { if (b == null) return false; @@ -557,7 +557,7 @@ public class BeanMeta<T> { * * @return Metadata on all properties associated with this bean. */ - public Collection<BeanPropertyMeta<T>> getPropertyMetas() { + public Collection<BeanPropertyMeta> getPropertyMetas() { return this.properties.values(); } @@ -567,10 +567,10 @@ public class BeanMeta<T> { * @param pNames The list of properties to retrieve. If <jk>null</jk>, returns all properties. * @return The metadata on the specified list of properties. */ - public Collection<BeanPropertyMeta<T>> getPropertyMetas(final String...pNames) { + public Collection<BeanPropertyMeta> getPropertyMetas(final String...pNames) { if (pNames == null) return getPropertyMetas(); - List<BeanPropertyMeta<T>> l = new ArrayList<BeanPropertyMeta<T>>(pNames.length); + List<BeanPropertyMeta> l = new ArrayList<BeanPropertyMeta>(pNames.length); for (int i = 0; i < pNames.length; i++) l.add(getPropertyMeta(pNames[i])); return l; @@ -592,7 +592,7 @@ public class BeanMeta<T> { * @return The metadata about the property, or <jk>null</jk> if no such property exists * on this bean. */ - public BeanPropertyMeta<T> getPropertyMeta(String name) { + public BeanPropertyMeta getPropertyMeta(String name) { return this.properties.get(name); } @@ -703,25 +703,25 @@ public class BeanMeta<T> { * Bean property for getting and setting bean subtype. */ @SuppressWarnings({"rawtypes","unchecked"}) - private class SubTypePropertyMeta extends BeanPropertyMeta<T> { + private class SubTypePropertyMeta extends BeanPropertyMeta { private Map<Class<?>,String> subTypes; - private BeanPropertyMeta<T> realProperty; // Bean property if bean actually has a real subtype field. + private BeanPropertyMeta realProperty; // Bean property if bean actually has a real subtype field. - SubTypePropertyMeta(String subTypeAttr, Map<Class<?>,String> subTypes, BeanPropertyMeta<T> realProperty) { + SubTypePropertyMeta(String subTypeAttr, Map<Class<?>,String> subTypes, BeanPropertyMeta realProperty) { super(BeanMeta.this, subTypeAttr, ctx.string()); this.subTypes = subTypes; this.realProperty = realProperty; - this.htmlMeta = new HtmlBeanPropertyMeta<T>(this); - this.xmlMeta = new XmlBeanPropertyMeta<T>(this); - this.rdfMeta = new RdfBeanPropertyMeta<T>(this); + this.htmlMeta = new HtmlBeanPropertyMeta(this); + this.xmlMeta = new XmlBeanPropertyMeta(this); + this.rdfMeta = new RdfBeanPropertyMeta(this); } /* * Setting this bean property causes the inner bean to be set to the subtype implementation. */ @Override /* BeanPropertyMeta */ - public Object set(BeanMap<T> m, Object value) throws BeanRuntimeException { + public Object set(BeanMap<?> m, Object value) throws BeanRuntimeException { if (value == null) throw new BeanRuntimeException("Attempting to set bean subtype property to null."); String subTypeId = value.toString(); @@ -730,7 +730,7 @@ public class BeanMeta<T> { Class subTypeClass = e.getKey(); m.meta = ctx.getBeanMeta(subTypeClass); try { - m.bean = (T)subTypeClass.newInstance(); + m.setBean(subTypeClass.newInstance()); if (realProperty != null) realProperty.set(m, value); // If subtype attribute wasn't specified first, set them again from the temporary cache. @@ -747,7 +747,7 @@ public class BeanMeta<T> { } @Override /* BeanPropertyMeta */ - public Object get(BeanMap<T> m) throws BeanRuntimeException { + public Object get(BeanMap<?> m) throws BeanRuntimeException { String subTypeId = transform.getSubTypes().get(c); if (subTypeId == null) throw new BeanRuntimeException(c, "Unmapped sub type class"); @@ -759,7 +759,7 @@ public class BeanMeta<T> { public String toString() { StringBuilder sb = new StringBuilder(c.getName()); sb.append(" {\n"); - for (BeanPropertyMeta<?> pm : this.properties.values()) + for (BeanPropertyMeta pm : this.properties.values()) sb.append('\t').append(pm.toString()).append(",\n"); sb.append('}'); return sb.toString(); http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b095bd88/juneau-core/src/main/java/org/apache/juneau/BeanMetaFiltered.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/BeanMetaFiltered.java b/juneau-core/src/main/java/org/apache/juneau/BeanMetaFiltered.java index 09b0d0d..cbffeaa 100644 --- a/juneau-core/src/main/java/org/apache/juneau/BeanMetaFiltered.java +++ b/juneau-core/src/main/java/org/apache/juneau/BeanMetaFiltered.java @@ -36,7 +36,7 @@ public final class BeanMetaFiltered<T> extends BeanMeta<T> { */ public BeanMetaFiltered(BeanMeta<T> innerMeta, String[] pNames) { this.innerMeta = innerMeta; - this.properties = new LinkedHashMap<String,BeanPropertyMeta<T>>(); + this.properties = new LinkedHashMap<String,BeanPropertyMeta>(); for (String p : pNames) properties.put(p, innerMeta.getPropertyMeta(p)); this.xmlMeta = new XmlBeanMeta<T>(innerMeta, pNames); @@ -58,12 +58,12 @@ public final class BeanMetaFiltered<T> extends BeanMeta<T> { } @Override /* BeanMeta */ - public Collection<BeanPropertyMeta<T>> getPropertyMetas() { + public Collection<BeanPropertyMeta> getPropertyMetas() { return properties.values(); } @Override /* BeanMeta */ - public BeanPropertyMeta<T> getPropertyMeta(String name) { + public BeanPropertyMeta getPropertyMeta(String name) { return properties.get(name); } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b095bd88/juneau-core/src/main/java/org/apache/juneau/BeanPropertyMeta.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/BeanPropertyMeta.java b/juneau-core/src/main/java/org/apache/juneau/BeanPropertyMeta.java index 48332cf..3813e8a 100644 --- a/juneau-core/src/main/java/org/apache/juneau/BeanPropertyMeta.java +++ b/juneau-core/src/main/java/org/apache/juneau/BeanPropertyMeta.java @@ -41,17 +41,16 @@ import org.apache.juneau.xml.*; * Developers will typically not need access to this class. The information provided by it is already * exposed through several methods on the {@link BeanMap} API. * - * @param <T> The class type of the bean that this metadata applies to. * @author James Bognar ([email protected]) */ @SuppressWarnings({ "rawtypes", "unchecked" }) -public class BeanPropertyMeta<T> { +public class BeanPropertyMeta { private Field field; private Method getter, setter; private boolean isConstructorArg, isBeanUri, isUri; - private final BeanMeta<T> beanMeta; + private final BeanMeta<?> beanMeta; private String name; private ClassMeta<?> @@ -61,13 +60,13 @@ public class BeanPropertyMeta<T> { private PojoTransform transform; // PojoTransform defined only via @BeanProperty annotation. /** HTML related metadata on this bean property. */ - protected HtmlBeanPropertyMeta<T> htmlMeta; + protected HtmlBeanPropertyMeta htmlMeta; /** XML related metadata on this bean property. */ - protected XmlBeanPropertyMeta<T> xmlMeta; + protected XmlBeanPropertyMeta xmlMeta; /** RDF related metadata on this bean property. */ - protected RdfBeanPropertyMeta<T> rdfMeta; // + protected RdfBeanPropertyMeta rdfMeta; // /** * Constructor. @@ -75,17 +74,17 @@ public class BeanPropertyMeta<T> { * @param beanMeta The metadata of the bean containing this property. * @param name This property name. */ - protected BeanPropertyMeta(BeanMeta<T> beanMeta, String name) { + protected BeanPropertyMeta(BeanMeta<?> beanMeta, String name) { this.beanMeta = beanMeta; this.name = name; } - BeanPropertyMeta(BeanMeta<T> beanMeta, String name, ClassMeta<?> rawTypeMeta) { + BeanPropertyMeta(BeanMeta<?> beanMeta, String name, ClassMeta<?> rawTypeMeta) { this(beanMeta, name); this.rawTypeMeta = rawTypeMeta; } - BeanPropertyMeta(BeanMeta<T> beanMeta, String name, Method getter, Method setter) { + BeanPropertyMeta(BeanMeta<?> beanMeta, String name, Method getter, Method setter) { this(beanMeta, name); setGetter(getter); setSetter(setter); @@ -106,7 +105,7 @@ public class BeanPropertyMeta<T> { * @return The bean meta that this property belongs to. */ @BeanIgnore - public BeanMeta<T> getBeanMeta() { + public BeanMeta<?> getBeanMeta() { return beanMeta; } @@ -158,7 +157,7 @@ public class BeanPropertyMeta<T> { * @param getter The getter method to associate with this property. * @return This object (for method chaining). */ - BeanPropertyMeta<T> setGetter(Method getter) { + BeanPropertyMeta setGetter(Method getter) { setAccessible(getter); this.getter = getter; return this; @@ -170,7 +169,7 @@ public class BeanPropertyMeta<T> { * @param setter The setter method to associate with this property. * @return This object (for method chaining). */ - BeanPropertyMeta<T> setSetter(Method setter) { + BeanPropertyMeta setSetter(Method setter) { setAccessible(setter); this.setter = setter; return this; @@ -182,7 +181,7 @@ public class BeanPropertyMeta<T> { * @param field The field to associate with this property. * @return This object (for method chaining). */ - BeanPropertyMeta<T> setField(Field field) { + BeanPropertyMeta setField(Field field) { setAccessible(field); this.field = field; return this; @@ -193,7 +192,7 @@ public class BeanPropertyMeta<T> { * * @return This object (for method chaining). */ - BeanPropertyMeta<T> setAsConstructorArg() { + BeanPropertyMeta setAsConstructorArg() { this.isConstructorArg = true; return this; } @@ -238,7 +237,7 @@ public class BeanPropertyMeta<T> { * * @return The HTML-related metadata on this bean property. Never <jk>null</jk>/. */ - public HtmlBeanPropertyMeta<T> getHtmlMeta() { + public HtmlBeanPropertyMeta getHtmlMeta() { return htmlMeta; } @@ -247,7 +246,7 @@ public class BeanPropertyMeta<T> { * * @return The XML-related metadata on this bean property. Never <jk>null</jk>/. */ - public XmlBeanPropertyMeta<T> getXmlMeta() { + public XmlBeanPropertyMeta getXmlMeta() { return xmlMeta; } @@ -256,7 +255,7 @@ public class BeanPropertyMeta<T> { * * @return The RDF-related metadata on this bean property. Never <jk>null</jk>/. */ - public RdfBeanPropertyMeta<T> getRdfMeta() { + public RdfBeanPropertyMeta getRdfMeta() { return rdfMeta; } @@ -349,7 +348,7 @@ public class BeanPropertyMeta<T> { * @param m The bean map to get the transformed value from. * @return The property value. */ - public Object get(BeanMap<T> m) { + public Object get(BeanMap<?> m) { try { // Read-only beans have their properties stored in a cache until getBean() is called. Object bean = m.bean; @@ -411,7 +410,7 @@ public class BeanPropertyMeta<T> { * @return The previous property value. * @throws BeanRuntimeException If property could not be set. */ - public Object set(BeanMap<T> m, Object value) throws BeanRuntimeException { + public Object set(BeanMap<?> m, Object value) throws BeanRuntimeException { try { // Comvert to raw form. value = normalize(value); @@ -617,7 +616,7 @@ public class BeanPropertyMeta<T> { * @throws IllegalAccessException Thrown by method invocation. * @throws InvocationTargetException Thrown by method invocation. */ - protected void setArray(T bean, List l) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { + protected void setArray(Object bean, List l) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { Object array = ArrayUtils.toArray(l, this.rawTypeMeta.getElementType().getInnerClass()); if (setter != null) setter.invoke(bean, array); @@ -636,7 +635,7 @@ public class BeanPropertyMeta<T> { * @param value The value to add to the field. * @throws BeanRuntimeException If field is not a collection or array. */ - public void add(BeanMap<T> m, Object value) throws BeanRuntimeException { + public void add(BeanMap<?> m, Object value) throws BeanRuntimeException { BeanContext bc = beanMeta.ctx; http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b095bd88/juneau-core/src/main/java/org/apache/juneau/BeanPropertyValue.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/BeanPropertyValue.java b/juneau-core/src/main/java/org/apache/juneau/BeanPropertyValue.java index 3238474..043dcb3 100644 --- a/juneau-core/src/main/java/org/apache/juneau/BeanPropertyValue.java +++ b/juneau-core/src/main/java/org/apache/juneau/BeanPropertyValue.java @@ -21,7 +21,7 @@ package org.apache.juneau; */ public class BeanPropertyValue { - private final BeanPropertyMeta<?> pMeta; + private final BeanPropertyMeta pMeta; private final Object value; private final Throwable thrown; @@ -32,7 +32,7 @@ public class BeanPropertyValue { * @param value The bean property value. * @param thrown The exception thrown by calling the property getter. */ - protected BeanPropertyValue(BeanPropertyMeta<?> pMeta, Object value, Throwable thrown) { + protected BeanPropertyValue(BeanPropertyMeta pMeta, Object value, Throwable thrown) { this.pMeta = pMeta; this.value = value; this.thrown = thrown; @@ -42,7 +42,7 @@ public class BeanPropertyValue { * Returns the bean property metadata. * @return The bean property metadata. */ - public final BeanPropertyMeta<?> getMeta() { + public final BeanPropertyMeta getMeta() { return pMeta; } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b095bd88/juneau-core/src/main/java/org/apache/juneau/BeanRuntimeException.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/BeanRuntimeException.java b/juneau-core/src/main/java/org/apache/juneau/BeanRuntimeException.java index 2df2070..3b0d995 100644 --- a/juneau-core/src/main/java/org/apache/juneau/BeanRuntimeException.java +++ b/juneau-core/src/main/java/org/apache/juneau/BeanRuntimeException.java @@ -32,6 +32,16 @@ public final class BeanRuntimeException extends FormattedRuntimeException { } /** + * Constructor. + * + * @param message The error message. + * @param args Arguments passed in to the {@code String.format()} method. + */ + public BeanRuntimeException(String message, Object...args) { + super(message, args); + } + + /** * Shortcut for calling <code><jk>new</jk> BeanRuntimeException(String.format(c.getName() + <js>": "</js> + message, args));</code> * * @param c The class name of the bean that caused the exception.
