// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.node.admin.task.util.file;

import java.nio.file.attribute.PosixFileAttributes;
import java.nio.file.attribute.PosixFilePermissions;
import java.time.Instant;

/**
 * This wrapper around PosixFileAttributes.
 * 
 * @author hakonhall
 */
public class FileAttributes {
    private final PosixFileAttributes attributes;

    FileAttributes(PosixFileAttributes attributes) {
        this.attributes = attributes;
    }

    public Instant lastModifiedTime() { return attributes.lastModifiedTime().toInstant(); }
    public String owner() { return attributes.owner().getName(); }
    public String group() { return attributes.group().getName(); }
    public String permissions() { return PosixFilePermissions.toString(attributes.permissions()); }
    public boolean isRegularFile() { return attributes.isRegularFile(); }
    public boolean isDirectory() { return attributes.isDirectory(); }
    public long size() { return attributes.size(); }
}

@@ -188,34 +188,56 @@
 tribute.
-PosixFileA
+FileTime;%0Aimport java.nio.file.a
 ttribute
 s;%0Aimpor
@@ -228,17 +228,36 @@
 ttribute
-s
+.PosixFilePermission
 ;%0Aimport
@@ -328,16 +328,60 @@
 Instant;
+%0Aimport java.util.Map;%0Aimport java.util.Set;
 %0A%0A/**%0A *
@@ -424,17 +424,16 @@
 utes.%0A *
- 
 %0A * @aut
@@ -480,16 +480,17 @@
 butes %7B%0A
+%0A
     priv
@@ -503,130 +503,661 @@
 nal 
-PosixFileAttributes attributes;%0A%0A    FileAttributes(PosixFileAttributes attributes) %7B%0A        this.attributes = attributes
+Instant lastModifiedTime;%0A    private final int ownerId;%0A    private final int groupId;%0A    private final String permissions;%0A    private final boolean isRegularFile;%0A    private final boolean isDirectory;%0A    private final long size;%0A%0A    public FileAttributes(Instant lastModifiedTime, int ownerId, int groupId, String permissions, boolean isRegularFile, boolean isDirectory, long size) %7B%0A        this.lastModifiedTime = lastModifiedTime;%0A        this.ownerId = ownerId;%0A        this.groupId = groupId;%0A        this.permissions = permissions;%0A        this.isRegularFile = isRegularFile;%0A        this.isDirectory = isDirectory;%0A        this.size = size
 ;%0A  
@@ -1208,27 +1208,16 @@
  return 
-attributes.
 lastModi
@@ -1228,22 +1228,8 @@
 Time
-().toInstant()
 ; %7D%0A
@@ -1243,20 +1243,19 @@
 lic 
-Str
 in
-g
+t
  owner
+Id
 () %7B
@@ -1266,36 +1266,15 @@
 urn 
-attributes.owner().getName()
+ownerId
 ; %7D%0A
@@ -1288,20 +1288,19 @@
 lic 
-Str
 in
-g
+t
  group
+Id
 () %7B
@@ -1311,36 +1311,15 @@
 urn 
-attributes.group().getName()
+groupId
 ; %7D%0A
@@ -1363,49 +1363,8 @@
 urn 
-PosixFilePermissions.toString(attributes.
 perm
@@ -1374,11 +1374,8 @@
 ions
-())
 ; %7D%0A
@@ -1418,27 +1418,16 @@
  return 
-attributes.
 isRegula
@@ -1431,18 +1431,16 @@
 ularFile
-()
 ; %7D%0A    
@@ -1481,86 +1481,650 @@
 urn 
-attributes.isDirectory(); %7D%0A    public long size() %7B return attributes.size();
+isDirectory; %7D%0A    public long size() %7B return size; %7D%0A%0A    @SuppressWarnings(%22unchecked%22)%0A    static FileAttributes fromAttributes(Map%3CString, Object%3E attributes) %7B%0A        return new FileAttributes(%0A                ((FileTime) attributes.get(%22lastModifiedTime%22)).toInstant(),%0A                (int) attributes.get(%22uid%22),%0A                (int) attributes.get(%22gid%22),%0A                PosixFilePermissions.toString(((Set%3CPosixFilePermission%3E) attributes.get(%22permissions%22))),%0A                (boolean) attributes.get(%22isRegularFile%22),%0A                (boolean) attributes.get(%22isDirectory%22),%0A                (long) attributes.get(%22size%22));%0A   
  %7D%0A%7D

Include missing change