Class FileAttributeViewCollection
- java.lang.Object
-
- com.github.robtimus.filesystems.attribute.FileAttributeViewCollection
-
public final class FileAttributeViewCollection extends Object
An immutable collection of file attribute views. Each view is represented as aFileAttributeViewMetadata
object. Instances of this class can be used to implement several methods inFileStore
,FileSystem
andFileSystemProvider
.- Author:
- Rob Spoor
- Since:
- 2.2
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsView(Class<? extends FileAttributeView> type)
Returns whether or not this collection contains a specific view.boolean
containsView(String name)
Returns whether or not this collection contains a specific view.FileAttributeViewMetadata
getView(String name)
Returns aFileAttributeViewMetadata
object representing a specific view.String
toString()
Set<String>
viewNames()
Returns the names of all contained views.static FileAttributeViewCollection
withViews(FileAttributeViewMetadata... views)
Creates a new collection of file attribute views.
-
-
-
Method Detail
-
withViews
public static FileAttributeViewCollection withViews(FileAttributeViewMetadata... views)
Creates a new collection of file attribute views.- Parameters:
views
- TheFileAttributeViewMetadata
objects representing the views in the created collection.- Returns:
- The created collection.
- Throws:
NullPointerException
- If any of the givenFileAttributeViewMetadata
objects is null.IllegalStateException
- If any of theFileAttributeViewMetadata
objects have duplicate view names.
-
containsView
public boolean containsView(Class<? extends FileAttributeView> type)
Returns whether or not this collection contains a specific view.- Parameters:
type
- The type of file attribute view to check.- Returns:
true
if this collection contains the given view, orfalse
otherwise.- See Also:
FileStore.supportsFileAttributeView(Class)
-
containsView
public boolean containsView(String name)
Returns whether or not this collection contains a specific view.- Parameters:
name
- The name of the file attribute view to check.- Returns:
true
if this collection contains the given view, orfalse
otherwise.- See Also:
FileStore.supportsFileAttributeView(String)
-
viewNames
public Set<String> viewNames()
Returns the names of all contained views.- Returns:
- An unmodifiable set with the names of all contained views.
- See Also:
FileSystem.supportedFileAttributeViews()
-
getView
public FileAttributeViewMetadata getView(String name)
Returns aFileAttributeViewMetadata
object representing a specific view.- Parameters:
name
- The name of the view to return aFileAttributeViewMetadata
object for.- Returns:
- A
FileAttributeViewMetadata
object representing the given view. - Throws:
UnsupportedOperationException
- If no view with the given name is contained in this collection.- See Also:
containsView(String)
-
-