Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package io.github.hkusu.example.lib.type;
- import android.support.annotation.NonNull;
- import java.util.LinkedHashSet;
- import java.util.Set;
- public class ImmutableSet<T> {
- private final Set<T> set = new LinkedHashSet<>();
- private ImmutableSet(@NonNull Set<T> set) {
- if (!set.isEmpty()) {
- this.set.addAll(set);
- }
- }
- public Set<T> snapshot() {
- final LinkedHashSet<T> set = new LinkedHashSet<>();
- if (!this.set.isEmpty()) {
- set.addAll(this.set);
- }
- return set;
- }
- public static <T> ImmutableSet<T> of(@NonNull Set<T> set) {
- return new ImmutableSet<>(set);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement