-
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.
Bug 565656 API revision | restriction execution
The decision has been taken to exclude restriction execution from access cycle and redesign it to a developer's set of facilities for `Diagnostic` and `ExaminationCertificate` analysis as well as for performing a set of predefining restrictive actions. All access cycle related interfaces of this sort are removed from 1.0.0 API. Signed-off-by: elena.parovyshnaya <elena.parovyshnaya@gmail.com>
- Loading branch information
1 parent
bd666ed
commit dc88844
Showing
28 changed files
with
338 additions
and
302 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
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
28 changes: 28 additions & 0 deletions
28
....lic.api/src/org/eclipse/passage/lic/internal/api/restrictions/RestrictionComparator.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,28 @@ | ||
/******************************************************************************* | ||
* 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.restrictions; | ||
|
||
import java.util.Comparator; | ||
|
||
public final class RestrictionComparator implements Comparator<Restriction> { | ||
|
||
@Override | ||
public int compare(Restriction left, Restriction right) { | ||
return new RestrictionLevelComparator().compare(level(left), level(right)); | ||
} | ||
|
||
private RestrictionLevel level(Restriction restriction) { | ||
return restriction.unsatisfiedRequirement().restrictionLevel(); | ||
} | ||
|
||
} |
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
40 changes: 40 additions & 0 deletions
40
...api/src/org/eclipse/passage/lic/internal/api/restrictions/RestrictionLevelComparator.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,40 @@ | ||
/******************************************************************************* | ||
* 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.restrictions; | ||
|
||
import java.util.Comparator; | ||
|
||
public final class RestrictionLevelComparator implements Comparator<RestrictionLevel> { | ||
|
||
@Override | ||
public int compare(RestrictionLevel left, RestrictionLevel right) { | ||
return Integer.compare(weight(left), weight(right)); | ||
} | ||
|
||
private int weight(RestrictionLevel level) { | ||
if (new RestrictionLevel.Info().equals(level)) { | ||
return 1; | ||
} | ||
if (new RestrictionLevel.Warning().equals(level)) { | ||
return 2; | ||
} | ||
if (new RestrictionLevel.Error().equals(level)) { | ||
return 3; | ||
} | ||
if (new RestrictionLevel.Fatal().equals(level)) { | ||
return 4; | ||
} | ||
return 10; | ||
} | ||
|
||
} |
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
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
31 changes: 31 additions & 0 deletions
31
.../src/org/eclipse/passage/lic/internal/base/restrictions/RestrictionMustStopExecution.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,31 @@ | ||
/******************************************************************************* | ||
* 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.base.restrictions; | ||
|
||
import java.util.function.Predicate; | ||
|
||
import org.eclipse.passage.lic.internal.api.restrictions.Restriction; | ||
import org.eclipse.passage.lic.internal.api.restrictions.RestrictionLevel; | ||
import org.eclipse.passage.lic.internal.api.restrictions.RestrictionLevelComparator; | ||
|
||
public final class RestrictionMustStopExecution implements Predicate<Restriction> { | ||
|
||
@Override | ||
public boolean test(Restriction restriction) { | ||
return new RestrictionLevelComparator().compare(// | ||
new RestrictionLevel.Error(), // | ||
restriction.unsatisfiedRequirement().restrictionLevel())// | ||
<= 0; | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
...e/src/org/eclipse/passage/lic/internal/base/restrictions/WorstRestrictionsPerFeature.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,53 @@ | ||
/******************************************************************************* | ||
* 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.base.restrictions; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.function.Supplier; | ||
import java.util.stream.Collectors; | ||
|
||
import org.eclipse.passage.lic.internal.api.restrictions.Restriction; | ||
import org.eclipse.passage.lic.internal.api.restrictions.RestrictionComparator; | ||
|
||
public final class WorstRestrictionsPerFeature implements Supplier<Collection<Restriction>> { | ||
|
||
private final Collection<Restriction> restrictions; | ||
|
||
public WorstRestrictionsPerFeature(Collection<Restriction> restrictions) { | ||
this.restrictions = restrictions; | ||
} | ||
|
||
@Override | ||
public Collection<Restriction> get() { | ||
Map<String, List<Restriction>> featured = restrictions.stream()// | ||
.collect(Collectors.groupingBy(r -> r.unsatisfiedRequirement().feature().identifier())); | ||
return featured.values().stream()// | ||
.map(this::worst) // | ||
.collect(Collectors.toSet()); | ||
} | ||
|
||
private Restriction worst(List<Restriction> source) { | ||
return sorted(source).get(source.size() - 1); | ||
} | ||
|
||
private List<Restriction> sorted(Collection<Restriction> source) { | ||
List<Restriction> sorted = new ArrayList<>(source); | ||
Collections.sort(sorted, new RestrictionComparator()); | ||
return sorted; | ||
} | ||
|
||
} |
Oops, something went wrong.