Class ServiceTemplate
java.lang.Object
eu.cloudnetservice.driver.service.ServiceTemplate
- All Implemented Interfaces:
Named,Cloneable,Comparable<ServiceTemplate>
public class ServiceTemplate
extends Object
implements Named, Comparable<ServiceTemplate>, Cloneable
A service template holds all files which can be copied onto a service. They are building the base structure of any
dynamic service and can be included on them dynamically as well.
- Since:
- 4.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA builder for a template storage. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanGet if this template should always be copied onto static services.static @NonNull ServiceTemplate.Builderbuilder()Constructs a new builder instance for a service template.static @NonNull ServiceTemplate.Builderbuilder(@NonNull ServiceTemplate template) Constructs a new builder for a service template which has all properties of the given template already set.clone()compareTo(@NonNull ServiceTemplate serviceTemplate) Tries to find the storage in which this template is stored.fullName()Get the full name of the template without the storage prefix.name()Get the unique name identifier of this object in the related scope.static @Nullable ServiceTemplateParses a service template from the given input string if possible.prefix()Get the prefix of the template.intpriority()This priority is used to determine in which order the template should be loaded onto a service.storage()Get the template storage in which this template is stored, throwing an exception if the template doesn't exist.Get the name of the storage in which the template is located.toString()
-
Field Details
-
LOCAL_STORAGE
-
prefix
-
name
-
storage
-
priority
private final int priority -
alwaysCopyToStaticServices
private final boolean alwaysCopyToStaticServices
-
-
Constructor Details
-
ServiceTemplate
protected ServiceTemplate(@NonNull @NonNull String prefix, @NonNull @NonNull String name, @NonNull @NonNull String storage, int priority, boolean alwaysCopyToStaticServices) Constructs a new service template instance.- Parameters:
prefix- the prefix of the template.name- the actual name of the template.storage- the storage in which the template is stored.priority- the inclusion priority of the template.alwaysCopyToStaticServices- if the template should always get copied onto static services.- Throws:
NullPointerException- if one of the given parameters is null.
-
-
Method Details
-
builder
Constructs a new builder instance for a service template.- Returns:
- a new service template builder.
-
builder
@NonNull public static @NonNull ServiceTemplate.Builder builder(@NonNull @NonNull ServiceTemplate template) Constructs a new builder for a service template which has all properties of the given template already set.When calling build directly after constructing a builder using this method, it will result in a service template which is equal but not the same as the given one.
- Parameters:
template- the template to copy the properties of.- Returns:
- a builder for a service template which has the properties of the given template already set.
- Throws:
NullPointerException- if the given service template is null.
-
parse
Parses a service template from the given input string if possible. The input template must be in the form- storage:prefix/name
- prefix/name (in this case the storage of the template will be the local storage)
Note: the returned service template only contains data actually given to the method, therefore the priority of the template will always be 0 and alwaysCopyToStaticServices false.
- Parameters:
template- the input string to parse if possible.- Returns:
- the parsed service template from the given input, null if parsing was not possible.
- Throws:
NullPointerException- if the given input string is null.
-
name
-
prefix
-
storageName
-
priority
public int priority()This priority is used to determine in which order the template should be loaded onto a service. For example a template with a priority of 10 (high priority) is installed after templates with a lower priority (for example 1). This can for example be used to control the order of file copies, for example when they potentially override each other.- Returns:
- the priority of the template.
-
alwaysCopyToStaticServices
public boolean alwaysCopyToStaticServices()Get if this template should always be copied onto static services. By default, a template is only copied onto a static service when it starts for the first time. Note that if enabled file from this template can override files which were created by the static service.- Returns:
- true if this template should always be copied onto static services, false otherwise.
-
fullName
-
toString
-
storage
Get the template storage in which this template is stored, throwing an exception if the template doesn't exist.- Returns:
- the template storage in which this template is stored.
- Throws:
NullPointerException- if the storage used in this template is unknown.
-
findStorage
Tries to find the storage in which this template is stored. This method returns null rather than throwing an exception if the storage doesn't exist.- Returns:
- the template storage in which this template is stored, null if the template doesn't exist.
-
compareTo
- Specified by:
compareToin interfaceComparable<ServiceTemplate>
-
clone
-