Missing a common interface between MethodGenericsContext and ConstructorGenericsContext

Open
#6 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
backend

Research direction

Start by reading MethodGenericsContext and ConstructorGenericsContext, especially their parameter-inspection methods such as resolveParametersTypes() and parameterType(int). Decide whether a shared interface or parent class best exposes the common API while avoiding duplication. Done means callers can use one common type for both contexts and the existing behavior remains available.

Written by the indexing model from the issue text.

Description

enhancement

java.lang.reflect.Constructor and java.lang.reflect.Method all inherit from java.lang.reflect.Executable, which defines all methods related to inspection of the arguments.
This allows to make some common code for inspecting the parameters of either a constructor or a method.

Generics-Resolver does not currently expose any such common parent between ConstructorGenericsContext and MethodGenericsContext, so it becomes difficult to share this kind of code when working with generics. (I am currently using a wrapper class around both objects, but this is not very nice)

A quick suggestion is to create an ExecutableGenericsContext interface defining the resolveParametersTypes() and parameterType(final int pos) methods, and a few others.
You could probably refactor the lib code a bit to make this a common parent class instead and avoid code duplication, but that's up to you - for the end user, the result will be the same :-)

Dominant language
Java
Stars
52
Forks
9
Avg merge
4h 4m
Merged PRs (30d)
3

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from xvik/generics-resolver

All issues in xvik/generics-resolver

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.