2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2020 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
20 package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd;
22 import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils.toIndentedString;
23 import java.io.ByteArrayInputStream;
24 import java.io.InputStream;
25 import java.util.Arrays;
26 import java.util.Objects;
29 * @author Waqas Ikram (waqas.ikram@est.tech)
32 public class FileEntry {
34 private boolean isDirectory;
35 private String filePath;
36 private byte[] fileContent;
38 public boolean isDirectory() {
42 public void setDirectory(final boolean isDirectory) {
43 this.isDirectory = isDirectory;
46 public FileEntry isDirectory(final boolean isDirectory) {
47 this.isDirectory = isDirectory;
51 public String getFilePath() {
55 public void setFilename(final String filePath) {
56 this.filePath = filePath;
59 public FileEntry filePath(final String filePath) {
60 this.filePath = filePath;
64 public byte[] getFileContent() {
68 public void setFileContent(final byte[] fileContent) {
69 this.fileContent = fileContent;
72 public FileEntry fileContent(final byte[] fileContent) {
73 this.fileContent = fileContent;
77 public InputStream getFileContentAsStream() {
78 if (fileContent == null || fileContent.length == 0) {
81 return new ByteArrayInputStream(fileContent);
85 public int hashCode() {
86 return Objects.hash(isDirectory, filePath) + Arrays.hashCode(fileContent);
90 public boolean equals(final Object obj) {
91 if (obj instanceof FileEntry) {
92 final FileEntry other = (FileEntry) obj;
93 return Objects.equals(isDirectory, other.isDirectory) && Objects.equals(filePath, other.filePath)
94 && Arrays.equals(fileContent, other.fileContent);
100 public String toString() {
101 final StringBuilder sb = new StringBuilder();
102 sb.append("class FileEntry {\n");
103 sb.append(" isDirectory: ").append(toIndentedString(isDirectory)).append("\n");
104 sb.append(" filePath: ").append(toIndentedString(filePath)).append("\n");
105 sb.append(" fileContent size: ").append(toIndentedString(fileContent != null ? fileContent.length : 0))
108 return sb.toString();