-
Notifications
You must be signed in to change notification settings - Fork 8
/
ExpressionProtocol.java
74 lines (55 loc) · 1.7 KB
/
ExpressionProtocol.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
66
67
68
69
70
71
72
73
74
/*******************************************************************************
* Copyright (c) 2020 ArSysOp
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0/.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* ArSysOp - initial API and implementation
*******************************************************************************/
package org.eclipse.passage.lic.internal.api.conditions.evaluation;
import java.util.Objects;
import org.eclipse.passage.lic.internal.api.registry.ServiceId;
public abstract class ExpressionProtocol implements ServiceId {
private final String identifier;
protected ExpressionProtocol(String identifier) {
Objects.requireNonNull(identifier, "ExpressionProtocol::identifier"); //$NON-NLS-1$
this.identifier = identifier.trim().toLowerCase();
}
public final String identifier() {
return identifier;
}
@Override
public final int hashCode() {
return Objects.hash(identifier());
}
@Override
public final boolean equals(Object object) {
if (!ExpressionProtocol.class.isInstance(object)) {
return false;
}
return identifier.equals(((ExpressionProtocol) object).identifier);
}
@Override
public final String toString() {
return identifier;
}
public static final class Ands extends ExpressionProtocol {
public Ands() {
super("ands"); //$NON-NLS-1$
}
}
public static final class Default extends ExpressionProtocol {
public Default() {
super(new Ands().identifier());
}
}
public static final class Of extends ExpressionProtocol {
public Of(String identifier) {
super(identifier);
}
}
}