|
| 1 | +package com.baeldung.polymorphism; |
| 2 | + |
| 3 | +import java.awt.image.BufferedImage; |
| 4 | + |
| 5 | +import org.slf4j.Logger; |
| 6 | +import org.slf4j.LoggerFactory; |
| 7 | + |
| 8 | +public class FileManager { |
| 9 | + |
| 10 | + final static Logger logger = LoggerFactory.getLogger(FileManager.class); |
| 11 | + |
| 12 | + public static void main(String[] args) { |
| 13 | + GenericFile file1 = new TextFile("SampleTextFile", "This is a sample text content", "v1.0.0"); |
| 14 | + logger.info("File Info: \n" + file1.getFileInfo() + "\n"); |
| 15 | + ImageFile imageFile = new ImageFile("SampleImageFile", 200, 100, new BufferedImage(100, 200, BufferedImage.TYPE_INT_RGB).toString() |
| 16 | + .getBytes(), "v1.0.0"); |
| 17 | + logger.info("File Info: \n" + imageFile.getFileInfo()); |
| 18 | + } |
| 19 | + |
| 20 | + public static ImageFile createImageFile(String name, int height, int width, byte[] content, String version) { |
| 21 | + ImageFile imageFile = new ImageFile(name, height, width, content, version); |
| 22 | + logger.info("File 2 Info: \n" + imageFile.getFileInfo()); |
| 23 | + return imageFile; |
| 24 | + } |
| 25 | + |
| 26 | + public static GenericFile createTextFile(String name, String content, String version) { |
| 27 | + GenericFile file1 = new TextFile(name, content, version); |
| 28 | + logger.info("File 1 Info: \n" + file1.getFileInfo() + "\n"); |
| 29 | + return file1; |
| 30 | + } |
| 31 | + |
| 32 | + public static TextFile createTextFile2(String name, String content, String version) { |
| 33 | + TextFile file1 = new TextFile(name, content, version); |
| 34 | + logger.info("File 1 Info: \n" + file1.getFileInfo() + "\n"); |
| 35 | + return file1; |
| 36 | + } |
| 37 | + |
| 38 | +} |
0 commit comments