Skip to content

Commit

Permalink
Technique parameter values may be arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
javagl committed Dec 29, 2016
1 parent 16cccc6 commit a728240
Showing 1 changed file with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/
package de.javagl.jgltf.validator;

import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -265,15 +266,32 @@ private ValidatorResult validateTechniqueParameters(
Object value = techniqueParameters.getValue();
if (value != null)
{
if (!(value instanceof String))
String textureId = null;
if (value instanceof String)
{
textureId = (String)value;
}
else if (value instanceof Collection<?>)
{
Collection<?> collection = (Collection<?>)value;
if (collection.size() == 0)
{
validatorResult.addError(
"The value of techniqueParameters "
+ techniqueParametersId + " is empty", context);
return validatorResult;
}
textureId = String.valueOf(collection.iterator().next());
}
else
{
validatorResult.addWarning(
"The value of techniqueParameters "
+ techniqueParametersId + " is "
+ value.getClass().getSimpleName()
+ ", but should be String", context);
+ ", but should be String or an array of strings",
context);
}
String textureId = String.valueOf(value);
validatorResult.add(textureValidator.validateTexture(
textureId, context));
if (validatorResult.hasErrors())
Expand Down

0 comments on commit a728240

Please sign in to comment.