Skip to content

Commit

Permalink
Bug 575447 Requirement declaration should be able to reference
Browse files Browse the repository at this point in the history
agreements

extend Requirement implementation with optional collection of agreement
files reference

Signed-off-by: eparovyshnaya <[email protected]>
  • Loading branch information
eparovyshnaya committed Aug 17, 2021
1 parent 59a3307 commit b52eca2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*******************************************************************************/
package org.eclipse.passage.lic.api.requirements;

import java.util.List;

import org.eclipse.passage.lic.api.restrictions.RestrictionLevel;

/**
Expand Down Expand Up @@ -39,6 +41,13 @@ public interface Requirement {
*/
RestrictionLevel restrictionLevel();

/**
* @return not-null, can be empty list of bundle-local paths to license
* agreement content files, that a user must actively accept to be
* allowed to use the feature
*/
List<String> agreement();

/**
* The original physical source under the program installation, where this
* requirement has been read from by some {@code ResolvedRequirements} service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*******************************************************************************/
package org.eclipse.passage.lic.base.requirements;

import java.util.Collections;
import java.util.List;
import java.util.Objects;

import org.eclipse.passage.lic.api.requirements.Feature;
Expand All @@ -27,18 +29,25 @@ public final class BaseRequirement implements Requirement {

private final Feature feature;
private final RestrictionLevel restriction;
private final List<String> agreements;
private final Object source;

public BaseRequirement(Feature feature, RestrictionLevel restriction, Object source) {
public BaseRequirement(Feature feature, RestrictionLevel restriction, List<String> agreements, Object source) {
Objects.requireNonNull(feature, "Feature cannot be null on requirement definition"); //$NON-NLS-1$
Objects.requireNonNull(restriction,
"Restriction cannot be null on requirement definition. Use DefaultrestrictionLevel should the need arise"); //$NON-NLS-1$
Objects.requireNonNull(agreements, "Agreements collection cannot be null, but can be empty"); //$NON-NLS-1$
Objects.requireNonNull(source, "Source is mandatory for requirement definition"); //$NON-NLS-1$
this.feature = feature;
this.restriction = restriction;
this.agreements = agreements;
this.source = source;
}

public BaseRequirement(Feature feature, RestrictionLevel restriction, Object source) {
this(feature, restriction, Collections.emptyList(), source);
}

@Override
public Feature feature() {
return feature;
Expand Down Expand Up @@ -77,4 +86,9 @@ public String toString() {
", source=" + source + "]"; //$NON-NLS-1$ //$NON-NLS-2$
}

@Override
public List<String> agreement() {
return agreements;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
*******************************************************************************/
package org.eclipse.passage.lic.api.tests.fakes.requirements;

import java.util.Collections;
import java.util.List;

import org.eclipse.passage.lic.api.requirements.Feature;
import org.eclipse.passage.lic.api.requirements.Requirement;
import org.eclipse.passage.lic.api.restrictions.RestrictionLevel;
Expand Down Expand Up @@ -48,6 +51,11 @@ public RestrictionLevel restrictionLevel() {
return level;
}

@Override
public List<String> agreement() {
return Collections.emptyList();
}

@Override
public Object source() {
return "API Tests"; //$NON-NLS-1$
Expand Down

0 comments on commit b52eca2

Please sign in to comment.