@Override public C.Set<T> withIn(Collection<? extends T> col) { C.Set<T> others = C.newSet(col); others.retainAll(this); if (isImmutable()) { return ImmutableSet.of(others); } return others; }
public CorsSetting allowOrigin(String allowOrigin) { E.illegalArgumentIf(S.blank(allowOrigin), "allow origin cannot be empty"); this.allowOrigin = allowOrigin; return this; }
@Override public BufferedImage render(String text) { List<? extends Img.Processor> processors = $.random(true, false) ? optionalA : optionalB; return Img.source(backgroundGenerator) .text(text) .color(Img.Random.darkColor()) .makeNoise() .setMaxLines(2 + randInt(5)) .setMaxLineWidth(3) .pipeline(processors) .get(); }
@Override public C.Sequence<T> append(C.Sequence<? extends T> seq) { if (seq instanceof C.List) { return appendList((C.List<T>) seq); } if (isLazy()) { return CompositeSeq.of(this, seq); } ListBuilder<T> lb = new ListBuilder<T>(size() * 2); lb.append(this).append(seq); return lb.toList(); }
@Override public C.Set<T> onlyIn(Collection<? extends T> col) { C.Set<T> others = C.newSet(col); others.removeAll(this); if (isImmutable()) { return ImmutableSet.of(others); } return others; }
public FastStr encodeBASE64() { String s; try { s = Unsafe.stringOf(buf); } catch (Exception e) { s = toString(); } return unsafeOf(S.encodeBASE64(s)); }
static <T> C.List<T> wrap(java.util.List<T> list) { if (list instanceof C.List) { C.List<T> cl = (C.List<T>)list; if (cl.is(C.Feature.IMMUTABLE) && cl.isEmpty()) { return Nil.list(); } } if (list instanceof DelegatingList) { list = ((DelegatingList<T>)list).data; } return new DelegatingList<T>(list, true); }
@Override public C.Set<T> with(Collection<? extends T> col) { C.Set<T> copy = C.newSet(this); copy.addAll(col); if (isImmutable()) { return ImmutableSet.of(copy); } return copy; }
@Override public C.List<T> subList(int fromIndex, int toIndex) { if (fromIndex == toIndex) { return Nil.list(); } if (is(C.Feature.RANDOM_ACCESS)) { return new RandomAccessSubList<T>(this, fromIndex, toIndex); } else { return new SubList<T>(this, fromIndex, toIndex); } }
@Override public C.Set<T> without(Collection<? super T> col) { C.Set<T> copy = C.newSet(this); copy.removeAll(col); if (isImmutable()) { return ImmutableSet.of(copy); } return copy; }
@Override public C.Set<T> onlyIn(Collection<? extends T> col) { C.Set<T> others = C.newSet(col); others.removeAll(this); if (isImmutable()) { return ImmutableSet.of(others); } return others; }