-
Notifications
You must be signed in to change notification settings - Fork 18
Closed
Labels
architectureDifficult architectural questionsDifficult architectural questions
Milestone
Description
As seen in the PR for #383, extending SetProperty
for EnumSetPropertyType
has problems:
public EnumSetProperty(String path, Class<E> enumClass, EnumSet<E> defaultValue) {
// Compile error, EnumSetProperty must be unchecked
super(new EnumSetPropertyType<>(enumClass), path, defaultValue);
}
This is because:
SetProperty<E> extends TypeBasedProperty<Set<E>>
EnumSetPropertyType<E extends Enum<E>> extends CollectionPropertyType<E, EnumSet<E>>
So theProperty
wrapper forEnumSetPropertyType
should be aProperty<EnumSet<E>>
, notProperty<Set<E>>
How to deal with this?
- I like a general parent for lists and sets (respectively), so that if we need to deal with Property classes, we can do
instanceof
on general sounding types without needing to list all implementations separately. Hierarchy-wise, it looks good for an enum set property to be of type set property. - We could make
SetProperty
more generic to be something likeSetProperty<E, S extends Set<E>> extends Property<S>
but that might be clunky for the general use case? Especially needing to then declare set property constants asSetProperty<String, Set<String>>
everywhere...- Introduce an extension??
- Introduce an abstract collection property that
SetProperty
andEnumSetProperty
can extend? EnumSetProperty would no longer be a SetProperty, but that might technically be true:SetPropertyType
andEnumSetPropertyType
are also not parent-child, but siblings
- Ignore this discrepancy as I think right now it has no impact so long as no
PropertyType
really strictly assumes only its implementation of a set (or similar) can come in.
Metadata
Metadata
Assignees
Labels
architectureDifficult architectural questionsDifficult architectural questions