[core] Implement PropertyFactory#1470
Conversation
Generated by 🚫 Danger |
They make no sense as they are shared by all StatisticalRules, and provoke configuration errors on normal inputs since uncorrectly configured properties now cause the rule not to be run
adangel
left a comment
There was a problem hiding this comment.
I like the way, this is going 👍
One small question: We once said, we wanted to move the internal implementation classes into a sub-package called internal or impl. You have now created the implementations in the same package and just made the classes package-private - which is fine, since this also hides the classes from public API. I think, if we would create a sub-package, then you'd need to make the implementations public, so that you can use it the PropertyFactory... What do you think?
| // todo Java 8 move up to interface | ||
| @Override | ||
| public String dysfunctionReason() { | ||
| for (PropertyDescriptor<?> descriptor : getOverriddenPropertyDescriptors()) { |
There was a problem hiding this comment.
We should think about improving this API (different PR) - this would only return the first error. We should have a API, that returns all the problems a rule has.
| * Note: from 7.0.0 on, this will be the only way to | ||
| * build property descriptors. | ||
| * | ||
| * TODO next PR add doc |
| * | ||
| * @return The same builder | ||
| */ | ||
| // TODO we could probably specify the order of execution of constraints come 7.0.0, for now this remains unspecified |
There was a problem hiding this comment.
I thought shortly about this - but does the order of the constraints matter? They all need to be met, and the constraints should be independent from each other...
There was a problem hiding this comment.
Indeed it wouldn't matter if constraints are truly independent -> in which case we should specify that. I think it makes sense, and it would allow to report all errors on a value, like you suggested for rules.
Co-Authored-By: oowekyala <clement.fournier76@gmail.com>
Co-Authored-By: oowekyala <clement.fournier76@gmail.com>
My 2 cents on that is, if the internal classes are only relevant to the package they're in (eg in this case), then I'd prefer package visibility over having an internal package. The internals are better hidden that way I guess. Although in some cases using package visibility is simply not possible, then those internal APIs would belong in an internal package. Also if the main package has many classes. |
…nto new-properties-framework
| public List<T> get() { | ||
| return new ArrayList<>(); | ||
| } | ||
| }; |
There was a problem hiding this comment.
do we really need this and to pass it around just to create an empty list? sounds like overkill to me
There was a problem hiding this comment.
This is in prevision of the migration to Java 8. Many things here are sloppy because I designed this as if it was Java 8, but had to write it with Java 7 syntax so it's ugly. In Java 8 it will be as short as ArrayList::new, and we can also provide a toSet method with HashSet::new, or let the user use any collection supplier they want.
There was a problem hiding this comment.
It's not about the syntax, it's about the actual need for a Supplier for such a thing
There was a problem hiding this comment.
As documented, GenericCollectionPropertyBuilder is designed to support building properties for an arbitrary Collection, not just lists. The most generic way to do that is to pass on a Supplier for the collection you want. How would you do it otherwise?
There was a problem hiding this comment.
I'm unsure there is a need for arbitrary collections types at all, and I fear being flexible about it is overengineering. Do we even have a use case for this?
There was a problem hiding this comment.
It's extremely easy to grab, so I wouldn't consider that overengineering. Everything is already completely generic, and GenericMultivaluePropertyDescriptor will be removed with 7.0.0, so there's really no point in artificially constraining ourselves to lists. One use case I can think of is the options for metrics rules, which would be better served by using a Set rather than a list.
Second step to #1432, scheduled for 6.10.0. It should be merged on master. The release notes update about PropertyFactory will be part of the next PR, along with the deprecations of concrete property classes.
delimiter()method).