forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#34274 from brunobat/build-analytics-part3
Build analytics - Improvements II
- Loading branch information
Showing
16 changed files
with
203 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...rojects/tools/analytics-common/src/main/java/io/quarkus/analytics/util/PropertyUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package io.quarkus.analytics.util; | ||
|
||
public class PropertyUtils { | ||
|
||
public static Integer getProperty(String propertyName, int defaultValue) { | ||
if (propertyName == null) { | ||
throw new IllegalArgumentException("Property name cannot be null"); | ||
} | ||
Integer result = Integer.getInteger(propertyName); | ||
try { | ||
if (result == null) { | ||
String stringValue = System.getenv(transformToEnvVarName(propertyName)); | ||
if (stringValue != null) { | ||
result = Integer.parseInt(stringValue); | ||
} else { | ||
result = defaultValue; | ||
} | ||
} | ||
} catch (NumberFormatException e) { | ||
result = defaultValue; | ||
} | ||
return result; | ||
} | ||
|
||
public static String getProperty(String propertyName, String defaultValue) { | ||
if (propertyName == null) { | ||
throw new IllegalArgumentException("Property name cannot be null"); | ||
} | ||
String result = System.getProperty(propertyName); | ||
try { | ||
if (result == null) { | ||
String stringValue = System.getenv(transformToEnvVarName(propertyName)); | ||
if (stringValue != null) { | ||
result = stringValue; | ||
} else { | ||
result = defaultValue; | ||
} | ||
} | ||
} catch (NumberFormatException e) { | ||
result = defaultValue; | ||
} | ||
return result; | ||
} | ||
|
||
public static boolean getProperty(String propertyName, boolean defaultValue) { | ||
if (propertyName == null) { | ||
throw new IllegalArgumentException("Property name cannot be null"); | ||
} | ||
boolean result; | ||
String systemValue = System.getProperty(propertyName); | ||
try { | ||
if (systemValue == null) { | ||
String envValue = System.getenv(transformToEnvVarName(propertyName)); | ||
if (envValue != null) { | ||
result = Boolean.parseBoolean(envValue); | ||
} else { | ||
result = defaultValue; | ||
} | ||
} else { | ||
result = Boolean.parseBoolean(systemValue); | ||
} | ||
} catch (NumberFormatException e) { | ||
result = defaultValue; | ||
} | ||
return result; | ||
} | ||
|
||
private static String transformToEnvVarName(String propertyName) { | ||
return propertyName.toUpperCase().replace('.', '_'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 0 additions & 113 deletions
113
...ts/tools/analytics-common/src/test/java/io/quarkus/analytics/ConfigServiceManualTest.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.