Package space.arim.dazzleconf.backend
Class CommentData
java.lang.Object
space.arim.dazzleconf.backend.CommentData
The comments on a data entry or configuration class.
This class is immutable, meaning that methods which appear to change data return a new object instead.
-
Method Summary
Modifier and TypeMethodDescription@NonNull CommentDataappend(@NonNull CommentData other) Appends another set of comments to this one.@NonNull CommentDataappendAt(@NonNull CommentLocation location, @NonNull String @NonNull ... lines) Appends comments at the following location and returns a new object.@NonNull CommentDataappendAt(@NonNull CommentLocation location, @NonNull List<@NonNull String> lines) Appends comments at the following location and returns a new object.static @NonNull CommentDataMakes an instance of this class according toCommentsannotations.@NonNull CommentDataclearAt(@NonNull CommentLocation @NonNull ... locations) Clears comments at some locations and returns a new objectstatic CommentDataempty()Returns an empty instance ofCommentsbooleangetAt(@NonNull CommentLocation location) Gets the comments at the specified location.inthashCode()booleanisEmpty()Gets whether there are no comments@NonNull CommentDatasetAt(@NonNull CommentLocation location, @NonNull String @NonNull ... lines) Attaches comments and returns a new object.@NonNull CommentDatasetAt(@NonNull CommentLocation location, @NonNull List<@NonNull String> lines) Attaches comments and returns a new object.toString()
-
Method Details
-
isEmpty
public boolean isEmpty()Gets whether there are no comments- Returns:
- true if no comments exist
-
getAt
Gets the comments at the specified location.The returned value may be immutable, or it may be a mutable copy.
- Parameters:
location- the location- Returns:
- the comment lines, or an empty list if none exist
-
setAt
public @NonNull CommentData setAt(@NonNull CommentLocation location, @NonNull List<@NonNull String> lines) Attaches comments and returns a new object.If an empty list is specified, this function will clear the comments at the specified location.
- Parameters:
location- where the comments are situatedlines- the comment lines to specify at this location- Returns:
- a new instance of this class with the comments set
-
setAt
public @NonNull CommentData setAt(@NonNull CommentLocation location, @NonNull String @NonNull ... lines) Attaches comments and returns a new object.If an empty array is specified, this function will clear the comments at the specified location.
- Parameters:
location- where the comments are situatedlines- the comment lines to specify at this location- Returns:
- a new instance of this class with the comments set
-
appendAt
public @NonNull CommentData appendAt(@NonNull CommentLocation location, @NonNull List<@NonNull String> lines) Appends comments at the following location and returns a new object.If existing comments are set, they will come first.
- Parameters:
location- where the comments will be situatedlines- the comment lines to add at this location- Returns:
- a new instance of this class with the comments appended
-
appendAt
public @NonNull CommentData appendAt(@NonNull CommentLocation location, @NonNull String @NonNull ... lines) Appends comments at the following location and returns a new object.If existing comments are set, they will come first.
- Parameters:
location- where the comments will be situatedlines- the comment lines to add at this location- Returns:
- a new instance of this class with the comments appended
-
clearAt
Clears comments at some locations and returns a new object- Parameters:
locations- which comments to clear- Returns:
- a new instance of this class with no comments at the specified locations
-
append
Appends another set of comments to this one.Any existing comments on this object will be placed first in the resulting product.
- Parameters:
other- the other instance to append to this one- Returns:
- a new instance with the given comments appended
-
buildFrom
Makes an instance of this class according toCommentsannotations.This function collects all the comments, in order, into a single object and returns it. If the argument array is null or empty, an empty object is returned.
- Parameters:
source- the annotations to use- Returns:
- a comments object
-
empty
Returns an empty instance ofComments- Returns:
- an empty instance
-
equals
-
hashCode
public int hashCode() -
toString
-