diff --git a/pmml-model/src/main/java/org/dmg/pmml/Version.java b/pmml-model/src/main/java/org/dmg/pmml/Version.java index a4f6b3a6..cc4b39dd 100644 --- a/pmml-model/src/main/java/org/dmg/pmml/Version.java +++ b/pmml-model/src/main/java/org/dmg/pmml/Version.java @@ -4,25 +4,52 @@ package org.dmg.pmml; public enum Version { - PMML_3_0("http://www.dmg.org/PMML-3_0"), + PMML_3_0("http://www.dmg.org/PMML-3_0"){ + + @Override + public Version previous(){ + return null; + } + }, PMML_3_1("http://www.dmg.org/PMML-3_1"), PMML_3_2("http://www.dmg.org/PMML-3_2"), PMML_4_0("http://www.dmg.org/PMML-4_0"), PMML_4_1("http://www.dmg.org/PMML-4_1"), PMML_4_2("http://www.dmg.org/PMML-4_2"), PMML_4_3("http://www.dmg.org/PMML-4_3"), - PMML_4_4("http://www.dmg.org/PMML-4_4"), + PMML_4_4("http://www.dmg.org/PMML-4_4"){ + + @Override + public Version next(){ + return null; + } + }, /** * Extended PMML */ XPMML("http://xpmml.org/XPMML"){ + @Override + public boolean isStandard(){ + return false; + } + @Override public String getVersion(){ throw new UnsupportedOperationException(); } - } + + @Override + public Version previous(){ + return null; + } + + @Override + public Version next(){ + return null; + } + }, ; private String namespaceURI = null; @@ -33,9 +60,7 @@ private Version(String namespaceURI){ } public boolean isStandard(){ - String namespaceURI = getNamespaceURI(); - - return namespaceURI.matches(Version.REGEX_PMML_XMLNS); + return true; } public String getNamespaceURI(){ @@ -54,6 +79,18 @@ public String getVersion(){ return version.replace('_', '.'); } + public Version previous(){ + Version[] versions = Version.values(); + + return versions[ordinal() - 1]; + } + + public Version next(){ + Version[] versions = Version.values(); + + return versions[ordinal() + 1]; + } + static public Version getMinimum(){ Version[] versions = Version.values(); diff --git a/pmml-model/src/main/java/org/jpmml/model/visitors/VersionInspector.java b/pmml-model/src/main/java/org/jpmml/model/visitors/VersionInspector.java index f8e152b3..8626b7a3 100644 --- a/pmml-model/src/main/java/org/jpmml/model/visitors/VersionInspector.java +++ b/pmml-model/src/main/java/org/jpmml/model/visitors/VersionInspector.java @@ -100,7 +100,7 @@ private void inspect(PMMLObject object, Field field, Object value){ Required required = field.getAnnotation(Required.class); if(required != null){ - updateMaximum(object, field, previous(required.value())); + updateMaximum(object, field, (required.value()).previous()); } return; @@ -133,11 +133,4 @@ private boolean isNull(Object value){ return (value == null); } - - static - private Version previous(Version version){ - Version[] values = Version.values(); - - return values[version.ordinal() - 1]; - } } \ No newline at end of file