public class Sugar extends Object
| Constructor and Description |
|---|
Sugar() |
| Modifier and Type | Method and Description |
|---|---|
static <T> Iterable<T> |
in(Iterator<T> iterator)
Use this method to create a new style (java 1.5+) 'for' loop when some
old library method returns iterator.
|
static boolean |
matchesAny(String string,
Set<String> regexSet) |
static <T> T |
to(T t)
For documentation see
using(java.lang.Object). |
static <T> T |
using(T t)
Simple syntactic sugar to provide some reading information to the code.
|
public static <T> Iterable<T> in(Iterator<T> iterator)
for (final PGPSecretKeyRing kRing : in((Iterator(actual code was copied from License.java).) pgpSec .getKeyRings())) { ... }
T - note that you can not pass a raw Iterator. You have
to cast it to the specific generic type Iterator as in the example above.iterator - is 'converted'public static <T> T using(T t)
encode(licensePlain, using(signatureGenerator), to(outputStream));(actual code was copied from License.java).
to(java.lang.Object) is also a similar method.
Note that these methods increase the size of the VM code, but any modern Java implementation will optimize them off in the JIT phase.
T - t - argument to pass back on to the calledpublic static <T> T to(T t)
using(java.lang.Object).T - t - Copyright © 2015. All Rights Reserved.