Skip to content

Commit

Permalink
Merge pull request yahoo#478 from yahoo/adding-ddi-support
Browse files Browse the repository at this point in the history
Adding prefabricated check
  • Loading branch information
Dennis McWherter authored Jun 15, 2017
2 parents 4e17f1a + 52d1448 commit a4e1866
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.yahoo.elide.security.PersistentResource;
import com.yahoo.elide.security.RequestScope;
import com.yahoo.elide.security.checks.CommitCheck;

import java.util.Optional;

/**
Expand All @@ -34,4 +33,16 @@ public boolean ok(T record, RequestScope requestScope, Optional<ChangeSpec> chan
return false;
}
}

/**
* A check that enables Only teh removal of an object from a relationship.
* @param <T> the type of object that this check guards
*/
public static class FieldSetToNull<T> extends CommitCheck<T> {
@Override
public boolean ok(T record, RequestScope requestScope, Optional<ChangeSpec> changeSpec) {
return changeSpec.map((c) -> { return c.getOriginal() != null && c.getModified() == null; })
.orElse(false);
}
}
}

0 comments on commit a4e1866

Please sign in to comment.