Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BraillePlot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Georg Graßnick
BraillePlot
Commits
a9b08d08
Commit
a9b08d08
authored
5 years ago
by
Andrey Ruzhanskiy
Browse files
Options
Downloads
Patches
Plain Diff
Changed parser in complience with Leo.
parent
8c45bb10
No related branches found
No related tags found
1 merge request
!14
Feat/braille print back end 4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/tudresden/inf/mci/brailleplot/configparser/JavaPropertiesConfigurationValidator.java
+15
-6
15 additions, 6 deletions
...ot/configparser/JavaPropertiesConfigurationValidator.java
with
15 additions
and
6 deletions
src/main/java/de/tudresden/inf/mci/brailleplot/configparser/JavaPropertiesConfigurationValidator.java
+
15
−
6
View file @
a9b08d08
...
...
@@ -16,8 +16,8 @@ import java.util.regex.Pattern;
/**
* Concrete validator for properties parsed from configuration files in Java Property File format.
* @author Leonard Kupper
* @version 2019.07.
18
* @author Leonard Kupper
, Andrey Ruzhanskiy
* @version 2019.07.
30
*/
class
JavaPropertiesConfigurationValidator
implements
ConfigurationValidator
{
...
...
@@ -43,6 +43,7 @@ class JavaPropertiesConfigurationValidator implements ConfigurationValidator {
Predicate
<
String
>
requireEnum
=
JavaPropertiesConfigurationValidator:
:
checkIfEnum
;
Predicate
<
String
>
requirePrinterExists
=
JavaPropertiesConfigurationValidator:
:
checkIfPrinterExists
;
/*
Map<String, Predicate<String>> p = new HashMap<>();
p.put("name", requireNotEmpty.and(requirePrinterExists));
...
...
@@ -210,11 +211,16 @@ class JavaPropertiesConfigurationValidator implements ConfigurationValidator {
throw
new
ConfigurationValidationException
(
"Invalid property name: "
+
propertyName
);
}
// Check against its type requirement predicate
if
(!
validation
.
get
(
propertyName
).
test
(
value
))
{
throw
new
ConfigurationValidationException
(
"Invalid value '"
+
value
+
"' for property '"
+
propertyName
+
"'"
);
try
{
if
(!
validation
.
get
(
propertyName
).
test
(
value
))
{
throw
new
ConfigurationValidationException
(
"Invalid value '"
+
value
+
"' for property '"
+
propertyName
+
"'"
);
}
}
catch
(
RuntimeException
e
)
{
throw
new
ConfigurationValidationException
(
e
.
getMessage
(),
e
);
}
}
// Validation Predicates
...
...
@@ -291,6 +297,9 @@ class JavaPropertiesConfigurationValidator implements ConfigurationValidator {
private
static
boolean
checkIfPrinterExists
(
final
String
printerName
)
{
PrintService
[]
services
=
PrintServiceLookup
.
lookupPrintServices
(
null
,
null
);
if
(
services
.
length
==
0
)
{
throw
new
RuntimeException
(
"Cant find any print services on this system."
);
}
for
(
PrintService
service:
services
)
{
// Second check needed for testing purposes
if
(
service
.
getName
().
equals
(
printerName
)
||
printerName
.
equals
(
"Dummy Printer"
))
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment