Skip to content

Commit

Permalink
mark new cycle API as EXPERIMENTAL
Browse files Browse the repository at this point in the history
This gives us the chance to easier break it if necessary, in case we find some really bad oversight somewhere.

Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
  • Loading branch information
codecholeric committed Aug 25, 2023
1 parent 4d78307 commit 2a4e015
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.tngtech.archunit.PublicAPI;

import static com.tngtech.archunit.PublicAPI.State.EXPERIMENTAL;
import static com.tngtech.archunit.PublicAPI.Usage.ACCESS;

/**
Expand All @@ -29,12 +30,12 @@
*
* @param <EDGE> The type of the edges forming the cycle
*/
@PublicAPI(usage = ACCESS)
@PublicAPI(usage = ACCESS, state = EXPERIMENTAL)
public interface Cycle<EDGE extends Edge<?>> {

/**
* @return The edges of the {@link Cycle}
*/
@PublicAPI(usage = ACCESS)
@PublicAPI(usage = ACCESS, state = EXPERIMENTAL)
List<EDGE> getEdges();
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@

import com.tngtech.archunit.PublicAPI;

import static com.tngtech.archunit.PublicAPI.State.EXPERIMENTAL;
import static com.tngtech.archunit.PublicAPI.Usage.ACCESS;

/**
* @see #detectCycles(Collection, Collection)
*/
@PublicAPI(usage = ACCESS)
@PublicAPI(usage = ACCESS, state = EXPERIMENTAL)
public final class CycleDetector {
private CycleDetector() {
}
Expand All @@ -51,7 +52,7 @@ private CycleDetector() {
* @param edges The edges connecting the nodes of the graph
* @return All cycles within the graph created from the passed nodes and edges.
*/
@PublicAPI(usage = ACCESS)
@PublicAPI(usage = ACCESS, state = EXPERIMENTAL)
public static <NODE, EDGE extends Edge<NODE>> Cycles<EDGE> detectCycles(Collection<NODE> nodes, Collection<EDGE> edges) {
Graph<NODE, EDGE> graph = new Graph<>();
graph.addNodes(nodes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@

import com.tngtech.archunit.PublicAPI;

import static com.tngtech.archunit.PublicAPI.State.EXPERIMENTAL;
import static com.tngtech.archunit.PublicAPI.Usage.ACCESS;

@PublicAPI(usage = ACCESS)
@PublicAPI(usage = ACCESS, state = EXPERIMENTAL)
public interface Cycles<EDGE extends Edge<?>> extends Collection<Cycle<EDGE>> {

/**
Expand All @@ -31,6 +32,6 @@ public interface Cycles<EDGE extends Edge<?>> extends Collection<Cycle<EDGE>> {
* The maximum number of cycles at which the algorithm will stop can be configured by the {@code archunit.properties}
* property {@value CycleConfiguration#MAX_NUMBER_OF_CYCLES_TO_DETECT_PROPERTY_NAME}.
*/
@PublicAPI(usage = ACCESS)
@PublicAPI(usage = ACCESS, state = EXPERIMENTAL)
boolean maxNumberOfCyclesReached();
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.tngtech.archunit.PublicAPI;

import static com.tngtech.archunit.PublicAPI.State.EXPERIMENTAL;
import static com.tngtech.archunit.PublicAPI.Usage.ACCESS;
import static com.tngtech.archunit.PublicAPI.Usage.INHERITANCE;

Expand All @@ -27,7 +28,7 @@ public interface Edge<NODE> {

NODE getTarget();

@PublicAPI(usage = ACCESS)
@PublicAPI(usage = ACCESS, state = EXPERIMENTAL)
static <N> Edge<N> create(N origin, N target) {
return new SimpleEdge<>(origin, target);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static com.google.common.collect.MultimapBuilder.hashKeys;
import static com.tngtech.archunit.PublicAPI.State.EXPERIMENTAL;
import static com.tngtech.archunit.PublicAPI.Usage.ACCESS;
import static com.tngtech.archunit.library.cycle_detection.CycleConfiguration.MAX_NUMBER_OF_CYCLES_TO_DETECT_PROPERTY_NAME;
import static com.tngtech.archunit.library.cycle_detection.rules.CycleRuleConfiguration.MAX_NUMBER_OF_DEPENDENCIES_TO_SHOW_PER_EDGE_PROPERTY_NAME;
Expand All @@ -63,7 +64,7 @@
*
* @param <COMPONENT> The type of the component to check dependencies between
*/
@PublicAPI(usage = ACCESS)
@PublicAPI(usage = ACCESS, state = EXPERIMENTAL)
public final class CycleArchCondition<COMPONENT> extends ArchCondition<COMPONENT> {
private static final Logger log = LoggerFactory.getLogger(CycleArchCondition.class);

Expand Down Expand Up @@ -297,12 +298,12 @@ private List<String> dependenciesDescription(ComponentDependency<COMPONENT> edge
}
}

@PublicAPI(usage = ACCESS)
@PublicAPI(usage = ACCESS, state = EXPERIMENTAL)
public static <COMPONENT> NeedsRetrieveClasses<COMPONENT> builder() {
return new Builder<>();
}

@PublicAPI(usage = ACCESS)
@PublicAPI(usage = ACCESS, state = EXPERIMENTAL)
public static final class Builder<COMPONENT> implements NeedsRetrieveClasses<COMPONENT>, NeedsRetrieveDescription<COMPONENT>, NeedsRetrieveOutgoingDependencies<COMPONENT> {
private Function<? super COMPONENT, Iterable<JavaClass>> retrieveClasses;
private Function<? super COMPONENT, String> retrieveDescription;
Expand Down Expand Up @@ -333,7 +334,7 @@ public Builder<COMPONENT> retrieveOutgoingDependenciesBy(Function<? super COMPON
/**
* @param relevantClassDependenciesPredicate A {@link Predicate} to decide which {@link Dependency dependencies} are relevant when checking for cycles
*/
@PublicAPI(usage = ACCESS)
@PublicAPI(usage = ACCESS, state = EXPERIMENTAL)
public Builder<COMPONENT> onlyConsiderDependencies(Predicate<? super Dependency> relevantClassDependenciesPredicate) {
this.relevantClassDependenciesPredicate = checkNotNull(relevantClassDependenciesPredicate);
return this;
Expand All @@ -342,36 +343,36 @@ public Builder<COMPONENT> onlyConsiderDependencies(Predicate<? super Dependency>
/**
* @return A new {@link CycleArchCondition}
*/
@PublicAPI(usage = ACCESS)
@PublicAPI(usage = ACCESS, state = EXPERIMENTAL)
public CycleArchCondition<COMPONENT> build() {
return new CycleArchCondition<>(retrieveClasses, retrieveDescription, retrieveOutgoingDependencies, relevantClassDependenciesPredicate);
}
}

@PublicAPI(usage = ACCESS)
@PublicAPI(usage = ACCESS, state = EXPERIMENTAL)
public interface NeedsRetrieveClasses<COMPONENT> {
/**
* @param retrieveClasses A {@link Function} to retrieve the contained {@link JavaClass classes} for any given {@code COMPONENT}
*/
@PublicAPI(usage = ACCESS)
@PublicAPI(usage = ACCESS, state = EXPERIMENTAL)
NeedsRetrieveDescription<COMPONENT> retrieveClassesBy(Function<? super COMPONENT, Iterable<JavaClass>> retrieveClasses);
}

@PublicAPI(usage = ACCESS)
@PublicAPI(usage = ACCESS, state = EXPERIMENTAL)
public interface NeedsRetrieveDescription<COMPONENT> {
/**
* @param retrieveDescription A {@link Function} to retrieve the description of a {@code COMPONENT}
*/
@PublicAPI(usage = ACCESS)
@PublicAPI(usage = ACCESS, state = EXPERIMENTAL)
NeedsRetrieveOutgoingDependencies<COMPONENT> retrieveDescriptionBy(Function<? super COMPONENT, String> retrieveDescription);
}

@PublicAPI(usage = ACCESS)
@PublicAPI(usage = ACCESS, state = EXPERIMENTAL)
public interface NeedsRetrieveOutgoingDependencies<COMPONENT> {
/**
* @param retrieveOutgoingDependencies A {@link Function} to retrieve the outgoing {@link Dependency dependencies} of a {@code COMPONENT}
*/
@PublicAPI(usage = ACCESS)
@PublicAPI(usage = ACCESS, state = EXPERIMENTAL)
Builder<COMPONENT> retrieveOutgoingDependenciesBy(Function<? super COMPONENT, Set<Dependency>> retrieveOutgoingDependencies);
}
}

0 comments on commit 2a4e015

Please sign in to comment.