S
S
Sland Show2019-09-21 00:15:19
Java
Sland Show, 2019-09-21 00:15:19

What is the best way to transform an object?

My object is an instance of the Port class that contains the desired portNumber field inside .

public class Port implements Serializable {
@JsonProperty("portNumber")
  private String portNumber = null;
...
}

The business logic uses a method that takes from the Port instance. But it is not Port that is returned, but the Object type.
// Возвращается инстанс Port
 runtimeService.getVariable(task.getExecutionId(), "port");

But the trouble is that I need to return the port field - portNumber. and when I try to return exactly the port field inline, the code is not very beautiful
(Port) variables.get(Variable.PORT.getName())).getPortNumber()

Is there a way to make it pretty? Maybe smack?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question