1 package org.apache.archiva.rest.api.model.v2;/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
20 * Licensed to the Apache Software Foundation (ASF) under one
21 * or more contributor license agreements. See the NOTICE file
22 * distributed with this work for additional information
23 * regarding copyright ownership. The ASF licenses this file
24 * to you under the Apache License, Version 2.0 (the
25 * "License"); you may not use this file except in compliance
26 * with the License. You may obtain a copy of the License at
28 * http://www.apache.org/licenses/LICENSE-2.0
29 * Unless required by applicable law or agreed to in writing,
30 * software distributed under the License is distributed on an
31 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
32 * KIND, either express or implied. See the License for the
33 * specific language governing permissions and limitations
37 import io.swagger.v3.oas.annotations.media.Schema;
38 import org.apache.archiva.repository.storage.StorageAsset;
40 import java.io.Serializable;
41 import java.time.OffsetDateTime;
42 import java.time.ZoneOffset;
45 * @author Martin Stockhammer <martin_s@apache.org>
47 @Schema(name="FileInfo",description = "Information about a file stored in the repository")
48 public class FileInfo implements Serializable
50 private static final long serialVersionUID = 900497784542880195L;
51 private OffsetDateTime modified;
52 private String fileName;
59 public static FileInfo of( StorageAsset asset ) {
60 FileInfo fileInfo = new FileInfo( );
61 fileInfo.setFileName( asset.getName() );
62 fileInfo.setPath( asset.getPath() );
63 fileInfo.setModified( asset.getModificationTime( ).atOffset( ZoneOffset.UTC ) );
67 @Schema(description = "Time when the file was last modified")
68 public OffsetDateTime getModified( )
73 public void setModified( OffsetDateTime modified )
75 this.modified = modified;
78 @Schema(name="file_name", description = "Name of the file")
79 public String getFileName( )
84 public void setFileName( String fileName )
86 this.fileName = fileName;
89 @Schema(name="path", description = "Path to the file relative to the repository directory")
90 public String getPath( )
95 public void setPath( String path )
101 public boolean equals( Object o )
103 if ( this == o ) return true;
104 if ( o == null || getClass( ) != o.getClass( ) ) return false;
106 FileInfo fileInfo = (FileInfo) o;
108 if ( modified != null ? !modified.equals( fileInfo.modified ) : fileInfo.modified != null ) return false;
109 if ( fileName != null ? !fileName.equals( fileInfo.fileName ) : fileInfo.fileName != null ) return false;
110 return path != null ? path.equals( fileInfo.path ) : fileInfo.path == null;
114 public int hashCode( )
116 int result = modified != null ? modified.hashCode( ) : 0;
117 result = 31 * result + ( fileName != null ? fileName.hashCode( ) : 0 );
118 result = 31 * result + ( path != null ? path.hashCode( ) : 0 );
123 public String toString( )
125 final StringBuilder sb = new StringBuilder( "FileInfo{" );
126 sb.append( "modified=" ).append( modified );
127 sb.append( ", fileName='" ).append( fileName ).append( '\'' );
128 sb.append( ", path='" ).append( path ).append( '\'' );
130 return sb.toString( );