Answer the question
In order to leave comments, you need to log in
What is going on???
I will show a simplified code from my project. I just have a butchert from him ...
MyModel.java
package com.company;
public class MyModel {
public String myField;
}
package com.company;
public class MyView {
public String myField;
}
package com.company;
public class MyMapper {
public static MyView map(MyModel model) {
return new MyView() {{
myField = model.myField;
}};
}
public static MyModel map(MyView view) {
return new MyModel() {{
myField = view.myField;
}};
}
}
package com.company;
import static com.company.MyMapper.*;
public class Main {
public static void main(String[] args) {
MyView view = new MyView() {{
myField = "Hello world!";
}};
myMethod(map(view));
}
public static void myMethod(MyModel model) {
System.out.println(model.getClass().getName()); // com.company.MyMapper$2
}
}
Answer the question
In order to leave comments, you need to log in
It is not MyMapper. It is MyMapper$2.
Replace
return new MyModel() {{
myField = view.myField;
}};
MyModel myModel = new MyModel();
myModel.myField = view.myField;
return myModel;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question