// allow this scenario for beans as we may want to bring in a subset of properties
if (beanClass != null) {
return propertyTypesGiven;
}
else {
throw new EPException("Event type " + eventTypeName + " has already been declared with a different number of parameters");
}
}
for(String property : eventType.getPropertyNames())
{
Class type;
try {
type = eventType.getPropertyType(property);
}
catch (PropertyAccessException e) {
// thrown if trying to access an invalid property on an EventBean
throw new EPException(e);
}
if(propertyTypesGiven != null && propertyTypesGiven.get(property) == null)
{
throw new EPException("Event type " + eventTypeName + "has already been declared with different parameters");
}
if(propertyTypesGiven != null && !propertyTypesGiven.get(property).equals(type))
{
throw new EPException("Event type " + eventTypeName + "has already been declared with a different type for property " + property);
}
// we can't set read-only properties for bean
if(!eventType.getUnderlyingType().equals(Map.class)) {
PropertyDescriptor[] pds = ReflectUtils.getBeanProperties(beanClass);
PropertyDescriptor pd = null;
for (PropertyDescriptor p :pds) {
if (p.getName().equals(property))
pd = p;
}
if (pd == null)
{
continue;
}
if (pd.getWriteMethod() == null) {
if (propertyTypesGiven == null) {
continue;
}
else {
throw new EPException("Event type " + eventTypeName + "property " + property + " is read only");
}
}
}
propertyTypes.put(property, type);
}