2  * ============LICENSE_START=======================================================
 
   3  *  Copyright (C) 2020 Ericsson. All rights reserved.
 
   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.Objects;
 
  28  * @author Waqas Ikram (waqas.ikram@est.tech)
 
  31 public class FileEntry {
 
  33     private boolean isDirectory;
 
  34     private String filePath;
 
  35     private byte[] fileContent;
 
  37     public boolean isDirectory() {
 
  41     public void setDirectory(final boolean isDirectory) {
 
  42         this.isDirectory = isDirectory;
 
  45     public FileEntry isDirectory(final boolean isDirectory) {
 
  46         this.isDirectory = isDirectory;
 
  50     public String getFilePath() {
 
  54     public void setFilename(final String filePath) {
 
  55         this.filePath = filePath;
 
  58     public FileEntry filePath(final String filePath) {
 
  59         this.filePath = filePath;
 
  63     public byte[] getFileContent() {
 
  67     public void setFileContent(final byte[] fileContent) {
 
  68         this.fileContent = fileContent;
 
  71     public FileEntry fileContent(final byte[] fileContent) {
 
  72         this.fileContent = fileContent;
 
  76     public InputStream getFileContentAsStream() {
 
  77         if (fileContent == null || fileContent.length == 0) {
 
  80         return new ByteArrayInputStream(fileContent);
 
  84     public int hashCode() {
 
  85         return Objects.hash(isDirectory, filePath, fileContent);
 
  89     public boolean equals(final Object obj) {
 
  90         if (obj instanceof FileEntry) {
 
  91             final FileEntry other = (FileEntry) obj;
 
  92             return Objects.equals(isDirectory, other.isDirectory) && Objects.equals(filePath, other.filePath)
 
  93                     && Objects.equals(fileContent, other.fileContent);
 
  99     public String toString() {
 
 100         final StringBuilder sb = new StringBuilder();
 
 101         sb.append("class FileEntry {\n");
 
 102         sb.append("    isDirectory: ").append(toIndentedString(isDirectory)).append("\n");
 
 103         sb.append("    filePath: ").append(toIndentedString(filePath)).append("\n");
 
 104         sb.append("    fileContent size: ").append(toIndentedString(fileContent != null ? fileContent.length : 0))
 
 107         return sb.toString();