All Questions
Tagged with refactoring java
1,412 questions
1
vote
1
answer
68
views
Is there anyway to make Java Custom Annotation Processor with RetentionPolicy SOURCE to work?
I have created a Java Custom Annotation Processor with RetentionPolicy as SOURCE for generating personalized code for me just like Lombok's Getter & Setter.
Unfortunately it didn't worked because ...
-1
votes
1
answer
61
views
Correct approach to refactor duplicate API Call to different endpoints
I have two methods that make a call to two different endpoints. The logic is exactly the same, however the API Endpoints have to be kept seperate. How would you refactor this?
public List<...
0
votes
2
answers
63
views
IntelliJ refactoring: join two variables into once
I have this class
@Data
@NoArgsConstructor
public class DittaIndividualeDTO implements Dati {
private String denominazione;
private String nome;
private String cognome;
private String ...
0
votes
0
answers
75
views
Refactor the method
I have a method that works with both a list and a single element. Is there a concise way to accept either of these types (perhaps using generics, etc)
public void write(MyInter elemen){
...
-1
votes
1
answer
43
views
return firts present Optional
I have a few validation cases which returns Optional.empty() or Optional.of(new Object())
How to return the first non empty result of this cases?
on this method I want to return the first not empty ...
0
votes
0
answers
66
views
Implementing a NON-implementation (example from "Head First Design Patterns")?
In "Head First Design Patterns," there is an example involving flying behavior of ducks that gets refactored because there is a combination of flying ducks (eg Mallards) and non-flying ducks ...
0
votes
0
answers
304
views
openapi generator and oneOf, What is the best way to implement OAS using oneOf
i am currently trying to implement an openapi specification which uses the oneOf component. The way its setup, there is a Grandparent which has a property Children which can be one of either Child or ...
0
votes
0
answers
41
views
(Java) How should I implement code for 2 semantically identical entities that need to be stored in different DB tables?
We are an E-commerce company and so far, we have been using an entity called DeliveryAddressEntity to represent address data stored when we receive orders. I am trying to add support for ...
1
vote
1
answer
189
views
Should you use the Command Pattern for requests involving very little logic? [closed]
I am new to design patterns and want to get a better understanding of when to implement the command pattern. The command pattern from my understanding is intended to encapsulate a request and the ...
-1
votes
1
answer
41
views
migration issue from Package by Layer to -> Package by Feature
What I am trying to achieve
I wish to use "Package by Feature" for my @Configuration files.
Currently, I am using "Package by Layer".
Just to be clear, this is not an opinion-...
0
votes
0
answers
49
views
IntelliJ: reorder methods by first usage
IntelliJ provides a couple of ways to reorder method. It seems that there is one possibility missing, namely reordering methods by their usage. I'd like to have all private methods to be sorted in ...
0
votes
0
answers
38
views
Rename files automatically within IntelliJ IDE
Within my current Selenium Java test automation framework, I have a method that upload a file to the site I am testing, where I pass the absolute path to the method parameter. The absolute path of the ...
0
votes
0
answers
97
views
How to find unused code in a huge codebase
It's a java springboot application with intellij.
The problem is:
intellij makes mistakes when it comes to finding unused code (marking unused as used or vica versa)
The codebase contains huge amount ...
0
votes
0
answers
66
views
Moving the method to another class make it stop working
I have this class called Screen
package main;
import java.awt.Dimension;
import java.io.IOException;
import javax.swing.JFrame;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
import ...
0
votes
4
answers
189
views
Refactoring Java Code: Eliminating or Streamlining a Boolean Variable Outside a For Loop
I am struggling with the following problem in my code:
boolean target = false;
for (Item item : list) {
if (item.boolA || target == true) {
if (item.boolB) {
target = false;
} else if (...