Class FileAttributeViewMetadata.Builder
- java.lang.Object
-
- com.github.robtimus.filesystems.attribute.FileAttributeViewMetadata.Builder
-
- Enclosing class:
- FileAttributeViewMetadata
public static final class FileAttributeViewMetadata.Builder extends Object
A builder forFileAttributeViewMetadata
objects.- Author:
- Rob Spoor
- Since:
- 2.2
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description FileAttributeViewMetadata
build()
Creates aFileAttributeViewMetadata
object with the attributes added to this builder.static Type
returnType(Class<?> declaringType, String methodName, Class<?>... parameterTypes)
Returns aType
representing the return type of an existing public method.FileAttributeViewMetadata.Builder
withAttribute(String attributeName, Type attributeType)
Adds a single attribute that is both readable and writable.FileAttributeViewMetadata.Builder
withAttribute(String attributeName, Type attributeType, FileAttributeViewMetadata.Operation firstOperation, FileAttributeViewMetadata.Operation... additionalOperations)
Adds a single attribute that is only supported for specific operations.FileAttributeViewMetadata.Builder
withAttributes(FileAttributeViewMetadata view)
Adds all attributes of anotherFileAttributeViewMetadata
object.FileAttributeViewMetadata.Builder
withViewName(String viewName)
Sets the view name to use.
-
-
-
Method Detail
-
withViewName
public FileAttributeViewMetadata.Builder withViewName(String viewName)
Sets the view name to use. The default view name is derived from the view type as follows:- If the view type's simple name ends with
FileAttributeView
, the part before it in camel case. - If the view type's simple name ends with
AttributeView
, the part before it in camel case. - If the view type's simple name ends with
View
, the part before it in camel case. - The view type's simple name in camel case.
- Parameters:
viewName
- The view name to use.- Returns:
- This builder.
- Throws:
NullPointerException
- If the given view name isnull
.IllegalArgumentException
- If the given view name isempty
.
- If the view type's simple name ends with
-
withAttribute
public FileAttributeViewMetadata.Builder withAttribute(String attributeName, Type attributeType)
Adds a single attribute that is both readable and writable.- Parameters:
attributeName
- The name of the attribute to add.attributeType
- The type of the attribute to add. This should usually be a class literal, or the result of callingreturnType(Class, String, Class...)
for generic types.- Returns:
- This object.
- Throws:
NullPointerException
- If the given attribute name or type isnull
.
-
withAttribute
public FileAttributeViewMetadata.Builder withAttribute(String attributeName, Type attributeType, FileAttributeViewMetadata.Operation firstOperation, FileAttributeViewMetadata.Operation... additionalOperations)
Adds a single attribute that is only supported for specific operations.- Parameters:
attributeName
- The name of the attribute to add.attributeType
- The type of the attribute to add. This should usually be a class literal, or the result of callingreturnType(Class, String, Class...)
for generic types.firstOperation
- The first operation for which the attribute is supported.additionalOperations
- Zero or more additional operations for which the attribute is supported.- Returns:
- This object.
- Throws:
NullPointerException
- If the given attribute name or type or any of the operations isnull
.
-
withAttributes
public FileAttributeViewMetadata.Builder withAttributes(FileAttributeViewMetadata view)
Adds all attributes of anotherFileAttributeViewMetadata
object. This can be used when oneFileAttributeView
interface extends from another.- Parameters:
view
- TheFileAttributeViewMetadata
object to add all attributes of.- Returns:
- This object.
- Throws:
NullPointerException
- If the givenFileAttributeViewMetadata
object isnull
.
-
build
public FileAttributeViewMetadata build()
Creates aFileAttributeViewMetadata
object with the attributes added to this builder.- Returns:
- The created
FileAttributeViewMetadata
object.
-
returnType
public static Type returnType(Class<?> declaringType, String methodName, Class<?>... parameterTypes)
Returns aType
representing the return type of an existing public method.- Parameters:
declaringType
- The class or interface where the method is declared.methodName
- The name of the method.parameterTypes
- The parameter types of the method.- Returns:
- A
Type
representing the return type of the requested method. - Throws:
NullPointerException
- If the given declaring type or method name isnull
.IllegalArgumentException
- If the requested method does not exist.
-
-