info.unterrainer.commons.jreutils.SetIntersection Maven / Gradle / Ivy
package info.unterrainer.commons.jreutils;
import java.util.HashSet;
import java.util.Set;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.experimental.SuperBuilder;
@Data
@RequiredArgsConstructor
@SuperBuilder()
public class SetIntersection {
private final Set before;
private final Set after;
private final Set create;
private final Set delete;
private final Set leave;
public static SetIntersection of(final Set before, final Set after) {
Set create = new HashSet<>(after);
create.removeAll(before);
Set delete = new HashSet<>(before);
delete.removeAll(after);
Set leave = new HashSet<>(after);
leave.removeAll(create);
return new SetIntersection<>(before, after, create, delete, leave);
}
}