Is there any possible way to set the compile time constant using the call method at runtime? In the book Spring in Action, I got this piece of code:
private static final String MAX_LONG_AS_STRING = Long.toString(Long.MAX_VALUE); @RequestMapping(method = RequestMethod.GET) public List<Spittle> spittles( @RequestParam(value = "max", defaultValue = MAX_LONG_AS_STRING) long max, @RequestParam(value = "count", defaultValue = "20") int count) { return spittleRepository.findSpittles(max, count); }
the problem is MAX_LONG_AS_STRING, because the defaultValue parameter must be a String constant, but MAX_LONG_AS_STRING is not a constant compile time variable, is there any possible way to get the Long max value as a constant String value? Maybe there is something that can help me call the toString method at compile time or get this value in any other way?
source share