Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto generate random long in IntelliJ Live Template

How do I auto generate an arbitrary number (Long) for use in a Live Template in IntelliJ?

Example:

public static final long uid = $randomLong$;

where randomLong is replaced with a random long value. I have tried adding the following as an expression for the variable on the live template definition but nothing is generated when the template outputs.

new Random().nextLong()

What I am trying to achieve is very similar to what the IDEA code inspector generates for the Serialization version UID field but with a live template.

like image 929
travega Avatar asked Mar 18 '23 22:03

travega


1 Answers

Please try adding groovyScript("new Random().nextLong()") as the variable expression instead.

like image 141
Peter Gromov Avatar answered Apr 05 '23 21:04

Peter Gromov