Closed havardh closed 4 years ago
For https://github.com/havardh/javaflow/issues/78 @JsonGetter needs to or the ability to use @JsonProperty annotation over the method. However, if you apply current changes it will be enough for me. Why do I need this annotation? I will give a small example
import com.fasterxml.jackson.annotation.JsonProperty;
public class Payment {
private String VAT;
@JsonProperty("VAT")
public String getVAT() {
return VAT;
}
public void setVAT(String VAT) {
this.VAT = VAT;
}
}
Json: {"VAT":"30%"} But:
import com.fasterxml.jackson.annotation.JsonProperty;
public class Payment {
@JsonProperty("VAT")
private String VAT;
public String getVAT() {
return VAT;
}
public void setVAT(String VAT) {
this.VAT = VAT;
}
}
Json: {"vat":"30%","VAT":"30%"} Because of this, I am forced to use @JsonProperty or @JsonGetter over the method.
Also need to fix validation logic
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.math.BigDecimal;
public class TestObject {
@JsonIgnore
private BigDecimal total;
public BigDecimal getTotal() {
return total;
}
public void setTotal(BigDecimal total) {
this.total = total;
}
}
Execute: javaflow ./ Result:
Exception in thread "main" picocli.CommandLine$ExecutionException: Error while running command (com.github.havardh.javaflow.JavaFlow@44f75083): com.github.havardh.javaflow.exceptions.AggregatedException: Verification failed:
Could not find types: {test.TestObject=[total: java.math.BigDecimal]}
at picocli.CommandLine.execute(CommandLine.java:1051)
at picocli.CommandLine.access$900(CommandLine.java:142)
at picocli.CommandLine$RunLast.handle(CommandLine.java:1246)
at picocli.CommandLine$RunLast.handle(CommandLine.java:1214)
at picocli.CommandLine$AbstractParseResultHandler.handleParseResult(CommandLine.java:1122)
at picocli.CommandLine.parseWithHandlers(CommandLine.java:1405)
at picocli.CommandLine.run(CommandLine.java:1864)
at picocli.CommandLine.run(CommandLine.java:1794)
at com.github.havardh.javaflow.JavaFlow.main(JavaFlow.java:54)
Caused by: com.github.havardh.javaflow.exceptions.AggregatedException: Verification failed:
Could not find types: {test.TestObject=[total: java.math.BigDecimal]}
at com.github.havardh.javaflow.Execution.verify(Execution.java:119)
at java.util.stream.ReferencePipeline$11$1.accept(ReferencePipeline.java:372)
at java.util.stream.ReferencePipeline$11$1.accept(ReferencePipeline.java:373)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.Streams$StreamBuilderImpl.forEachRemaining(Streams.java:419)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at com.github.havardh.javaflow.Execution.run(Execution.java:98)
at com.github.havardh.javaflow.JavaFlow.run(JavaFlow.java:90)
at picocli.CommandLine.execute(CommandLine.java:1043)
... 8 more
No need to validate field with @JsonIgnore mark
@spirit93 here is my proposal for
@JsonIgnore
and@JsonProperty
, if you have some spare time please check out if these meets your needs for #78 :v: