-
Notifications
You must be signed in to change notification settings - Fork 214
/
Prohibition.java
65 lines (55 loc) · 1.74 KB
/
Prohibition.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* Copyright (c) 2020, 2021 Microsoft Corporation
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Microsoft Corporation - initial API and implementation
* Fraunhofer Institute for Software and Systems Engineering - added method
*
*/
package org.eclipse.edc.policy.model;
import static java.util.stream.Collectors.joining;
/**
* Disallows an action if its constraints are satisfied.
*/
public class Prohibition extends Rule {
@Override
public <R> R accept(Visitor<R> visitor) {
return visitor.visitProhibition(this);
}
@Override
public String toString() {
return "Prohibition constraints: [" + getConstraints().stream().map(Object::toString).collect(joining(",")) + "]";
}
/**
* Returns a copy of this prohibition with the specified target.
*
* @param target the target.
* @return a copy with the specified target.
*/
public Prohibition withTarget(String target) {
return Builder.newInstance()
.assigner(this.assigner)
.assignee(this.assignee)
.action(this.action)
.constraints(this.constraints)
.target(target)
.build();
}
public static class Builder extends Rule.Builder<Prohibition, Prohibition.Builder> {
private Builder() {
rule = new Prohibition();
}
public static Builder newInstance() {
return new Builder();
}
public Prohibition build() {
return rule;
}
}
}