-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #245 from eclipse-passage/564328
Bug 564328 API revision | conditions | rethink key interfaces
- Loading branch information
Showing
10 changed files
with
389 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...clipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/Condition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/******************************************************************************* | ||
* 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; | ||
|
||
/** | ||
* <p> | ||
* Regarding each feature under licensing there is a series of statements in a | ||
* license of some kind. | ||
* </p> | ||
* <p> | ||
* These statements demands the feature to be used under curtain | ||
* {@code condition}s, such as "only version older than 2.14.1 on a workstation | ||
* under Windows OS with hard disk of serial AB0123C4DEFJHI and only for two | ||
* years starting from the 1st of May, 2020." {@code Condition} represents such | ||
* a bundle of demands. | ||
* </p> | ||
*/ | ||
public interface Condition { | ||
|
||
/** | ||
* @return unique identifier of a feature under licensing. | ||
*/ | ||
String feature(); | ||
|
||
/** | ||
* Define the actual {@code version} representing string that has been mined in | ||
* the scope of this condition (typically from license of sorts). | ||
* | ||
* @see VersionMatch | ||
*/ | ||
VersionMatch versionMatch(); | ||
|
||
/** | ||
* Period of this condition applicability. | ||
* | ||
* @see ValidityPeriod | ||
*/ | ||
ValidityPeriod validityPeriod(); | ||
|
||
/** | ||
* <p> | ||
* Defined how exactly the condition is to be evaluates. | ||
* </p> | ||
* <p> | ||
* Type of a license dictates how Passage can evaluate the condition (check if | ||
* all it's demands are met). For example, "hardware" license requires examining | ||
* of the actual workstation hardware. | ||
* </p> | ||
* | ||
* @see EvaluationInstructions | ||
*/ | ||
EvaluationInstructions evaluationInstructions(); | ||
} |
43 changes: 43 additions & 0 deletions
43
...e.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/EvaluationInstructions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/******************************************************************************* | ||
* 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; | ||
|
||
/** | ||
* <p> | ||
* Condition definition contains sufficient amount of instructions on how | ||
* exactly can we say if this condition is satisfied or not. | ||
* </p> | ||
* <p> | ||
* For example, condition of {@code hardware} type requires actual workstation | ||
* hardware evaluation and assessing it against condition's expectations. These | ||
* ones can demand particular hardware part of have predefined serial id. | ||
* </p> | ||
*/ | ||
public interface EvaluationInstructions { | ||
|
||
/** | ||
* Meta classifier of the way this condition can be evaluated | ||
* | ||
* @see EvaluationType | ||
*/ | ||
EvaluationType type(); | ||
|
||
/** | ||
* Precise data for evaluation. Each evaluation type can expect it's own format | ||
* here. | ||
* | ||
* @return raw string mined from a license | ||
*/ | ||
String expression(); | ||
|
||
} |
75 changes: 75 additions & 0 deletions
75
...e.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/EvaluationType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/******************************************************************************* | ||
* 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; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* <p> | ||
* Defines the way the condition will be evaluated in a running environment. For | ||
* example, "hardware" means that specially dedicated module is going to access | ||
* a workstation hardware in order to supply enough information to verify if the | ||
* condition is met. | ||
* </p> | ||
* <p> | ||
* Designed to be a <i>data-class</i>. | ||
* </p> | ||
*/ | ||
public abstract class EvaluationType { | ||
|
||
private final String identifier; | ||
|
||
protected EvaluationType(String identifier) { | ||
Objects.requireNonNull(identifier, "Identifier is mandatory for condition type"); //$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 (!EvaluationType.class.isInstance(object)) { | ||
return false; | ||
} | ||
return identifier.equals(((EvaluationType) object).identifier); | ||
} | ||
|
||
@Override | ||
public final String toString() { | ||
return identifier; | ||
} | ||
|
||
public static final class Hardware extends EvaluationType { | ||
|
||
public Hardware() { | ||
super("hardware"); //$NON-NLS-1$ | ||
} | ||
|
||
} | ||
|
||
public static final class Of extends EvaluationType { | ||
|
||
public Of(String identifier) { | ||
super(identifier); | ||
} | ||
|
||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
...pse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/MatchingRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/******************************************************************************* | ||
* 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; | ||
|
||
import org.eclipse.passage.lic.internal.api.requirements.Requirement; | ||
|
||
/** | ||
* <p> | ||
* Defines the way a two strings can be matched. | ||
* </p> | ||
* <p> | ||
* In scope of condition evaluation we find out if <i>version comes from | ||
* {@linkplain Requirement}</i> ({@code required}) {@code match} to version | ||
* definition string that comes from a license of source through | ||
* {@linkplain Condition} ({@code allowed}). | ||
* </p> | ||
* <p> | ||
* For example {@code perfect match} match rule would mean absolute equality. | ||
* </p> | ||
* | ||
* @see VersionMatch | ||
* @see Condition | ||
*/ | ||
public abstract interface MatchingRule { | ||
|
||
/** | ||
* Descriptive identifier of a rule. | ||
* | ||
* @return | ||
*/ | ||
String identifier(); | ||
|
||
/** | ||
* Find out if the {@code required} ({@code actual}) string {@code matches} with | ||
* the {@code allowed} one ({@code expected}). | ||
*/ | ||
boolean match(String required, String allowed); | ||
|
||
} |
Oops, something went wrong.