-
Notifications
You must be signed in to change notification settings - Fork 20
Feat/add lombok #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/add lombok #87
Changes from 2 commits
a045da7
ffa2d92
5376f2e
5b893e7
be7db4c
7147345
d232cbd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,9 +1,13 @@ | ||||||||
| package com.mycmd; | ||||||||
|
|
||||||||
| import lombok.Getter; | ||||||||
| import lombok.Setter; | ||||||||
| import java.io.*; | ||||||||
| import java.util.*; | ||||||||
| import java.time.Instant; | ||||||||
|
|
||||||||
| @Getter | ||||||||
| @Setter | ||||||||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||
| public class ShellContext { | ||||||||
| private File currentDir; | ||||||||
| private List<String> history; | ||||||||
|
|
@@ -13,6 +17,8 @@ public class ShellContext { | |||||||
| private final List<String> commandHistory; | ||||||||
| private final Instant startTime; | ||||||||
|
|
||||||||
| private final Map<String, String> envVars = new HashMap<>(); | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add @Getter(AccessLevel.NONE) to the envVars field. The Apply this diff: + @Getter(AccessLevel.NONE)
private final Map<String, String> envVars = new HashMap<>();📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||
|
|
||||||||
| public ShellContext() { | ||||||||
| this.currentDir = new File(System.getProperty("user.dir")); | ||||||||
| this.history = new ArrayList<>(); | ||||||||
|
|
@@ -22,14 +28,6 @@ public ShellContext() { | |||||||
| loadAliases(); | ||||||||
| } | ||||||||
|
|
||||||||
| public File getCurrentDir() { | ||||||||
| return currentDir; | ||||||||
| } | ||||||||
|
|
||||||||
| public void setCurrentDir(File dir) { | ||||||||
| this.currentDir = dir; | ||||||||
| } | ||||||||
|
|
||||||||
| public void addToHistory(String command) { | ||||||||
| history.add(command); | ||||||||
| commandHistory.add(command); // Add to command history | ||||||||
|
|
@@ -38,17 +36,6 @@ public void addToHistory(String command) { | |||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| public List<String> getHistory() { | ||||||||
| return new ArrayList<>(history); | ||||||||
| } | ||||||||
|
|
||||||||
| public List<String> getCommandHistory() { | ||||||||
| return commandHistory; | ||||||||
| } | ||||||||
|
|
||||||||
| public Instant getStartTime() { | ||||||||
| return startTime; | ||||||||
| } | ||||||||
|
|
||||||||
| public void clearHistory() { | ||||||||
| history.clear(); | ||||||||
|
|
@@ -65,14 +52,6 @@ public void removeAlias(String name) { | |||||||
| saveAliases(); | ||||||||
| } | ||||||||
|
|
||||||||
| public String getAlias(String name) { | ||||||||
| return aliases.get(name); | ||||||||
| } | ||||||||
|
|
||||||||
| public Map<String, String> getAliases() { | ||||||||
| return new HashMap<>(aliases); | ||||||||
| } | ||||||||
|
|
||||||||
| public boolean hasAlias(String name) { | ||||||||
| return aliases.containsKey(name); | ||||||||
| } | ||||||||
|
|
@@ -131,21 +110,4 @@ public File resolvePath(String path) { | |||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| // environmental variable map | ||||||||
| // author: Kaveesha Fernando | ||||||||
| // date: 2024-06-10 | ||||||||
| private final Map<String, String> envVars = new HashMap<>(); | ||||||||
|
|
||||||||
| public void setEnvVar(String key, String value) { | ||||||||
| envVars.put(key, value); | ||||||||
| } | ||||||||
|
|
||||||||
| public String getEnvVar(String key) { | ||||||||
| return envVars.get(key); | ||||||||
| } | ||||||||
|
|
||||||||
| public Map<String, String> getEnvVars() { | ||||||||
| return new HashMap<>(envVars); | ||||||||
| } | ||||||||
|
|
||||||||
| } | ||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix: Class-level @Getter conflicts with custom getter implementations.
The class-level
@Gettergenerates getters for all fields, but you're attempting to provide custom implementations forgetHistory(),getAliases(), andgetEnvVars()that return defensive copies. This approach causes the@Overridecompilation errors on lines 46, 51, and 56 because you cannot override methods generated in the same class.Solution: Exclude specific fields from the class-level
@Getterby annotating them with@Getter(AccessLevel.NONE), then provide your custom getters without@Override.Apply this diff:
Then remove the
@Overrideannotations from lines 46, 51, and 56 (see separate comments below).🤖 Prompt for AI Agents