I have a decision in my Java application.
if (variable == 0) {
// call a function without parameter
func();
} else {
// call a function with parameter
func(variable);
}
Could I do this call (function) with or without parameter in just one line? This problem is because the function can't receive "Zero", just a valid ID.
What I want to do is somenthing like that. (ternary operation) Here is the main problem what I want to resolve
//condition ? truth : false; to allow to send with or without parameter
func( (variable!=0?Id:null) )
And then the Java will decision what function access.
I declared my function like below in my repository
@Query("select c from Cliente c "
+ " where c.id = :id "
+ " and c.negativar = true" )
List<Cliente> findClients(@Param("id") Integer id);
@Query("select c from Cliente c "
+ " where "
+ " c.negativar = true" )
List<Cliente> findClients();