Top Description Fields Constructors Methods
com.sun.codemodel

public Class JModule

extends Object
implements JGenerable, JAnnotatable, JDocCommentable
Class Inheritance
All Implemented Interfaces
com.sun.codemodel.JDocCommentable, com.sun.codemodel.JAnnotatable, com.sun.codemodel.JGenerable
Imports
java.io.BufferedWriter, .IOException, .PrintWriter, .Writer, java.lang.annotation.Annotation, java.util.ArrayList, .Collection, .Collections, .HashSet, .Iterator, .List, .Set

Represents a Java module.
Author
Tomas Kraus

Field Summary

Modifier and TypeField and Description
private List<JAnnotationUse>
annotations

Annotations on this JModule.

private final Set<JModuleDirective>
directives

Set of Java module directives.

private static final String
FILE_NAME

Java module file name.

private JDocComment
jdoc

javadoc comments for this JModule

private final String
name

Name of this module.

private final JCodeModel

Constructor Summary

AccessConstructor and Description
pack-priv
JModule(final String
Java module name. Value can not be null
name
)
Deprecated for removal since 4.0.7. use two args constructor

Creates an instance of Java module.

pack-priv
JModule(final String
Java module name. Value can not be null
name
,
JCodeModel
JCodeModel instance that owns this module.
owner
)

Creates an instance of Java module.

Method Summary

Modifier and TypeMethod and Description
public void
_exports(final JPackage
Java package to be exported.
pkg
)

Adds a package to the list of Java module exports.

public void
_exports(final Collection<JPackage>
Collection of packages to be added.
pkgs
,
final boolean
Adds also packages without any classes when true.
addEmpty
)

Adds packages to the list of Java module exports.

public void
_requires(final String
Name of required Java module.
name
,
final boolean
Use public modifier.
isPublic
,
final boolean
Use static modifier.
isStatic
)

Adds a module to the list of Java module requirements.

public void
_requires(final String
Name of required Java module.
name
)

Adds a module to the list of Java module requirements without public and static modifiers.

public void
_requires(final boolean
Use public modifier.
isPublic
,
final boolean
Use static modifier.
isStatic
,
final String...
Names of required Java module.
names
)

Adds all modules to the list of Java module requirements.

public void
_requires(final String...
Names of required Java module.
names
)

Adds all modules to the list of Java module requirements without public and static modifiers.

public JAnnotationUse
annotate(JClass clazz)

Implements com.sun.codemodel.JAnnotatable.annotate.

Adds an annotation to this program element.

public JAnnotationUse
annotate(Class<? extends Annotation> clazz)

Implements com.sun.codemodel.JAnnotatable.annotate.

Adds an annotation to this program element.

public <W extends JAnnotationWriter<? extends Annotation>> W
annotate2(Class<W> clazz)

Implements com.sun.codemodel.JAnnotatable.annotate2.

Adds an annotation to this program element and returns a type-safe writer to fill in the values of such annotations.

public Collection<JAnnotationUse>
annotations()

Implements com.sun.codemodel.JAnnotatable.annotations.

Read-only live view of all annotations on this

pack-priv void
build(final CodeWriter
Source code writer.
src
)

Build module-info.java source file.

private JFormatter

Returns:

New instance of module-info.java source writer.
createModuleInfoSourceFileWriter
(final CodeWriter src)

Create module-info.java source writer.

public void
generate(final JFormatter
Java code formatter.
f
)

Implements com.sun.codemodel.JGenerable.generate.

Print source code of Java Module declaration.

pack-priv Set<JModuleDirective>

Returns:

Module directives set.
getDirectives
()

Gets module directives set.

public JDocComment

Returns:

JDocComment containing javadocs for this class
javadoc
()

Implements com.sun.codemodel.JDocCommentable.javadoc.

Creates, if necessary, and returns the class javadoc for this JModule

public String

Returns:

name of this module.
name
()

Gets the name of this module.

public boolean
removeAnnotation(JAnnotationUse annotation)

Implements com.sun.codemodel.JAnnotatable.removeAnnotation.

Removes annotation from this program element.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

annotationsback to summary
private List<JAnnotationUse> annotations

Annotations on this JModule. Lazily created.

directivesback to summary
private final Set<JModuleDirective> directives

Set of Java module directives.

FILE_NAMEback to summary
private static final String FILE_NAME

Java module file name.

jdocback to summary
private JDocComment jdoc

javadoc comments for this JModule

nameback to summary
private final String name

Name of this module. Mandatory value. Shall not be null.

ownerback to summary
private final JCodeModel owner

Constructor Detail

JModuleback to summary
pack-priv JModule(final String name)

Deprecated

for removal since 4.0.7.

use two args constructor

Creates an instance of Java module.

Parameters
name:String

Java module name. Value can not be null

Annotations
@Deprecated
forRemoval:true
since:4.0.7
Since
4.0.7
JModuleback to summary
pack-priv JModule(final String name, JCodeModel owner)

Creates an instance of Java module.

Parameters
name:String

Java module name. Value can not be null

owner:JCodeModel

JCodeModel instance that owns this module.

Method Detail

_exportsback to summary
public void _exports(final JPackage pkg)

Adds a package to the list of Java module exports. The package name shall not be null or empty String.

Parameters
pkg:JPackage

Java package to be exported.

_exportsback to summary
public void _exports(final Collection<JPackage> pkgs, final boolean addEmpty)

Adds packages to the list of Java module exports.

Parameters
pkgs:Collection<JPackage>

Collection of packages to be added.

addEmpty:boolean

Adds also packages without any classes when true.

_requiresback to summary
public void _requires(final String name, final boolean isPublic, final boolean isStatic)

Adds a module to the list of Java module requirements. The module name shall not be null or empty String.

Parameters
name:String

Name of required Java module.

isPublic:boolean

Use public modifier.

isStatic:boolean

Use static modifier.

_requiresback to summary
public void _requires(final String name)

Adds a module to the list of Java module requirements without public and static modifiers. The module name shall not be null or empty String.

Parameters
name:String

Name of required Java module.

_requiresback to summary
public void _requires(final boolean isPublic, final boolean isStatic, final String... names)

Adds all modules to the list of Java module requirements. The module name shall not be null or empty String.

Parameters
isPublic:boolean

Use public modifier.

isStatic:boolean

Use static modifier.

names:String[]

Names of required Java module.

_requiresback to summary
public void _requires(final String... names)

Adds all modules to the list of Java module requirements without public and static modifiers.

Parameters
names:String[]

Names of required Java module.

annotateback to summary
public JAnnotationUse annotate(JClass clazz)

Implements com.sun.codemodel.JAnnotatable.annotate.

Doc from com.sun.codemodel.JAnnotatable.annotate.

Adds an annotation to this program element.

Annotations
@Override
annotateback to summary
public JAnnotationUse annotate(Class<? extends Annotation> clazz)

Implements com.sun.codemodel.JAnnotatable.annotate.

Doc from com.sun.codemodel.JAnnotatable.annotate.

Adds an annotation to this program element.

Annotations
@Override
annotate2back to summary
public <W extends JAnnotationWriter<? extends Annotation>> W annotate2(Class<W> clazz)

Implements com.sun.codemodel.JAnnotatable.annotate2.

Doc from com.sun.codemodel.JAnnotatable.annotate2.

Adds an annotation to this program element and returns a type-safe writer to fill in the values of such annotations.

Annotations
@Override
annotationsback to summary
public Collection<JAnnotationUse> annotations()

Implements com.sun.codemodel.JAnnotatable.annotations.

Doc from com.sun.codemodel.JAnnotatable.annotations.

Read-only live view of all annotations on this

Annotations
@Override
buildback to summary
pack-priv void build(final CodeWriter src) throws IOException

Build module-info.java source file.

Parameters
src:CodeWriter

Source code writer.

Exceptions
IOException:
if there is any problem with writing the file.
createModuleInfoSourceFileWriterback to summary
private JFormatter createModuleInfoSourceFileWriter(final CodeWriter src) throws IOException

Create module-info.java source writer.

Returns:JFormatter

New instance of module-info.java source writer.

generateback to summary
public void generate(final JFormatter f)

Implements com.sun.codemodel.JGenerable.generate.

Print source code of Java Module declaration.

Parameters
f:JFormatter

Java code formatter.

getDirectivesback to summary
pack-priv Set<JModuleDirective> getDirectives()

Gets module directives set. jUnit helper method.

Returns:Set<JModuleDirective>

Module directives set.

javadocback to summary
public JDocComment javadoc()

Implements com.sun.codemodel.JDocCommentable.javadoc.

Creates, if necessary, and returns the class javadoc for this JModule

Returns:JDocComment

JDocComment containing javadocs for this class

Annotations
@Override
nameback to summary
public String name()

Gets the name of this module.

Returns:String

name of this module.

removeAnnotationback to summary
public boolean removeAnnotation(JAnnotationUse annotation)

Implements com.sun.codemodel.JAnnotatable.removeAnnotation.

Doc from com.sun.codemodel.JAnnotatable.removeAnnotation.

Removes annotation from this program element.

Annotations
@Override