Package net.sourceforge.pmd.lang
Class LanguageModuleBase.LanguageMetadata
- java.lang.Object
-
- net.sourceforge.pmd.lang.LanguageModuleBase.LanguageMetadata
-
- Enclosing class:
- LanguageModuleBase
public static final class LanguageModuleBase.LanguageMetadata extends Object
Metadata about a language, basically a builder pattern for the language instance.Some of the metadata are mandatory:
- The id (
withId(String)
) - The display name (
name(String)
) - The file extensions (
extensions(String, String...)
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LanguageModuleBase.LanguageMetadata
addAllVersionsOf(Language language)
Add all the versions of the given language, including the default version.LanguageModuleBase.LanguageMetadata
addDefaultVersion(String name, String... aliases)
Add a new version by its name and make it the default version.LanguageModuleBase.LanguageMetadata
addVersion(String name, String... aliases)
Add a new version by its name.LanguageModuleBase.LanguageMetadata
dependsOnLanguage(String id)
Record that this language depends on another language, identified by its id.LanguageModuleBase.LanguageMetadata
extensions(String extensionWithoutPeriod, String... others)
Record the extensions assigned to the language.LanguageModuleBase.LanguageMetadata
extensions(Collection<String> extensions)
Record the extensions assigned to the language.LanguageModuleBase.LanguageMetadata
name(@NonNull String name)
Record the display name of the language.LanguageModuleBase.LanguageMetadata
shortName(@NonNull String shortName)
Record the short name of the language.static LanguageModuleBase.LanguageMetadata
withId(@NonNull String id)
Factory method to create an ID.
-
-
-
Method Detail
-
withId
public static LanguageModuleBase.LanguageMetadata withId(@NonNull String id)
Factory method to create an ID.- Parameters:
id
- The language id. Must be usable as a Java package name segment, ie be lowercase, alphanumeric, starting with a letter.- Returns:
- A builder for language metadata
- Throws:
IllegalArgumentException
- If the parameter is not a valid IDNullPointerException
- If the parameter is null
-
name
public LanguageModuleBase.LanguageMetadata name(@NonNull String name)
Record the display name of the language. This also serves as the short name ifshortName(String)
is not called.- Parameters:
name
- Display name of the language- Throws:
NullPointerException
- If the parameter is nullIllegalArgumentException
- If the parameter is not a valid language name
-
shortName
public LanguageModuleBase.LanguageMetadata shortName(@NonNull String shortName)
Record the short name of the language.- Parameters:
shortName
- Short name of the language- Throws:
NullPointerException
- If the parameter is nullIllegalArgumentException
- If the parameter is not a valid language name
-
extensions
public LanguageModuleBase.LanguageMetadata extensions(String extensionWithoutPeriod, String... others)
Record the extensions assigned to the language. Extensions should not start with a period.
.- Parameters:
extensionWithoutPeriod
- First extensionsothers
- Other extensions (optional)- Throws:
NullPointerException
- If any extension is null
-
extensions
public LanguageModuleBase.LanguageMetadata extensions(Collection<String> extensions)
Record the extensions assigned to the language. Extensions should not start with a period.
. At least one extension must be provided.- Parameters:
extensions
- the extensions- Throws:
NullPointerException
- If any extension is nullIllegalArgumentException
- If no extensions are provided
-
addVersion
public LanguageModuleBase.LanguageMetadata addVersion(String name, String... aliases)
Add a new version by its name.- Parameters:
name
- Version name. Must contain no spaces.aliases
- Additional names that are mapped to this version. Must contain no spaces.- Throws:
NullPointerException
- If any parameter is nullIllegalArgumentException
- If the name or aliases are empty or contain spaces
-
addDefaultVersion
public LanguageModuleBase.LanguageMetadata addDefaultVersion(String name, String... aliases)
Add a new version by its name and make it the default version.- Parameters:
name
- Version name. Must contain no spaces.aliases
- Additional names that are mapped to this version. Must contain no spaces.- Throws:
NullPointerException
- If any parameter is nullIllegalArgumentException
- If the name or aliases are empty or contain spaces
-
addAllVersionsOf
public LanguageModuleBase.LanguageMetadata addAllVersionsOf(Language language)
Add all the versions of the given language, including the default version.- Parameters:
language
- Other language- Throws:
NullPointerException
- If any parameter is nullIllegalArgumentException
- If the name or aliases are empty or contain spaces
-
dependsOnLanguage
public LanguageModuleBase.LanguageMetadata dependsOnLanguage(String id)
Record that this language depends on another language, identified by its id. This means anyLanguageProcessorRegistry
that contains a processor for this language is asserted upon construction to also contain a processor for the language depended on.- Parameters:
id
- ID of the language to depend on.- Throws:
NullPointerException
- If any parameter is nullIllegalArgumentException
- If the name is not a valid language Id
-
-