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 forFileAttributeViewMetadataobjects.- Author:
- Rob Spoor
- Since:
- 2.2
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description FileAttributeViewMetadatabuild()Creates aFileAttributeViewMetadataobject with the attributes added to this builder.static TypereturnType(Class<?> declaringType, String methodName, Class<?>... parameterTypes)Returns aTyperepresenting the return type of an existing public method.FileAttributeViewMetadata.BuilderwithAttribute(String attributeName, Type attributeType)Adds a single attribute that is both readable and writable.FileAttributeViewMetadata.BuilderwithAttribute(String attributeName, Type attributeType, FileAttributeViewMetadata.Operation firstOperation, FileAttributeViewMetadata.Operation... additionalOperations)Adds a single attribute that is only supported for specific operations.FileAttributeViewMetadata.BuilderwithAttributes(FileAttributeViewMetadata view)Adds all attributes of anotherFileAttributeViewMetadataobject.FileAttributeViewMetadata.BuilderwithViewName(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 anotherFileAttributeViewMetadataobject. This can be used when oneFileAttributeViewinterface extends from another.- Parameters:
view- TheFileAttributeViewMetadataobject to add all attributes of.- Returns:
- This object.
- Throws:
NullPointerException- If the givenFileAttributeViewMetadataobject isnull.
-
build
public FileAttributeViewMetadata build()
Creates aFileAttributeViewMetadataobject with the attributes added to this builder.- Returns:
- The created
FileAttributeViewMetadataobject.
-
returnType
public static Type returnType(Class<?> declaringType, String methodName, Class<?>... parameterTypes)
Returns aTyperepresenting 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
Typerepresenting 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.
-
-