Modify CommandParser to use generic type simmilar to CommandHandler #33

Closed
opened 2026-03-31 19:18:01 +02:00 by lars.winzer · 5 comments
lars.winzer commented 2026-03-31 19:18:01 +02:00 (Migrated from git.scicore.unibas.ch)

Feature Request

Summary

Modifying the CommandParser to allow for any type extending the Request type.

Required workarround

Returning an type extending Request, with the downside that any context in the JavaDoc is lost.

Description

Currently its only possible to implement a CommandParser as follows:

public class PingParser implements CommandParser {
    @Override
    public PingRequest parse(PrimitiveRequest primitiveRequest) {
        return new PingRequest(primitiveRequest.context());
    }
}

After the change, its possible to do it like this:

public class PingParser implements CommandParser<PingRequest> {
    @Override
    public PingRequest parse(PrimitiveRequest primitiveRequest) {
        return new PingRequest(primitiveRequest.context());
    }
}

It gives the code more context without needing to read it.

Additionally IDEs are able to auto generate stubs (like the parse method) using this specified type.

Checklist

  • I have described the function in detail
  • I searched docs for alternative implementations matching my needs
  • I added relevant labels
## Feature Request <!--The reccommended type is: Task--> ### Summary Modifying the CommandParser to allow for any type extending the Request type. ### Required workarround Returning an type extending `Request`, with the downside that any context in the JavaDoc is lost. ### Description Currently its only possible to implement a CommandParser as follows: ```java public class PingParser implements CommandParser { @Override public PingRequest parse(PrimitiveRequest primitiveRequest) { return new PingRequest(primitiveRequest.context()); } } ``` After the change, its possible to do it like this: ```java public class PingParser implements CommandParser<PingRequest> { @Override public PingRequest parse(PrimitiveRequest primitiveRequest) { return new PingRequest(primitiveRequest.context()); } } ``` It gives the code more context without needing to read it. Additionally IDEs are able to auto generate stubs (like the parse method) using this specified type. ### Checklist - [x] I have described the function in detail - [x] I searched docs for alternative implementations matching my needs - [x] I added relevant labels
lars.winzer commented 2026-03-31 19:18:07 +02:00 (Migrated from git.scicore.unibas.ch)

assigned to @lars.winzer

assigned to @lars.winzer
lars.winzer commented 2026-03-31 19:19:17 +02:00 (Migrated from git.scicore.unibas.ch)

created branch feat/33-commandparser-generic-type to address this issue

created branch [`feat/33-commandparser-generic-type`](/cs108-fs26/Gruppe-13/-/compare/main...feat%2F33-commandparser-generic-type) to address this issue
lars.winzer commented 2026-03-31 19:29:52 +02:00 (Migrated from git.scicore.unibas.ch)

added 5m of time spent at 2026-03-31 12:00:00 +0200

added 5m of time spent at 2026-03-31 12:00:00 +0200
lars.winzer commented 2026-03-31 19:31:15 +02:00 (Migrated from git.scicore.unibas.ch)

mentioned in merge request !63

mentioned in merge request !63
lars.winzer commented 2026-03-31 19:32:33 +02:00 (Migrated from git.scicore.unibas.ch)

mentioned in commit 56667bfb12

mentioned in commit 56667bfb1205bfbf204c2eefe832838f32da559d
lars.winzer (Migrated from git.scicore.unibas.ch) closed this issue 2026-03-31 19:32:34 +02:00
This repo is archived. You cannot comment on issues.
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: University-of-Basel-Studentprojects/Programmierprojekt#33