Module com.speedment.common.codegen
Package com.speedment.common.codegen
Interface DependencyManager
-
public interface DependencyManagerKeeps track of which dependencies have been imported and which is not included. This is useful for solving the issue of when to write the full name of a class and when to only include the short name.- Since:
- 2.0
- Author:
- Emil Forslund
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclearDependencies()Clear all dependencies.static DependencyManagercreate()Creates and returns a new default DependencyManager.static DependencyManagercreate(Pattern... ignoredPatterns)Creates and returns a new default DependencyManager.Optional<String>getCurrentPackage()Returns the current package if one is set, or elseempty.booleanisIgnored(String fullname)Returns true if the specified class belongs to a package that is on the ignore list.booleanisLoaded(String fullname)Returnstrueif the specified fullname is either:booleanload(String fullname)Attempts to add the specified resource to the dependency list.booleansetCurrentPackage(String pack)Attempts to set the package that is currently being rendered.booleanunsetCurrentPackage(String pack)Attempts to unset the currently rendered package.
-
-
-
Method Detail
-
load
boolean load(String fullname)
Attempts to add the specified resource to the dependency list. If the name is already taken it will returnfalse.- Parameters:
fullname- the full name of the resource.- Returns:
trueif it was added, elsefalse
-
isLoaded
boolean isLoaded(String fullname)
Returnstrueif the specified fullname is either:(A) loaded into the dependency list; (B) on the ignore list.Else it returnsfalse.- Parameters:
fullname- the full name of the resource.- Returns:
trueif it don't have to be loaded.
-
isIgnored
boolean isIgnored(String fullname)
Returns true if the specified class belongs to a package that is on the ignore list.- Parameters:
fullname- the full name of a package or a class- Returns:
trueif it should be ignored as a dependency
-
clearDependencies
void clearDependencies()
Clear all dependencies.
-
setCurrentPackage
boolean setCurrentPackage(String pack)
Attempts to set the package that is currently being rendered. If a package is already set, the operation will fail andfalsewill be returned. If the operation succeeded,trueis returned and theDependencyManagerwill expectunsetCurrentPackage(java.lang.String)to be called later before the generation is finished.- Parameters:
pack- the new current package- Returns:
trueif the operation succeeded, elsefalse
-
unsetCurrentPackage
boolean unsetCurrentPackage(String pack)
Attempts to unset the currently rendered package. If the specified package is the one that is currently being rendered, it will be unset andtruewill be returned. If the package specified is not correct, the current package will not be unset andfalsewill be returned. If no package was set the operation will throw anIllegalStateException.- Parameters:
pack- the current package to unset- Returns:
trueif the operation succeeded, elsefalse
-
getCurrentPackage
Optional<String> getCurrentPackage()
Returns the current package if one is set, or elseempty.- Returns:
- the package
-
create
static DependencyManager create()
Creates and returns a new default DependencyManager.- Returns:
- a new default DependencyManager
-
create
static DependencyManager create(Pattern... ignoredPatterns)
Creates and returns a new default DependencyManager.- Parameters:
ignoredPatterns- to add to the ignore list- Returns:
- a new default DependencyManager
- Throws:
NullPointerException- if the providedignoredPatternisnull.
-
-