-
Notifications
You must be signed in to change notification settings - Fork 55
Validate PURLs #179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Validate PURLs #179
Changes from all commits
f532d53
e1931b3
9dd1ff9
503d884
ecd70ab
509e902
d0c98a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
## 2.4.3 | ||
- Optional validation of PURLs added. | ||
|
||
## 2.4.2 | ||
- Typo fix. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.ericsson.eiffel.remrem.semantics.util; | ||
|
||
import com.ericsson.eiffel.remrem.semantics.validator.EiffelValidator; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.HashMap; | ||
|
||
public class PropertiesUtil { | ||
public static final Logger log = LoggerFactory.getLogger(PropertiesUtil.class); | ||
|
||
public static <T> T getProperty(HashMap<String, Object> validationProperties, String property) { | ||
return getProperty(validationProperties, property, null); | ||
} | ||
|
||
public static <T> T getProperty(HashMap<String, Object> validationProperties, String property, T defValue) { | ||
Object object = validationProperties.get(property); | ||
if (object == null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. code can be optimised as follows: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but then I lose the error message. And it's important here as it would be difficult to investigate why default value was returned instead of value from HashMap. I tried to find how to check it dynamically (something linek 'object instance of T'), but generics are compile-time-only feature... |
||
return defValue; | ||
if (object instanceof Boolean) { | ||
return (T)object; | ||
} | ||
else { | ||
log.error("Value of property '{}' should be a boolean, but is '{}'; returning default value '{}'", | ||
property, object.getClass().getName(), defValue); | ||
return defValue; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this class required , we can directly fetch the details from the hashmap ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last method of the class ensures that property is a Boolean. If fetching from a HashMap directly, the code would have to follow the fetch making it harder to read. That's why a new class was introduced.