Free AggregatorFactory implementors from boilerplate in getMergingFactory()
- Dominant language
- Java
- Stars
- 14.1k
- Forks
- 3.8k
- Avg merge
- 2d 58m
- Merged PRs (30d)
- 233
Description
Currently AggregatorFactory implementors should write code like the following themselves:
```java
if (other.getName().equals(this.getName()) && other.getClass() == getClass()) {
...
} else {
throw new AggregatorFactoryNotMergeableException(...);
}
```
or
```java
if (other.getName().equals(this.getName()) && other instanceof MyBaseAggregatorFactory) {
...
} else {
throw new AggregatorFactoryNotMergeableException(...);
}
```
if `MyBaseAggregatorFactory` is extended by other aggregator factory classes.
It could be replaced by e. g. by adding a generic parameter `BaseMergeAggregatorFactory` to `AggregatorFactory` class; adding a method `Class getBaseMergeAggregatorFactory()` method; and changing the signature of `getMergeFactory()` to accept `BaseMergeAggregatorFactory` as the parameter.
Contributor guide
Research direction
Start by locating AggregatorFactory, getMergingFactory(), and existing AggregatorFactory implementors that repeat the name and type checks. Review how AggregatorFactoryNotMergeableException is used; done means the shared merge contract removes that boilerplate while preserving the existing mergeability behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100