Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VIPSCommon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VIPS
VIPSCommon
Commits
8473b9db
Commit
8473b9db
authored
3 years ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
Added getDoubleArray
parent
41d0f6b4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/no/nibio/vips/util/ModelUtil.java
+28
-2
28 additions, 2 deletions
src/main/java/no/nibio/vips/util/ModelUtil.java
with
28 additions
and
2 deletions
src/main/java/no/nibio/vips/util/ModelUtil.java
+
28
−
2
View file @
8473b9db
/*
* Copyright (c) 201
5
NIBIO <http://www.nibio.no/>.
* Copyright (c) 20
2
1 NIBIO <http://www.nibio.no/>.
*
* This file is part of VIPSCommon.
* VIPSCommon is free software: you can redistribute it and/or modify
...
...
@@ -27,6 +27,7 @@ import java.io.InputStream;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.net.URLConnection
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
...
...
@@ -36,7 +37,7 @@ import org.apache.commons.codec.binary.Base64;
import
org.apache.commons.io.IOUtils
;
/**
* @copyright 201
5
<a href="http://www.nibio.no/">NIBIO</a>
* @copyright 20
2
1 <a href="http://www.nibio.no/">NIBIO</a>
* @author Tor-Einar Skog <tor-einar.skog@nibio.no>
*/
public
class
ModelUtil
{
...
...
@@ -198,4 +199,29 @@ public class ModelUtil {
throw
new
ConfigValidationException
(
ex
.
getMessage
());
}
}
public
Double
[]
getDoubleArray
(
Object
possibleArrayOfPossibleNumbers
)
throws
ConfigValidationException
{
// Is it not an array?
if
(!
possibleArrayOfPossibleNumbers
.
getClass
().
isArray
()
&&
!
(
possibleArrayOfPossibleNumbers
instanceof
List
))
{
Double
oneDouble
=
this
.
getDouble
(
possibleArrayOfPossibleNumbers
);
Double
[]
retVal
=
{
oneDouble
};
return
retVal
;
}
// Is it an array? Convert to list
List
<
Object
>
listOfPossibleNumbers
=
possibleArrayOfPossibleNumbers
.
getClass
().
isArray
()
?
Arrays
.
asList
((
Object
[])
possibleArrayOfPossibleNumbers
)
:
(
List
)
possibleArrayOfPossibleNumbers
;
Double
[]
retVal
=
new
Double
[
listOfPossibleNumbers
.
size
()];
int
counter
=
0
;
for
(
Object
possibleNumber:
listOfPossibleNumbers
)
{
retVal
[
counter
++]
=
this
.
getDouble
(
possibleNumber
);
}
return
retVal
;
}
}
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