@Override public T getById(@Nonnull final Integer id) { synchronized (this) { return find(entities, new JPredicate<T>() { @Override public boolean apply(@Nullable T t) { return t != null && t.getId().equals(id); } }); } }
CalculatorFixableError(@Nullable String... messageCodes) { this.messageCodes = Collections.asList(messageCodes); }
public static <T> boolean contains(@Nonnull T value, @Nullable Collection<T> list) { return contains(value, FilterType.included, list); }
public LoopData(@Nullable Object... objects) { if (Collections.isEmpty(objects)) { this.length = (long) 0; } else { this.length = (long) objects.length; } }
public boolean remove(@Nonnull final WeakReference<L> reference) { return Collections.removeIf(references.iterator(), new JPredicate<ReferenceHolder<L>>() { @Override public boolean apply(@Nullable ReferenceHolder<L> referenceHolder) { return referenceHolder != null && referenceHolder.reference == reference; } }); }
@Nonnull static <T extends Comparable<T>> ArrayBinaryHeap<T> newArrayBinaryHeapWithHeight(int height) { return newArrayBinaryHeapWithHeight(height, Collections.<T>naturalComparator()); }
public static <T> void addUnique(@Nonnull List<T> list, @Nonnull List<T> list2) { for (T t : list2) { addUnique(list, t); } }
public static boolean notEmpty(@Nullable Collection<?> c) { return !isEmpty(c); }
@Override public void removeOwnChildIf(@Nonnull JPredicate<TreeNode<T>> predicate) { org.solovyev.common.collections.Collections.removeIf(this.children.iterator(), predicate); }
@Nonnull static <T extends Comparable> BinarySearchTree<T> newBinarySearchTree(@Nonnull BinarySearchTreeNode<T> root) { return new BinarySearchTree<T>(root, Collections.<T>naturalComparator()); }
@Nullable @Override public MutableTreeNode<T> findOwnChild(@Nonnull JPredicate<TreeNode<T>> finder) { return org.solovyev.common.collections.Collections.find(children.iterator(), finder); }
protected AbstractMessage(@Nonnull String messageCode, @Nonnull MessageLevel messageType, @Nullable Object... parameters) { this(messageCode, messageType, Collections.asList(parameters)); }
@Nonnull public static <T> List<T> asList(T... ts) { final List<T> result = new ArrayList<T>(); if (!Collections.isEmpty(ts)) { for (T t : ts) { result.add(t); } } return result; }
public static <T> boolean contains(@Nonnull T value, @Nullable Collection<T> list, @Nonnull Equalizer<T> equalizer) { return contains(value, list, FilterType.included, equalizer); }
@Override public boolean removeListener(@Nonnull final L listener) { synchronized (listeners) { if (referenceProducer instanceof HardReferenceProducer) { return Collections.removeIf(listeners.iterator(), new JPredicate<R>() { @Override public boolean apply(@Nullable R r) { final L l = r != null ? r.get() : null; boolean removed = listener.equals(l); if (removed) { // we must clean reference in order to avoid memory leak ((HardReferenceProducer) referenceProducer).remove((WeakReference) r); } return removed; } }); } else { return Collections.removeIf(listeners.iterator(), new ReferencePredicate<R, L>(listener)); } } }
@Nonnull static <T extends Comparable<T>> ArrayBinaryHeap<T> heapify(@Nonnull T[] array) { return heapify(array, Collections.<T>naturalComparator()); }
public static <T> boolean contains(@Nullable Collection<T> list, @Nonnull FilterType filterType, @Nonnull JPredicate<T> finder) { boolean found = find(list, finder) != null; final boolean result; if (filterType == FilterType.included) { result = found; } else { result = !found; } return result; }
MathType(@Nonnull Integer priority, boolean needMultiplicationSignBefore, boolean needMultiplicationSignAfter, @Nonnull MathGroupType groupType, @Nonnull List<String> tokens) { this.priority = priority; this.needMultiplicationSignBefore = needMultiplicationSignBefore; this.needMultiplicationSignAfter = needMultiplicationSignAfter; this.groupType = groupType; this.tokens = java.util.Collections.unmodifiableList(tokens); }
public LoopData(@Nullable Collection collection) { if (Collections.isEmpty(collection)) { this.length = (long) 0; } else { this.length = (long) collection.size(); } }
public static <T> boolean contains(@Nonnull T value, @Nullable T... array) { return contains(value, Arrays.asList(array)); }