1. Project Clover database Wed Jan 17 2024 23:40:18 CST
  2. Package org.europa.together.utils

File Constraints.java

 

Coverage histogram

../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
9
3
1
132
55
4
0.44
3
3
1.33

Classes

Class Line # Actions
Constraints 13 9 0% 4 1
0.916666791.7%
 

Contributing tests

This file is covered by 2 tests. .

Source view

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  1 toggle private Constraints() {
23  1 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  1 toggle public static String printConstraintInfo() {
105  1 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  3 toggle private static String getAppInfo(final String propertyName) {
122  3 PropertyReader propertyReader = new PropertyFileReader();
123  3 String value = "";
124  3 try {
125  3 propertyReader.appendPropertiesFromClasspath(FILE);
126  3 value = propertyReader.getPropertyAsString(propertyName);
127    } catch (Exception ex) {
128  0 LOGGER.catchException(ex);
129    }
130  3 return value;
131    }
132    }