Class Devon4jPackage
- java.lang.Object
-
- com.devonfw.module.basic.common.api.reflect.Devon4jPackage
-
public final class Devon4jPackage extends Object
This class represents aPackage
following the devonfw coding convetion.
After parsing aPackage
asDevon4jPackage
you can get individual parts/segments such ascompoent
,layer
,scope
, etc.
This is useful for advanced features and tools such as service clients and exception facades, code-generators, static-code-analyzers (SonarQube plugin), etc.- Author:
- hohwille
- See Also:
of(String)
,of(Package)
,of(Class)
-
-
Field Summary
Fields Modifier and Type Field Description static String
LAYER_BATCH
The batch layer.static String
LAYER_CLIENT
The client layer.static String
LAYER_COMMON
The common "layer" for cross-cutting code.static String
LAYER_DATA_ACCESS
The data-access layer.static String
LAYER_LOGIC
The logic layer.static String
LAYER_SERVICE
The service layer.static String
SCOPE_API
The scope for APIs.static String
SCOPE_BASE
The scope for reusable base implementations.static String
SCOPE_IMPL
The scope for implementations.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
String
getApplication()
String
getComponent()
String
getDetail()
String
getLayer()
String
getRoot()
String
getScope()
String
getSegment(int index)
int
getSegmentCount()
int
hashCode()
boolean
isLayerBatch()
boolean
isLayerClient()
boolean
isLayerCommon()
boolean
isLayerDataAccess()
boolean
isLayerLogic()
boolean
isLayerService()
boolean
isScopeApi()
boolean
isScopeBase()
boolean
isScopeImpl()
boolean
isValid()
boolean
isValidLayer()
boolean
isValidScope()
static Devon4jPackage
of(Class<?> type)
static Devon4jPackage
of(Package javaPackage)
static Devon4jPackage
of(String packageName)
static Devon4jPackage
of(String root, String application, String component, String layer, String scope, String detail)
String
toString()
-
-
-
Field Detail
-
LAYER_COMMON
public static final String LAYER_COMMON
The common "layer" for cross-cutting code.- See Also:
- Constant Field Values
-
LAYER_DATA_ACCESS
public static final String LAYER_DATA_ACCESS
The data-access layer.- See Also:
- Constant Field Values
-
LAYER_LOGIC
public static final String LAYER_LOGIC
The logic layer.- See Also:
- Constant Field Values
-
LAYER_SERVICE
public static final String LAYER_SERVICE
The service layer.- See Also:
- Constant Field Values
-
LAYER_BATCH
public static final String LAYER_BATCH
The batch layer.- See Also:
- Constant Field Values
-
LAYER_CLIENT
public static final String LAYER_CLIENT
The client layer. Please note that devonfw does not recommend to implement the client layer in Java.- See Also:
- Constant Field Values
-
SCOPE_API
public static final String SCOPE_API
The scope for APIs.- See Also:
- Constant Field Values
-
SCOPE_BASE
public static final String SCOPE_BASE
The scope for reusable base implementations.- See Also:
- Constant Field Values
-
SCOPE_IMPL
public static final String SCOPE_IMPL
The scope for implementations.- See Also:
- Constant Field Values
-
-
Method Detail
-
getSegmentCount
public int getSegmentCount()
- Returns:
- the number of
package segments
.
-
getSegment
public String getSegment(int index)
- Parameters:
index
- the position of the requested segment. A valid index is in the range from0
togetSegmentCount()
-1- Returns:
- the
Package
segment at the given index ornull
if the given index is invalid.
-
isValid
public boolean isValid()
- Returns:
true
if thisDevon4jPackage
is a valid according to devonfw package conventions",false
otherwise.
-
isValidScope
public boolean isValidScope()
-
isValidLayer
public boolean isValidLayer()
-
getRoot
public String getRoot()
- Returns:
- the root-
Package
of the organization or IT project owning the code.
-
getApplication
public String getApplication()
- Returns:
- the technical name of the application or (micro-)service.
-
getComponent
public String getComponent()
- Returns:
- the business component the code belongs to.
-
getLayer
public String getLayer()
- Returns:
- the layer the code is assigned to.
-
isLayerCommon
public boolean isLayerCommon()
- Returns:
true
iflayer
isLAYER_COMMON
.
-
isLayerDataAccess
public boolean isLayerDataAccess()
- Returns:
true
iflayer
isLAYER_DATA_ACCESS
.
-
isLayerLogic
public boolean isLayerLogic()
- Returns:
true
iflayer
isLAYER_LOGIC
.
-
isLayerService
public boolean isLayerService()
- Returns:
true
iflayer
isLAYER_SERVICE
.
-
isLayerBatch
public boolean isLayerBatch()
- Returns:
true
iflayer
isLAYER_BATCH
.
-
isLayerClient
public boolean isLayerClient()
- Returns:
true
iflayer
isLAYER_CLIENT
.
-
getScope
public String getScope()
- Returns:
- scope the scope the code is assigned to.
-
isScopeBase
public boolean isScopeBase()
- Returns:
true
ifscope
isSCOPE_BASE
.
-
isScopeImpl
public boolean isScopeImpl()
- Returns:
true
ifscope
isSCOPE_IMPL
.
-
getDetail
public String getDetail()
- Returns:
- the optional detail. Can be a single segment or multiple segments separated with dot. May be
null
.
-
of
public static Devon4jPackage of(String root, String application, String component, String layer, String scope, String detail)
- Parameters:
root
- - seegetRoot()
.application
- - seegetApplication()
.component
- - seegetComponent()
.layer
- - seegetLayer()
.scope
- - seegetScope()
.detail
- - seegetDetail()
.- Returns:
- the
Devon4jPackage
for the given parameters.
-
of
public static Devon4jPackage of(String packageName)
- Parameters:
packageName
- thepackage name
to parse.- Returns:
- the parsed
Devon4jPackage
corresponding to the given package.
-
of
public static Devon4jPackage of(Package javaPackage)
- Parameters:
javaPackage
- thePackage
to parse.- Returns:
- the parsed
Devon4jPackage
corresponding to the given package.
-
of
public static Devon4jPackage of(Class<?> type)
-
-