| 1 | package org.europa.together.utils; | |
| 2 | ||
| 3 | import java.nio.file.Paths; | |
| 4 | import java.util.TimeZone; | |
| 5 | import org.europa.together.application.LogbackLogger; | |
| 6 | import org.europa.together.application.PropertyFileReader; | |
| 7 | import org.europa.together.business.Logger; | |
| 8 | import org.europa.together.business.PropertyReader; | |
| 9 | ||
| 10 | /** | |
| 11 | * Constraints for the package CORE. | |
| 12 | */ | |
| 13 | public final class Constraints { | |
| 14 | ||
| 15 | private static final Logger LOGGER = new LogbackLogger(Constraints.class); | |
| 16 | private static final String FILE | |
| 17 | = "org/europa/together/configuration/module.properties"; | |
| 18 | ||
| 19 | /** | |
| 20 | * Constructor. | |
| 21 | */ | |
| 22 | private Constraints() { | |
| 23 | throw new UnsupportedOperationException(); | |
| 24 | } | |
| 25 | ||
| 26 | /** | |
| 27 | * Name of the module (artifact), also used for ConfigurationDAO. | |
| 28 | */ | |
| 29 | public static final String MODULE_NAME = getAppInfo("module"); | |
| 30 | ||
| 31 | /** | |
| 32 | * Version of the module (artifact). This Version is autogenerated by the | |
| 33 | * Maven POM file version entry. | |
| 34 | */ | |
| 35 | public static final String MODULE_VERSION = getAppInfo("version"); | |
| 36 | ||
| 37 | /** | |
| 38 | * The Software License of the artifact. | |
| 39 | */ | |
| 40 | public static final String LICENSE = "Apache License 2.0"; | |
| 41 | ||
| 42 | /** | |
| 43 | * A short description of the module. | |
| 44 | */ | |
| 45 | public static final String MODULE_DESCRIPTION = getAppInfo("description"); | |
| 46 | ||
| 47 | /* ###################################################################### */ | |
| 48 | /** | |
| 49 | * The default timezone is used by the artifact. | |
| 50 | */ | |
| 51 | public static final TimeZone SYSTEM_DEFAULT_TIMEZONE = TimeZone.getTimeZone("UTC"); | |
| 52 | ||
| 53 | /** | |
| 54 | * Detect the Operating System (OS) where the application is running. | |
| 55 | */ | |
| 56 | public static final String SYSTEM_OS = System.getProperty("os.name"); | |
| 57 | ||
| 58 | /** | |
| 59 | * Detect the home directory of the user in the OS. | |
| 60 | */ | |
| 61 | public static final String SYSTEM_USER_HOME_DIR = System.getProperty("user.home"); | |
| 62 | ||
| 63 | /** | |
| 64 | * Detect the directory where the application is running. | |
| 65 | */ | |
| 66 | public static final String SYSTEM_APP_DIR = Paths.get("").toAbsolutePath().toString(); | |
| 67 | ||
| 68 | /** | |
| 69 | * Magic constant. | |
| 70 | */ | |
| 71 | public static final int INT_128 = 128; | |
| 72 | ||
| 73 | /** | |
| 74 | * Magic constant. | |
| 75 | */ | |
| 76 | public static final int INT_512 = 512; | |
| 77 | ||
| 78 | /** | |
| 79 | * * | |
| 80 | * Magic constant. | |
| 81 | */ | |
| 82 | public static final int INT_1024 = 1024; | |
| 83 | ||
| 84 | /** | |
| 85 | * Magic constant. | |
| 86 | */ | |
| 87 | public static final int INT_4096 = 4096; | |
| 88 | ||
| 89 | /** | |
| 90 | * Hexadecimal representation of 255. | |
| 91 | */ | |
| 92 | public static final int HEX_255 = 0xff; | |
| 93 | ||
| 94 | /** | |
| 95 | * Hexadecimal representation of 256. | |
| 96 | */ | |
| 97 | public static final int HEX_256 = 0x100; | |
| 98 | ||
| 99 | /** | |
| 100 | * Implements a static version of toString();. | |
| 101 | * | |
| 102 | * @return Constraints as String | |
| 103 | */ | |
| 104 | public static String printConstraintInfo() { | |
| 105 |
1
1. printConstraintInfo : replaced return value with "" for org/europa/together/utils/Constraints::printConstraintInfo → SURVIVED |
return "CORE Constraints DEBUG Info." |
| 106 | + "\n\t Module Name: " + MODULE_NAME | |
| 107 | + "\n\t Module Version: " + MODULE_VERSION | |
| 108 | + "\n\t Module Description: " + MODULE_DESCRIPTION | |
| 109 | + "\n\t Software License: " + LICENSE | |
| 110 | + "\n\t Operating System: " + SYSTEM_OS | |
| 111 | + "\n\t User Home DIR: " + SYSTEM_USER_HOME_DIR | |
| 112 | + "\n\t Application DIR: " + SYSTEM_APP_DIR | |
| 113 | + "\n\t BYTE 512: " + INT_512 | |
| 114 | + "\n\t BYTE 1024: " + INT_1024 | |
| 115 | + "\n\t BYTE 4096: " + INT_4096 | |
| 116 | + "\n\t HEX 255: " + HEX_255 | |
| 117 | + "\n\t HEX 256: " + HEX_256; | |
| 118 | } | |
| 119 | ||
| 120 | /* ###################################################################### */ | |
| 121 | private static String getAppInfo(final String propertyName) { | |
| 122 | PropertyReader propertyReader = new PropertyFileReader(); | |
| 123 | String value = ""; | |
| 124 | try { | |
| 125 | propertyReader.appendPropertiesFromClasspath(FILE); | |
| 126 | value = propertyReader.getPropertyAsString(propertyName); | |
| 127 | } catch (Exception ex) { | |
| 128 | LOGGER.catchException(ex); | |
| 129 | } | |
| 130 | return value; | |
| 131 | } | |
| 132 | } | |
Mutations | ||
| 105 |
1.1 |