![JAR search and dependency download from the Maven repository](/logo.png)
de.is24.deadcode4j.IntermediateResults Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of deadcode4j-maven-plugin Show documentation
Show all versions of deadcode4j-maven-plugin Show documentation
Finds unused classes of a project
package de.is24.deadcode4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import static com.google.common.collect.Maps.newHashMap;
import static com.google.common.collect.Sets.newHashSet;
/**
* Instances of IntermediateResults
are used to keep track of and calculate the {@link IntermediateResult}s
* produced by and being made available to {@link AnalysisContext} instances, respectively.
*
* @since 2.0.0
*/
public final class IntermediateResults {
@Nonnull
private final Logger logger = LoggerFactory.getLogger(getClass());
@Nonnull
private final Map> intermediateResults = newHashMap();
public IntermediateResults() {
}
/**
* Returns an IntermediateResultSet
for the given Set
.
* This method is defined for type inference, as it could simply be replaced with a constructor call.
*
* @since 2.0.0
*/
@Nonnull
public static IntermediateResultSet resultSetFor(@Nonnull Collection intermediateResults) {
return new IntermediateResultSet(intermediateResults);
}
/**
* Returns an IntermediateResultMap
for the given Map
.
* This method is defined for type inference, as it could simply be replaced with a constructor call.
*
* @since 2.0.0
*/
@Nonnull
public static IntermediateResultMap resultMapFor(@Nonnull Map intermediateResults) {
return new IntermediateResultMap(intermediateResults);
}
/**
* Returns an IntermediateResultSet
from the given AnalysisContext
for the given key.
* This method is defined to handle the unchecked cast to a typed IntermediateResultSet
,
* it could simply be replaced with {@link AnalysisContext#getIntermediateResult(Object)}.
*
* @since 2.0.0
*/
@Nullable
@SuppressWarnings("unchecked")
public static IntermediateResultSet resultSetFrom(@Nonnull AnalysisContext analysisContext, Object key) {
return (IntermediateResultSet) analysisContext.getIntermediateResult(key);
}
/**
* Returns an IntermediateResultMap
from the given AnalysisContext
for the given key.
* This method is defined to handle the unchecked cast to a typed IntermediateResultMap
,
* it could simply be replaced with {@link AnalysisContext#getIntermediateResult(Object)}.
*
* @since 2.0.0
*/
@Nullable
@SuppressWarnings("unchecked")
public static IntermediateResultMap resultMapFrom(@Nonnull AnalysisContext analysisContext, Object key) {
return (IntermediateResultMap) analysisContext.getIntermediateResult(key);
}
/**
* Adds the intermediate results of the given analysis context's cache.
*
* @since 2.0.0
*/
public void add(@Nonnull AnalysisContext analysisContext) {
intermediateResults.put(analysisContext.getModule(), getIntermediateResultsOf(analysisContext));
}
/**
* Calculates the intermediate results being available for the specified module.
*
* @since 2.0.0
*/
@Nonnull
public Map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy