velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Fedotov <a...@kayak.com>
Subject Re: Create an empty java.util.Set in VTL
Date Thu, 25 Jan 2018 16:44:29 GMT
You can probably use a hack with classloader. Along the lines of:

 #set($x =
"1".getClass().getClassloader().findClass("java.uti.HashSet").newInstance())

Alex


On Thu, Jan 25, 2018 at 11:30 AM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> All,
>
> If I want to create a new empty array/collection, I can do something
> like this:
>
> #set($array = [])
>
> If I want to create a new Map, I can do this:
>
> #set($map = {})
>
> Is there a way to create a new Set?
>
> I'd like to use a set because:
>
> 1. I want to use this object as a sort of scratch-area to know what
> work I've done before
>
> and
>
> 2. I'm going to be consulting it a lot using Set.contains(object) so
> something other than ArrayList/LinkedList will be much faster
>
> Thanks,
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iQJRBAEBCAA7FiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlpqBjsdHGNocmlzQGNo
> cmlzdG9waGVyc2NodWx0ei5uZXQACgkQHPApP6U8pFisIQ//VqqfK6GzyxnQZ9qK
> QvQREhkJoafg5X7n4d1M7pfG99qGTlGhrLXwO8YD0Qhpj0v7QKbJbi3LsjmwIVQT
> 4wvMXO7cBLXbB3bdc640ITylettTqKODTPk/KBIKq4nvSUVMGKvn/q/NlrZFX776
> 11SBC2VLcU7ujzaglL+F/xlF0C1ZS1UAFQlBVcRxT48C44dGOGSYVOu9UmYPvxpk
> 4ExrjKwkuTb6zsXn/Nwn1d/K7jB+Cqx77KDNOj0eBQK5POHZa/cC/W0z9uVdlUJg
> oVOwxITiEyTd2XmEFa1OjnU4yrZkU+N+wPzsFxgNwKzWSTC4CsBjIw2oSh4cOEqy
> gU7HRlCQMRhhBAYD6M7a8wvI60/UI/klb7aB1wOwt74A2/jtwx3M2mBKoYFYTx3X
> sfXS1lRtiXLtmooe50wHBvHBhvWXHkLE0dRETtgsLH/QiFgpG3xjoLPHkm6nL/60
> 4KJ5kt/a8afm1dBgcSc4Y6eXrAr0XQl9vREPfGWbcQs3h+azJ2L1leoEg2jnA3gh
> oytTF7HmuoX4cYqF1SLeLlMlRJdaAzayZYRwWeB739t7W7iRBzackNzTZyWfNqVD
> FRTv3vmsl477J9KI05rH7qlmowFL0QmwP6WeRPtOpQq8gDFKhRcGcoPXRtT6aXke
> VGfV9fj4L7nJBBUkOWtSfQU7WuY=
> =61WB
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message