Skip to content

Commit

Permalink
[#1453] Evolve raw string identifier to semantic entity
Browse files Browse the repository at this point in the history
Rework `String` feature identifier to a dedicated type
`FeatureIdentifier`
  • Loading branch information
ruspl-afed authored and eparovyshnaya committed Nov 12, 2024
1 parent 2639cae commit 5946a1d
Show file tree
Hide file tree
Showing 74 changed files with 545 additions and 365 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2021 ArSysOp
* Copyright (c) 2020, 2024 ArSysOp
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -9,13 +9,15 @@
*
* Contributors:
* ArSysOp - initial API and implementation
* ArSysOp - further support and improvements
*******************************************************************************/
package org.eclipse.passage.ldc.internal.pde.core.templates;

import java.util.function.Supplier;

import org.eclipse.passage.lic.api.requirements.Requirement;
import org.eclipse.passage.lic.api.restrictions.RestrictionLevel;
import org.eclipse.passage.lic.base.BaseFeatureIdentifier;
import org.eclipse.passage.lic.base.requirements.BaseFeature;
import org.eclipse.passage.lic.base.requirements.BaseRequirement;

Expand All @@ -38,7 +40,7 @@ public DefaultProductRequirement(Supplier<String> product, Supplier<String> name
public Requirement get() {
return new BaseRequirement(//
new BaseFeature(//
product.get(), //
new BaseFeatureIdentifier(product.get()), //
version.get(), //
name.get(), //
provider.get()), //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2021 ArSysOp
* Copyright (c) 2020, 2024 ArSysOp
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -9,13 +9,15 @@
*
* Contributors:
* ArSysOp - initial API and implementation
* ArSysOp - further support and improvements
*******************************************************************************/
package org.eclipse.passage.ldc.internal.pde.ui.templates.fullfeather;

import java.util.function.Supplier;

import org.eclipse.passage.lic.api.requirements.Requirement;
import org.eclipse.passage.lic.api.restrictions.RestrictionLevel;
import org.eclipse.passage.lic.base.BaseFeatureIdentifier;
import org.eclipse.passage.lic.base.requirements.BaseFeature;
import org.eclipse.passage.lic.base.requirements.BaseRequirement;

Expand All @@ -25,7 +27,7 @@ public final class AntimagicShieldFeatureLicRequirement implements Supplier<Requ
public Requirement get() {
return new BaseRequirement(//
new BaseFeature(//
"antimagic-shield", //$NON-NLS-1$
new BaseFeatureIdentifier("antimagic-shield"), //$NON-NLS-1$
"2.72", //$NON-NLS-1$
"Antimagic protection", //$NON-NLS-1$
"Passage E4FF Template"), //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*******************************************************************************
* Copyright (c) 2024 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.api;

/**
* Identifies a feature under license protection
*
* @see Passage#canUse(FeatureIdentifier)
* @see Passage#acquireLicense(FeatureIdentifier)
*
* @since 4.0
*/
public interface FeatureIdentifier {

String identifier();

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2021 ArSysOp
* Copyright (c) 2020, 2024 ArSysOp
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -9,6 +9,7 @@
*
* Contributors:
* ArSysOp - initial API and implementation
* ArSysOp - further support and improvements
*******************************************************************************/
package org.eclipse.passage.lic.api;

Expand Down Expand Up @@ -46,12 +47,13 @@ public interface Passage {
* {@code feature} code to let others use the license after you don't need it.
* </p>
*
* @param feature string identifier of the feature under licensing.
* @param feature identifier of the feature under licensing.
*
* @see org.eclipse.passage.lic.api
* @see Passage#releaseLicense(ExaminationCertificate)
* @since 4.0
*/
ServiceInvocationResult<GrantLockAttempt> acquireLicense(String feature);
ServiceInvocationResult<GrantLockAttempt> acquireLicense(FeatureIdentifier feature);

/**
* <p>
Expand Down Expand Up @@ -101,16 +103,17 @@ public interface Passage {
* control flow.
* </p>
*
* @param feature string identifier of the feature under licensing.
* @param feature identifier of the feature under licensing.
* @return {@code true} if the given {@code feature} can be used and
* {@code false} otherwise
*
* @see Requirement
* @see Restriction
* @see RestrictionLevel
* @see org.eclipse.passage.lic.api
* @since 4.0
*/
boolean canUse(String feature);
boolean canUse(FeatureIdentifier feature);

/**
* Examines all the requirements against all the permissions and summarizes the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2021 ArSysOp
* Copyright (c) 2020, 2024 ArSysOp
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -9,6 +9,7 @@
*
* Contributors:
* ArSysOp - initial API and implementation
* ArSysOp - further support and improvements
*******************************************************************************/
package org.eclipse.passage.lic.api;

Expand Down Expand Up @@ -53,8 +54,9 @@ public interface PassageUI {
* for the {@code feature} utilization. Returns {@code false} if
* existing coverage is not enough and the end user failed to improve
* it.
* @since 4.0
*/
ServiceInvocationResult<GrantLockAttempt> acquireLicense(String feature);
ServiceInvocationResult<GrantLockAttempt> acquireLicense(FeatureIdentifier feature);

/**
* Assess the whole product licensing coverage.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2021 ArSysOp
* Copyright (c) 2020, 2024 ArSysOp
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -9,11 +9,14 @@
*
* Contributors:
* ArSysOp - initial API and implementation
* ArSysOp - further support and improvements
*******************************************************************************/
package org.eclipse.passage.lic.api.acquire;

import java.util.Date;

import org.eclipse.passage.lic.api.FeatureIdentifier;

/**
*
* @since 2.1
Expand All @@ -24,7 +27,10 @@ public interface GrantAcquisition {

String grant();

String feature();
/**
* @since 4.0
*/
FeatureIdentifier feature();

String user();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2021 ArSysOp
* Copyright (c) 2020, 2024 ArSysOp
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -9,9 +9,11 @@
*
* Contributors:
* ArSysOp - initial API and implementation
* ArSysOp - further support and improvements
*******************************************************************************/
package org.eclipse.passage.lic.api.acquire;

import org.eclipse.passage.lic.api.FeatureIdentifier;
import org.eclipse.passage.lic.api.LicensedProduct;
import org.eclipse.passage.lic.api.ServiceInvocationResult;
import org.eclipse.passage.lic.api.conditions.ConditionMiningTarget;
Expand All @@ -23,7 +25,10 @@
*/
public interface LicenseAcquisitionService extends Service<ConditionMiningTarget> {

ServiceInvocationResult<GrantAcquisition> acquire(LicensedProduct product, String feature);
/**
* @since 4.0
*/
ServiceInvocationResult<GrantAcquisition> acquire(LicensedProduct product, FeatureIdentifier feature);

ServiceInvocationResult<Boolean> release(LicensedProduct product, GrantAcquisition acquisition);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2021 ArSysOp
* Copyright (c) 2020, 2024 ArSysOp
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -9,10 +9,12 @@
*
* Contributors:
* ArSysOp - initial API and implementation
* ArSysOp - further support and improvements
*******************************************************************************/
package org.eclipse.passage.lic.api.conditions;

import org.eclipse.passage.lic.api.EvaluationInstructions;
import org.eclipse.passage.lic.api.FeatureIdentifier;

/**
* <p>
Expand All @@ -38,8 +40,9 @@ public interface Condition {

/**
* @return unique identifier of a feature under licensing.
* @since 4.0
*/
String feature();
FeatureIdentifier feature();

/**
* Define the actual {@code version} representing string that has been mined in
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2021 ArSysOp
* Copyright (c) 2020, 2024 ArSysOp
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -9,9 +9,12 @@
*
* Contributors:
* ArSysOp - initial API and implementation
* ArSysOp - further support and improvements
*******************************************************************************/
package org.eclipse.passage.lic.api.requirements;

import org.eclipse.passage.lic.api.FeatureIdentifier;

/**
* <p>
* Describes a <i> feature under licensing</i> in context of access cycle.
Expand All @@ -37,9 +40,11 @@ public interface Feature {
String version();

/**
* Id of the feature under licensing
* Identifier of the feature under licensing
*
* @since 4.0
*/
String identifier();
FeatureIdentifier identifier();

/**
* Freely named provider of the feature
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*******************************************************************************
* Copyright (c) 2024 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.base;

import org.eclipse.passage.lic.api.FeatureIdentifier;

/**
* Base implementation for {@link FeatureIdentifier}
*
* @since 4.0
*/
public record BaseFeatureIdentifier(String identifier) implements FeatureIdentifier {

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2021 ArSysOp
* Copyright (c) 2020, 2024 ArSysOp
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -9,9 +9,11 @@
*
* Contributors:
* ArSysOp - initial API and implementation
* ArSysOp - further support and improvements
*******************************************************************************/
package org.eclipse.passage.lic.base;

import org.eclipse.passage.lic.api.FeatureIdentifier;
import org.eclipse.passage.lic.api.LicensedProduct;
import org.eclipse.passage.lic.api.Passage;
import org.eclipse.passage.lic.api.ServiceInvocationResult;
Expand All @@ -31,7 +33,7 @@ public BasePassage(FrameworkAware delegate) {
}

@Override
public boolean canUse(String feature) {
public boolean canUse(FeatureIdentifier feature) {
return delegate.withFramework(framework -> new Access(framework).canUse(feature)).orElse(Boolean.FALSE);
}

Expand All @@ -41,7 +43,7 @@ public ServiceInvocationResult<ExaminationCertificate> assess() {
}

@Override
public ServiceInvocationResult<GrantLockAttempt> acquireLicense(String feature) {
public ServiceInvocationResult<GrantLockAttempt> acquireLicense(FeatureIdentifier feature) {
return delegate.withFrameworkService(framework -> new Access(framework).acquire(feature));
}

Expand Down
Loading

0 comments on commit 5946a1d

Please sign in to comment.