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<>(before);
create.removeAll(after);
Set delete = new HashSet<>(after);
delete.removeAll(before);
Set leave = new HashSet<>(before);
leave.removeAll(create);
return new SetIntersection(before, after, create, delete, leave);
}
}