@Override public final String toString() { /* * The toStringCache is safe, since the object contract requires * immutability of the object and all objects referenced from this * object. * Used lists, maps are immutable. Path Arguments (elements) are also * immutable, since the PathArgument contract requires immutability. * The cache is thread-safe - if multiple computations occurs at the * same time, cache will be overwritten with same result. */ String ret = toStringCache; if (ret == null) { final StringBuilder builder = new StringBuilder("/"); PathArgument prev = null; for (PathArgument argument : getPathArguments()) { if (prev != null) { builder.append('/'); } builder.append(argument.toRelativeString(prev)); prev = argument; } ret = builder.toString(); TOSTRINGCACHE_UPDATER.lazySet(this, ret); } return ret; }
@Override public final String toString() { /* * The toStringCache is safe, since the object contract requires * immutability of the object and all objects referenced from this * object. * Used lists, maps are immutable. Path Arguments (elements) are also * immutable, since the PathArgument contract requires immutability. * The cache is thread-safe - if multiple computations occurs at the * same time, cache will be overwritten with same result. */ String ret = toStringCache; if (ret == null) { final StringBuilder builder = new StringBuilder("/"); PathArgument prev = null; for (PathArgument argument : getPathArguments()) { if (prev != null) { builder.append('/'); } builder.append(argument.toRelativeString(prev)); prev = argument; } ret = builder.toString(); TOSTRINGCACHE_UPDATER.lazySet(this, ret); } return ret; }