The parent builder.
+ * @param The object to build.
+ * @param This builder.
+ * @author Willem Cazander
+ * @version 1.0 Oct 22, 2015
+ */
+public abstract class AbstractUnitXCBuilder
implements Builder
{
+
+ private final P parent;
+ private final T value;
+ private final BiConsumer
parentBuilder;
+
+ /**
+ * Creates the builder.
+ * @param parent The parent builder.
+ * @param value The object to build.
+ */
+ public AbstractUnitXCBuilder(P parent,T value,BiConsumer
parentBuilder) {
+ this.parent = Validate.notNull(parent);
+ this.value = Validate.notNull(value);
+ this.parentBuilder = Validate.notNull(parentBuilder);
+ }
+
+ protected P getParent() {
+ return parent;
+ }
+
+ protected T getValue() {
+ return value;
+ }
+
+ protected abstract B getBuilder();
+
+ /**
+ * Builds the result.
+ * @return The result.
+ */
+ @Override
+ public final P build() {
+ buildPreValue(getValue());
+ parentBuilder.accept(getParent(), getValue());
+ return getParent();
+ }
+
+ protected void buildPreValue(T value) {
+ }
+
+ protected B make(Consumer mixer) {
+ mixer.accept(getValue());
+ return getBuilder();
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/AbstractUnitXCGroupBuilder.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/AbstractUnitXCGroupBuilder.java
new file mode 100644
index 00000000..1b735227
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/AbstractUnitXCGroupBuilder.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.config.builder;
+
+import java.util.Arrays;
+import java.util.function.BiConsumer;
+
+import net.forwardfire.unitxc.model.AbstractUnitXCGroup;
+import net.forwardfire.unitxc.model.DefaultUnitXCGroupQuantity;
+import net.forwardfire.unitxc.model.DefaultUnitXCType;
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 28, 2016
+ */
+abstract public class AbstractUnitXCGroupBuilder
extends AbstractUnitXCBuilder
{
+
+ public AbstractUnitXCGroupBuilder(P parent, T model, BiConsumer
parentBuilder) {
+ super(parent, model, parentBuilder);
+ }
+
+ public UnitXCGroupJumpBuilder> createGroupJump(String unitGroupId) {
+ return new UnitXCGroupJumpBuilder<>(this,getValue(),unitGroupId,(p,v) -> p.getValue().addGroupJump(v));
+ }
+
+ public UnitXCTypeBuilder> createUnitType() {
+ return new UnitXCTypeBuilder<>(this,new DefaultUnitXCType(),(p,v) -> p.getValue().addUnitType(v));
+ }
+
+ public B setBaseTypeId(String baseTypeId) {
+ return make((v) -> v.setBaseTypeId(baseTypeId));
+ }
+
+ public B addQuantityId(String id) {
+ return make((v) -> v.addQuantity(new DefaultUnitXCGroupQuantity(null,"group."+v.getId()+".quantity",id))); // TODO: fix null bundle here
+ }
+
+ public B addQuantityIds(String...ids) {
+ Arrays.asList(ids).forEach(id -> addQuantityId(id));
+ return getBuilder();
+ }
+
+// public B addDerivedFrom(String fromId) {
+// return make((v) -> v.addDerivedFrom(fromId));
+// }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/AbstractUnitXCTypeBuilder.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/AbstractUnitXCTypeBuilder.java
new file mode 100644
index 00000000..1567843a
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/AbstractUnitXCTypeBuilder.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.config.builder;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.function.BiConsumer;
+
+import net.forwardfire.unitxc.model.DefaultUnitXCType;
+import net.forwardfire.unitxc.model.UnitXCType;
+import net.forwardfire.unitxc.model.step.UnitXConverterStep;
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 22, 2015
+ */
+public abstract class AbstractUnitXCTypeBuilder
extends AbstractUnitXCBuilder
{
+
+ public AbstractUnitXCTypeBuilder(P parent,DefaultUnitXCType model,BiConsumer
parentBuilder) {
+ super(parent, model, parentBuilder);
+ }
+
+ @Override
+ protected final void buildPreValue(DefaultUnitXCType value) {
+ if (value.getNamePlural() == null) {
+ setNamePlurals();
+ }
+ if (value.getAliasOfType() != null && !value.getTypeFlags().contains(UnitXCConfigBuilder.TYPE_FLAG_ALIAS)) {
+ value.getTypeFlags().add(UnitXCConfigBuilder.TYPE_FLAG_ALIAS);
+ }
+ buildModel(value);
+ }
+
+ protected void buildModel(UnitXCType value) {
+ }
+
+ public B setId(String id) {
+ return make((v) -> v.setId(id));
+ }
+
+ public B setName(String name) {
+ return make((v) -> v.setName(name));
+ }
+
+ public B setNamePlurals() {
+ return setNamePlural(getValue().getName()+"s");
+ }
+
+ public B setNamePlural(String name) {
+ return make((v) -> v.setNamePlural(name));
+ }
+
+ public B setAliasOfType(String aliasOfType) {
+ return make((v) -> v.setAliasOfType(aliasOfType));
+ }
+
+ public B setWebLinkWiki(String websiteLink) {
+ return setWebLink(UnitXCConfigBuilder.WIKI_BASE_URL+websiteLink);
+ }
+
+ public B setWebLink(String websiteLink) {
+ return make((v) -> v.setWebLink(websiteLink));
+ }
+
+ public B addTypeFlag(String flag) {
+ return make((v) -> v.getTypeFlags().add(flag));
+ }
+
+ public B addTypeFlags(Collection flags) {
+ return make(v -> flags.forEach(flag -> v.getTypeFlags().add(flag)));
+ }
+
+ public B addTypeFlags(String[] flags) {
+ return addTypeFlags(Arrays.asList(flags));
+ }
+
+ public UnitXConverterStepBuilder> createFromBaseConverterSteps() {
+ return new UnitXConverterStepBuilder<>(this,(p,v) -> p.addFromBaseConverterSteps(v),() -> "convert "+getValue().getId());
+ }
+
+ public UnitXConverterStepBuilder> createToBaseConverterSteps() {
+ return new UnitXConverterStepBuilder<>(this,(p,v) -> p.addToBaseConverterSteps(v),() -> "convert "+getValue().getId());
+ }
+
+ public B addFromBaseConverterStep(UnitXConverterStep unitTypeConverter) {
+ return make((v) -> v.getFromBaseConverterSteps().add(unitTypeConverter));
+ }
+
+ public B addFromBaseConverterSteps(List unitTypeConverters) {
+ return make((v) -> unitTypeConverters.forEach(c -> v.getFromBaseConverterSteps().add(c)));
+ }
+
+ public B addToBaseConverterStep(UnitXConverterStep unitTypeConverter) {
+ return make((v) -> v.getToBaseConverterSteps().add(unitTypeConverter));
+ }
+
+ public B addToBaseConverterSteps(List unitTypeConverters) {
+ return make((v) -> unitTypeConverters.forEach(c -> v.getToBaseConverterSteps().add(c)));
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCConfigBuilder.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCConfigBuilder.java
new file mode 100644
index 00000000..e5c29c3e
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCConfigBuilder.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.config.builder;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.apache.commons.lang3.Validate;
+
+import net.forwardfire.unitxc.model.AbstractUnitXCGroup;
+import net.forwardfire.unitxc.model.UnitXCConfig;
+import net.forwardfire.unitxc.model.UnitXCGroup;
+import net.forwardfire.unitxc.model.UnitXCGroupBase;
+import net.forwardfire.unitxc.model.UnitXCGroupCompoundExponent;
+import net.forwardfire.unitxc.model.UnitXCGroupCompoundPair;
+import net.forwardfire.unitxc.model.UnitXCResourceBundle;
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 17, 2015
+ */
+public class UnitXCConfigBuilder {
+
+ public static final String TYPE_FLAG_IMPERIAL = "IMPERIAL"; // TODO: move to ...
+ public static final String TYPE_FLAG_IMPERIAL_EXTRA = "IMPERIAL_EXTRA";
+ public static final String TYPE_FLAG_ALIAS = "ALIAS";
+
+ public static final String WIKI_BASE_URL = "https://en.wikipedia.org/wiki/";
+
+ private final UnitXCConfig config;
+ private final UnitXCResourceBundle bundle;
+
+ public UnitXCConfigBuilder(UnitXCConfig config) {
+ this.config = Validate.notNull(config);
+ this.bundle = new UnitXCResourceBundle();
+ this.initBundle();
+ }
+
+ private void initBundle() {
+ config.getLanguages().add(Locale.forLanguageTag(""));
+ for (Locale l:config.getLanguages()) {
+ String language = l.toLanguageTag();
+ ResourceBundle b = ResourceBundle.getBundle("net.forwardfire.unitxc.UnitXCBundle", l);
+ //System.out.println("loading bundle language: "+language+" baseBundle: "+b.getBaseBundleName()+" size: "+b.keySet().size());
+ b.keySet().forEach(k -> bundle.addData(language, k, b.getString(k)));
+ }
+ }
+
+ protected UnitXCConfig getConfig() {
+ return config;
+ }
+
+ public UnitXCGroupBaseBuilder createUnitGroupBase(String groupId) {
+ return new UnitXCGroupBaseBuilder(this, new UnitXCGroupBase(bundle,groupId), (p,v) -> p.getConfig().addUnitGroup(v));
+ }
+
+ public UnitXCGroupCompoundPairBuilder createUnitGroupCompoundPair(String groupId, String parentGroupId, String parentPerGroupId) {
+ return new UnitXCGroupCompoundPairBuilder(this, new UnitXCGroupCompoundPair(bundle,groupId,findGroup(parentGroupId),findGroup(parentPerGroupId)), (p,v) -> p.getConfig().addUnitGroup(v));
+ }
+
+ public UnitXCGroupCompoundExponentBuilder createUnitGroupCompoundExponent(String groupId, String parentGroupId, int exponent) {
+ return new UnitXCGroupCompoundExponentBuilder(this, new UnitXCGroupCompoundExponent(bundle,groupId,findGroup(parentGroupId),exponent), (p,v) -> p.getConfig().addUnitGroup(v));
+ }
+
+ public UnitXCGroupExtendBuilder extendUnitGroup(String groupId) {
+ UnitXCGroup group = findGroup(groupId);
+ return new UnitXCGroupExtendBuilder(this, AbstractUnitXCGroup.class.cast(group), (p,v) -> {});
+ }
+
+ private UnitXCGroup findGroup(String id) {
+ Validate.notBlank(id,"Can't search blank id.");
+ for (UnitXCGroup m:config.getUnitGroups()) {
+ if (m.getId().equals(id)) {
+ return m;
+ }
+ }
+ throw new IllegalArgumentException("Could not find: "+id);
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCConfigModuleBuilder.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCConfigModuleBuilder.java
new file mode 100644
index 00000000..458dfe05
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCConfigModuleBuilder.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.config.builder;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 31, 2015
+ */
+public class UnitXCConfigModuleBuilder {
+
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCGroupBaseBuilder.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCGroupBaseBuilder.java
new file mode 100644
index 00000000..01a3237d
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCGroupBaseBuilder.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.config.builder;
+
+import java.util.function.BiConsumer;
+
+import net.forwardfire.unitxc.model.UnitXCGroupBase;
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 22, 2015
+ */
+public class UnitXCGroupBaseBuilder extends AbstractUnitXCGroupBuilder {
+
+ public UnitXCGroupBaseBuilder(UnitXCConfigBuilder parent, UnitXCGroupBase model, BiConsumer parentBuilder) {
+ super(parent, model, parentBuilder);
+ }
+
+ @Override
+ protected UnitXCGroupBaseBuilder getBuilder() {
+ return this;
+ }
+
+ public UnitXCTypeSIPrefixBuilder createSIUnitTypes() {
+ return new UnitXCTypeSIPrefixBuilder<>(this,this);
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCGroupCompoundExponentBuilder.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCGroupCompoundExponentBuilder.java
new file mode 100644
index 00000000..a73bd0e5
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCGroupCompoundExponentBuilder.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.config.builder;
+
+import java.util.function.BiConsumer;
+
+import net.forwardfire.unitxc.model.UnitXCGroupCompoundExponent;
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 26, 2015
+ */
+public class UnitXCGroupCompoundExponentBuilder extends AbstractUnitXCGroupBuilder {
+
+ public UnitXCGroupCompoundExponentBuilder(UnitXCConfigBuilder parent, UnitXCGroupCompoundExponent model, BiConsumer parentBuilder) {
+ super(parent, model, parentBuilder);
+ }
+
+ @Override
+ protected UnitXCGroupCompoundExponentBuilder getBuilder() {
+ return this;
+ }
+
+ @Override
+ protected void buildPreValue(UnitXCGroupCompoundExponent value) {
+ // TODO: move
+ getValue().getDerivedFrom().add(getValue().getParentGroup().getId());
+ }
+
+
+ public UnitXCGroupCompoundExponentBuilder setUnitIdPostfix(String unitIdPostfix) {
+ return make(v -> v.setUnitIdPostfix(unitIdPostfix));
+ }
+
+ public UnitXCGroupCompoundExponentBuilder setUnitNamePrefix(String unitNamePrefix) {
+ return make(v -> v.setUnitNamePrefix(unitNamePrefix));
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCGroupCompoundPairBuilder.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCGroupCompoundPairBuilder.java
new file mode 100644
index 00000000..11950224
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCGroupCompoundPairBuilder.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.config.builder;
+
+import java.util.function.BiConsumer;
+
+import net.forwardfire.unitxc.model.UnitXCGroup;
+import net.forwardfire.unitxc.model.UnitXCGroupCompoundPair;
+import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueNamedParameter;
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 26, 2015
+ */
+public class UnitXCGroupCompoundPairBuilder extends AbstractUnitXCGroupBuilder {
+
+ public UnitXCGroupCompoundPairBuilder(UnitXCConfigBuilder parent, UnitXCGroupCompoundPair model, BiConsumer parentBuilder) {
+ super(parent, model, parentBuilder);
+ }
+
+ @Override
+ protected UnitXCGroupCompoundPairBuilder getBuilder() {
+ return this;
+ }
+
+ @Override
+ protected void buildPreValue(UnitXCGroupCompoundPair value) {
+
+ UnitXCGroup group = getValue().getParentGroup();
+ UnitXCGroup perGroup = getValue().getParentPerGroup();
+
+ // TODO: do once !!
+ // TODO: move
+ getValue().getDerivedFrom().add(group.getId());
+ getValue().getDerivedFrom().add(perGroup.getId());
+//
+// UnitXCGroupJump toGroupJump = new UnitXCGroupJump();
+// toGroupJump.setId("to_"+group.getId());
+// toGroupJump.setUnitGroup(group);
+// toGroupJump.addJumpParameter(new UnitXCGroupJumpParameter("to_"+perGroup.getId(),"",perGroup.getId()));
+//
+// UnitXCGroupJump perGroupJump = new UnitXCGroupJump();
+// perGroupJump.setId("to_"+group.getId());
+// perGroupJump.setUnitGroup(group);
+
+ //getValue().getGroupJumps().add(toGroupJump); // m/s -> m
+ //getValue().getGroupJumps().add(perGroupJump); // m/s -> h
+
+ //group.getGroupJumps().add(toGroupJump); // m -> m/s
+ //perGroup.getGroupJumps().add(perGroupJump); // s -> m/s
+
+ // m/s -> m
+ createGroupJump(group.getId())
+ .addJumpParameter(value.getId()+"_"+perGroup.getId(),perGroup.getId())
+ .createToGroupConverterSteps()
+ .multiply(new UnitXConverterStepValueNamedParameter(value.getId()+"_"+perGroup.getId()))
+ .build()
+ .build();
+
+ // m -> m/s
+ getParent().extendUnitGroup(group.getId())
+ .createGroupJump(value.getId())
+ .addJumpParameter(value.getId()+"_"+perGroup.getId(),perGroup.getId())
+ .createToGroupConverterSteps()
+ .divide(new UnitXConverterStepValueNamedParameter(value.getId()+"_"+perGroup.getId()))
+ .build()
+ .build();
+
+
+ //FIXME
+ // m/s -> s
+ createGroupJump(perGroup.getId())
+ .addJumpParameter(value.getId()+"_"+group.getId(),group.getId())
+ .createToGroupConverterSteps()
+ .multiply(new UnitXConverterStepValueNamedParameter(value.getId()+"_"+group.getId()))
+ .build()
+ .build();
+
+ // s -> m/s
+ getParent().extendUnitGroup(perGroup.getId())
+ .createGroupJump(value.getId())
+ .addJumpParameter(value.getId()+"_"+group.getId(),group.getId())
+ .createToGroupConverterSteps()
+ .divide(new UnitXConverterStepValueNamedParameter(value.getId()+"_"+group.getId()))
+ .build()
+ .build();
+
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCGroupExtendBuilder.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCGroupExtendBuilder.java
new file mode 100644
index 00000000..a7e04838
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCGroupExtendBuilder.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.config.builder;
+
+import java.util.function.BiConsumer;
+
+import net.forwardfire.unitxc.model.AbstractUnitXCGroup;
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 28, 2016
+ */
+public class UnitXCGroupExtendBuilder extends AbstractUnitXCGroupBuilder {
+
+ public UnitXCGroupExtendBuilder(UnitXCConfigBuilder parent, AbstractUnitXCGroup model, BiConsumer parentBuilder) {
+ super(parent, model, parentBuilder);
+ }
+
+ @Override
+ protected UnitXCGroupExtendBuilder getBuilder() {
+ return this;
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCGroupJumpBuilder.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCGroupJumpBuilder.java
new file mode 100644
index 00000000..a0273b49
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCGroupJumpBuilder.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.config.builder;
+
+
+import java.util.function.BiConsumer;
+
+import net.forwardfire.unitxc.model.DefaultUnitXCGroupJump;
+import net.forwardfire.unitxc.model.DefaultUnitXCGroupJumpParameter;
+import net.forwardfire.unitxc.model.UnitXCGroup;
+import net.forwardfire.unitxc.model.UnitXCGroupJumpParameter;
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Apr 1, 2016
+ */
+public class UnitXCGroupJumpBuilder
addJumpParameter(String id,String unitGroupId) {
+ return make((v) -> v.addJumpParameter(new DefaultUnitXCGroupJumpParameter(id, unitGroupId)));
+ }
+
+ public UnitXConverterStepBuilder> createToGroupConverterSteps() {
+ return new UnitXConverterStepBuilder<>(this,(p,v) -> getValue().getToGroupConverterSteps().addAll(v),() -> "group jump");
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCNumberTypeSetting.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCNumberTypeSetting.java
new file mode 100644
index 00000000..c1f278bc
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCNumberTypeSetting.java
@@ -0,0 +1,35 @@
+package net.forwardfire.unitxc.config.builder;
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 28, 2015
+ */
+public class UnitXCNumberTypeSetting {
+
+ private static final char ZERO_CHAR_NORMAL = '0';
+ private static final char ZERO_CHAR_SUB = '₀';
+ private static final char ZERO_CHAR_SUPER = '⁰';
+
+ public static String toSuperScript(int value) {
+ return printScript(value, ZERO_CHAR_SUPER, new StringBuilder()).toString();
+ }
+
+ public static String toSubScript(int value) {
+ return printScript(value, ZERO_CHAR_SUB, new StringBuilder()).toString();
+ }
+
+ private static StringBuilder printScript(int value,char zeroChar,StringBuilder buf) {
+ String number = Integer.toString(value);
+ for (char c:number.toCharArray()) {
+ int offset = c-ZERO_CHAR_NORMAL;
+ int scriptChar = zeroChar+offset;
+ if (scriptChar==0x2072 || scriptChar==0x2073) { // TODO: rewrite to lookup table
+ scriptChar-=(0x2070-0x00B0); // utf-8 is iso-8859-1 compatible :(
+ }
+ buf.append((char)scriptChar);
+ }
+ return buf;
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCTypeBuilder.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCTypeBuilder.java
new file mode 100644
index 00000000..579c73d7
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCTypeBuilder.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.config.builder;
+
+import java.util.function.BiConsumer;
+
+import net.forwardfire.unitxc.model.DefaultUnitXCType;
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 23, 2015
+ */
+public class UnitXCTypeBuilder
extends AbstractUnitXCTypeBuilder
> {
+
+ public UnitXCTypeBuilder(P parent,DefaultUnitXCType model, BiConsumer
getBuilder() {
+ return this;
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCTypeSIPrefix.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCTypeSIPrefix.java
new file mode 100644
index 00000000..b9e131b1
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCTypeSIPrefix.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.config.builder;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 22, 2015
+ */
+public enum UnitXCTypeSIPrefix {
+
+ YOTTA ("Y", 24),
+ ZETTA ("Z", 21),
+ EXA ("E", 18),
+ PETA ("P", 15),
+ TERA ("T", 12),
+ GIGA ("G", 9),
+ MEGA ("M", 6),
+ KILO ("k", 3),
+ HECTO ("h", 2),
+ DECA ("da",1),
+ DECI ("d", -1),
+ CENTI ("c", -2),
+ MILLI ("m", -3),
+ MICRO ("µ", -6, null, UnitXCTypeSIPrefix.NAME_ALIAS_MILLIMILLI),
+ NANO ("n", -9, null, UnitXCTypeSIPrefix.NAME_ALIAS_MILLIMICRO),
+ PICO ("p", -12, null, UnitXCTypeSIPrefix.NAME_ALIAS_MICROMICRO),
+ FEMTO ("f", -15),
+ ATTO ("a", -18),
+ ZEPTO ("z", -21),
+ YOCTO ("y", -24),
+
+ EXBI ("Ei", 60, UnitXCTypeSIPrefix.TYPE_FLAG_SI_UNIT_BINARY),
+ PEBI ("Pi", 50, UnitXCTypeSIPrefix.TYPE_FLAG_SI_UNIT_BINARY),
+ TEBI ("Ti", 40, UnitXCTypeSIPrefix.TYPE_FLAG_SI_UNIT_BINARY),
+ GIBI ("Gi", 30, UnitXCTypeSIPrefix.TYPE_FLAG_SI_UNIT_BINARY),
+ MEBI ("Mi", 20, UnitXCTypeSIPrefix.TYPE_FLAG_SI_UNIT_BINARY),
+ KIBI ("Ki", 10, UnitXCTypeSIPrefix.TYPE_FLAG_SI_UNIT_BINARY),
+
+ HECTOKILO ("hk", 5, UnitXCTypeSIPrefix.TYPE_FLAG_SI_UNIT_OBSOLETE),
+ MYRIA ("my", 4, UnitXCTypeSIPrefix.TYPE_FLAG_SI_UNIT_OBSOLETE),
+ ;
+
+ public static final String TYPE_FLAG_SI_UNIT = "SI_UNIT";
+ public static final String TYPE_FLAG_SI_UNIT_BIGGER = "SI_UNIT_BIGGER";
+ public static final String TYPE_FLAG_SI_UNIT_BIGGEST = "SI_UNIT_BIGGEST";
+ public static final String TYPE_FLAG_SI_UNIT_BINARY = "SI_UNIT_BINARY";
+ public static final String TYPE_FLAG_SI_UNIT_OBSOLETE = "SI_UNIT_OBSOLETE";
+ public static final String TYPE_FLAG_SI_UNIT_COMMON = "SI_UNIT_COMMON";
+
+ public static final String NAME_ALIAS_MILLIMILLI = "millimilli";
+ public static final String NAME_ALIAS_MILLIMICRO = "millimicro";
+ public static final String NAME_ALIAS_MICROMICRO = "micromicro";
+
+ private final String id;
+ private final String name;
+ private final int exponent;
+ private final List flags;
+ private final List nameAliases;
+
+ private UnitXCTypeSIPrefix(String id,int exponent) {
+ this(id,exponent,null);
+ }
+
+ private UnitXCTypeSIPrefix(String id,int exponent,String flag,String...names) {
+ this.id=id;
+ this.name = this.name().toLowerCase();
+ this.exponent=exponent;
+ List f = new ArrayList<>(3);
+ f.add(TYPE_FLAG_SI_UNIT);
+ if (exponent > 3 || exponent < -3) {
+ f.add(TYPE_FLAG_SI_UNIT_BIGGER);
+ }
+ if (exponent > 12 || exponent < -12) {
+ f.add(TYPE_FLAG_SI_UNIT_BIGGEST);
+ }
+ if (flag != null) {
+ f.add(flag);
+ }
+ this.flags = Collections.unmodifiableList(f);
+ List n = new ArrayList<>(2);
+ n.addAll(Arrays.asList(names));
+ this.nameAliases = Collections.unmodifiableList(n);
+ }
+
+ public String getPrefixId() {
+ return id;
+ }
+
+ public String getPrefixName() {
+ return name;
+ }
+
+ public int getExponent() {
+ return exponent;
+ }
+
+ public List getFlags() {
+ return flags;
+ }
+
+ public List getNameAliases() {
+ return nameAliases;
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCTypeSIPrefixBuilder.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCTypeSIPrefixBuilder.java
new file mode 100644
index 00000000..f2ab47c2
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCTypeSIPrefixBuilder.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.config.builder;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import net.forwardfire.unitxc.model.DefaultUnitXCType;
+import net.forwardfire.unitxc.model.UnitXCType;
+import net.forwardfire.unitxc.model.step.UnitXCConverterStepPowerOfTen;
+import net.forwardfire.unitxc.model.step.UnitXConverterStepContext;
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 22, 2015
+ */
+public class UnitXCTypeSIPrefixBuilder
extends AbstractUnitXCTypeBuilder
> {
+
+ private final UnitXCGroupBaseBuilder builder;
+ private final List commonSIPrefixes;
+
+ public UnitXCTypeSIPrefixBuilder(P parent, UnitXCGroupBaseBuilder builder) {
+ super(parent,new DefaultUnitXCType(), (p,v) -> {});
+ this.builder = builder;
+ this.commonSIPrefixes = new ArrayList<>();
+ }
+
+ @Override
+ protected UnitXCTypeSIPrefixBuilder
addCommonSIPrefix(UnitXCTypeSIPrefix prefix) {
+ return make((v) -> commonSIPrefixes.add(prefix));
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXConverterStepBuilder.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXConverterStepBuilder.java
new file mode 100644
index 00000000..2c2c6d9b
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/UnitXConverterStepBuilder.java
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.config.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.function.BiConsumer;
+import java.util.function.Supplier;
+
+import org.apache.commons.lang3.Validate;
+import org.apache.commons.lang3.math.Fraction;
+
+import net.forwardfire.unitxc.model.step.UnitXCConverterStepOperation;
+import net.forwardfire.unitxc.model.step.UnitXCConverterStepOperationOperator;
+import net.forwardfire.unitxc.model.step.UnitXCConverterStepPowerOfTen;
+import net.forwardfire.unitxc.model.step.UnitXConverterStep;
+import net.forwardfire.unitxc.model.step.UnitXConverterStepContext;
+import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueRead;
+import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueReferenceDouble;
+import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueReferenceDoubleFraction;
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 23, 2015
+ */
+public class UnitXConverterStepBuilder
> extends AbstractUnitXCBuilder
,UnitXConverterStepBuilder
> {
+
+ private final Supplier stepReason;
+
+ public UnitXConverterStepBuilder(P parent, BiConsumer
power10Down(UnitXCTypeSIPrefix exponent) {
+ return power10Down(exponent,createStepReason());
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/package-info.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/package-info.java
new file mode 100644
index 00000000..153fb496
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/builder/package-info.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/**
+ * @author willemc
+ *
+ */
+package net.forwardfire.unitxc.config.builder;
\ No newline at end of file
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/package-info.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/package-info.java
new file mode 100644
index 00000000..9055cbde
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/config/package-info.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/**
+ * @author willemc
+ *
+ */
+package net.forwardfire.unitxc.config;
\ No newline at end of file
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/converter/UnitXConverter.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/converter/UnitXConverter.java
new file mode 100644
index 00000000..e2eecd67
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/converter/UnitXConverter.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.converter;
+
+import java.math.BigDecimal;
+import java.util.Collections;
+import java.util.Map;
+
+import org.apache.commons.lang3.Validate;
+
+import net.forwardfire.unitxc.UnitXCManager;
+import net.forwardfire.unitxc.model.UnitXCType;
+import net.forwardfire.unitxc.model.UnitXConverterResult;
+
+/**
+ * Converts value to value.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 8, 2015
+ */
+public class UnitXConverter {
+
+ private final UnitXCManager unitManager;
+ private final UnitXConverterEngine convertEngine;
+
+ public UnitXConverter(UnitXCManager unitManager) {
+ this.unitManager = Validate.notNull(unitManager);
+ this.convertEngine = new UnitXConverterEngine(unitManager);
+ }
+
+ private UnitXCType getUnitType(String id) {
+ return Validate.notNull(unitManager.getUnitType(id),"Could not resolve unit type for id; '"+id+"'");
+ }
+
+ public double convert(double value, String fromTypeId, String toTypeId) {
+ return convert(value, getUnitType(fromTypeId), getUnitType(toTypeId));
+ }
+
+ public double convert(double value, UnitXCType fromType, UnitXCType toType) {
+ return convertStepped(value,fromType,toType).getResultValue();
+ }
+
+ public UnitXConverterResult convertStepped(double value, String fromTypeId, String toTypeId) {
+ return convertStepped(value, getUnitType(fromTypeId), getUnitType(toTypeId));
+ }
+
+ public UnitXConverterResult convertStepped(double value, String fromTypeId, String toTypeId,Map parameters) {
+ return convertStepped(value, getUnitType(fromTypeId), getUnitType(toTypeId), parameters);
+ }
+
+ public UnitXConverterResult convertStepped(double value, UnitXCType fromType, UnitXCType toType) {
+ return convertStepped(value, fromType, toType, Collections.emptyMap());
+ }
+
+ public UnitXConverterResult convertStepped(double value, UnitXCType fromType, UnitXCType toType, Map parameters) {
+ return convertStepped(BigDecimal.valueOf(value), fromType, toType, parameters);
+ }
+
+ public UnitXConverterResult convertStepped(BigDecimal value, UnitXCType fromType, UnitXCType toType, Map parameters) {
+ return convertEngine.convertStepped(value, fromType, toType, parameters);
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/converter/UnitXConverterEngine.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/converter/UnitXConverterEngine.java
new file mode 100644
index 00000000..7697887a
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/converter/UnitXConverterEngine.java
@@ -0,0 +1,220 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.converter;
+
+import java.math.BigDecimal;
+import java.math.MathContext;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang3.Validate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.forwardfire.unitxc.UnitXCManager;
+import net.forwardfire.unitxc.model.DefaultUnitXConverterResult;
+import net.forwardfire.unitxc.model.DefaultUnitXConverterResultStep;
+import net.forwardfire.unitxc.model.UnitXCGroup;
+import net.forwardfire.unitxc.model.UnitXCGroupJump;
+import net.forwardfire.unitxc.model.UnitXCGroupJumpParameter;
+import net.forwardfire.unitxc.model.UnitXCType;
+import net.forwardfire.unitxc.model.UnitXConverterResult;
+import net.forwardfire.unitxc.model.UnitXConverterResultStep;
+import net.forwardfire.unitxc.model.step.UnitXCConverterStepAutoRounding;
+import net.forwardfire.unitxc.model.step.UnitXConverterStep;
+import net.forwardfire.unitxc.model.step.UnitXConverterStepContext;
+import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueRead;
+import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueReadWrite;
+import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueReferenceDouble;
+
+/**
+ * Runs requested convert steps and builds result models.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 17, 2015
+ */
+public final class UnitXConverterEngine {
+
+ private final static Logger LOG = LoggerFactory.getLogger(UnitXConverterEngine.class);
+ private final UnitXCManager manager;
+ private final UnitXConverterStep roundingStep;
+
+ public UnitXConverterEngine(UnitXCManager manager) {
+ this.manager = manager;
+ this.roundingStep = new UnitXCConverterStepAutoRounding(UnitXConverterStepContext.createStepValue(),UnitXConverterStepContext.createStepValue());
+ }
+
+ public UnitXConverterResult convertStepped(BigDecimal valueConvert2,UnitXCType fromType,UnitXCType toType, Map parameters) {
+ Validate.notNull(valueConvert2,"Can't convert null to number");
+ Validate.notNull(fromType,"Can't convert from null unit type");
+ Validate.notNull(toType,"Can't convert to null unit type");
+
+
+ if (fromType.getAliasOfType() != null) {
+ fromType = Validate.notNull(manager.getUnitType(fromType.getAliasOfType()),"Coultn't resolve alias id: "+fromType.getAliasOfType()+" for: "+fromType.getId());
+ }
+ if (toType.getAliasOfType() != null) {
+ toType = Validate.notNull(manager.getUnitType(toType.getAliasOfType()),"Coultn't resolve alias id: "+toType.getAliasOfType()+" for: "+toType.getId());
+ }
+
+ double valueConvert = valueConvert2.doubleValue();
+ long startTime = System.currentTimeMillis();
+ MathContext mathContext = MathContext.DECIMAL128;
+ UnitXConverterStepContextImpl ctx = new UnitXConverterStepContextImpl(mathContext,valueConvert);
+
+ UnitXCGroup fromTypeGroup = fromType.getUnitGroup();
+ UnitXCGroup toTypeGroup = toType.getUnitGroup();
+ UnitXCGroupJump crossGroupJump = null; // List<> after multi level search
+
+ if (!fromTypeGroup.getId().equals(toTypeGroup.getId())) {
+ for (UnitXCGroupJump groupJump:fromTypeGroup.getGroupJumps()) { // FIXME
+ if (toTypeGroup.getId().equals(groupJump.getUnitGroupId())) {
+ crossGroupJump = groupJump;
+ break;
+ }
+ }
+ if (crossGroupJump == null) {
+ throw new IllegalArgumentException("from and to groups are not equals: "+fromTypeGroup.getId()+" != "+toTypeGroup.getId());
+ }
+ for (UnitXCGroupJumpParameter jumpPara:crossGroupJump.getJumpParameters()) {
+ if (!parameters.containsKey(jumpPara.getId())) {
+ throw new IllegalArgumentException("Missing required convert parameter: "+jumpPara.getId());
+ }
+ UnitXConverterParameterValue convPara = parameters.get(jumpPara.getId());
+ if (convPara.getValueType() == null) {
+ throw new IllegalArgumentException("Convert parameter has not type: "+jumpPara.getId());
+ }
+ if (!jumpPara.getUnitGroupId().equals(convPara.getValueType().getUnitGroup().getId())) {
+ throw new IllegalArgumentException("Convert parameter is wrong group required: "+jumpPara.getUnitGroupId()+" got: "+convPara.getValueType().getUnitGroup().getId());
+ }
+ boolean paraToBase = convPara.getValueType().getUnitGroup().getBaseTypeId().equals(convPara.getValueType().getId());
+ double paraValue = convPara.getValue();
+ if (!paraToBase) {
+ System.out.println("--- cont para");;
+ UnitXConverterResult res = convertStepped(BigDecimal.valueOf(paraValue), convPara.getValueType(), manager.getUnitType(convPara.getValueType().getUnitGroup().getBaseTypeId()), parameters); // FIXME rm parameters ?
+ paraValue = res.getResultValue();
+ //ctx.resultSteps.addAll(res.getResultSteps());
+ }
+ ctx.namedParameter.put(jumpPara.getId(), new UnitXConverterStepValueReferenceDouble(paraValue));
+ }
+ }
+
+ boolean fromTypeBase = fromTypeGroup.getBaseTypeId().equals(fromType.getId());
+ if (!fromTypeBase) {
+ ctx.runSteps(fromType.getToBaseConverterSteps());
+ }
+
+ if (crossGroupJump != null) {
+ ctx.runSteps(crossGroupJump.getToGroupConverterSteps());
+ }
+
+ boolean toTypeBase = toTypeGroup.getBaseTypeId().equals(toType.getId());
+ if (!toTypeBase) {
+ ctx.runSteps(toType.getFromBaseConverterSteps());
+ }
+
+ long convertTime = System.currentTimeMillis()-startTime;
+ DefaultUnitXConverterResult result = new DefaultUnitXConverterResult();
+// result.setStartValue(ctx.getStartValue());
+ result.setStartTypeId(fromType.getId());
+ result.setResultValue(ctx.getValue());
+ result.setResultTypeId(toType.getId());
+ result.setConvertTime(convertTime);
+ result.setResultSteps(ctx.resultSteps);
+ return result;
+ }
+
+ class UnitXConverterStepContextImpl implements UnitXConverterStepContext {
+
+ final MathContext mathContext;
+ List resultSteps = new ArrayList<>();
+ Map namedVariables = new HashMap<>();
+ Map namedParameter = new HashMap<>();
+
+ public UnitXConverterStepContextImpl(MathContext mathContext, double startValue) {
+ this.mathContext = Validate.notNull(mathContext);
+ setNamedVariable(VALUE, new UnitXConverterStepValueReferenceDouble(startValue));
+ setNamedVariable(VALUE_START, new UnitXConverterStepValueReferenceDouble(startValue));
+ }
+
+ @Override
+ public void setNamedVariable(String name,UnitXConverterStepValueReadWrite variable) {
+ namedVariables.put(Validate.notBlank(name,"name is blank"),Validate.notNull(variable,"variable is null"));
+ }
+
+ @Override
+ public UnitXConverterStepValueReadWrite getNamedVariable(String name) {
+ return Validate.notNull(namedVariables.get(Validate.notBlank(name,"name is blank")),"named variable not found: "+name);
+ }
+
+ @Override
+ public UnitXConverterStepValueRead getNamedParameter(String name) {
+ return Validate.notNull(namedParameter.get(Validate.notBlank(name,"name is blank")),"named parameter not found: "+name);
+ }
+
+ @Override
+ public void runSteps(List steps) {
+ for (UnitXConverterStep step:steps) {
+ runStep(step);
+ if (roundingStep != null) {
+ runStep(roundingStep);
+ }
+ }
+ }
+
+ private void runStep(UnitXConverterStep step) {
+
+ long startTime = System.currentTimeMillis();
+ double valueOld = getValue();
+ step.runStep(this);
+ long convertTime = System.currentTimeMillis()-startTime;
+
+// System.out.println("runStep: "+step+" res: "+step.getStepReasons());
+
+ DefaultUnitXConverterResultStep resultStep = new DefaultUnitXConverterResultStep();
+ resultStep.setStartValue(valueOld);
+ resultStep.setResultValue(getValue());
+ resultStep.setConvertTime(convertTime);
+ resultStep.setConvertStep(step);
+ resultSteps.add(resultStep);
+// previousValue = valueOld;
+ }
+
+ private Double getValue() {
+ return (Double)(getNamedVariable(VALUE).valueRead(this));
+ }
+
+ @Override
+ public MathContext getMathContext() {
+ return mathContext;
+ }
+
+// @Override
+// public UnitXCManager getUnitManager() {
+// return manager;
+// }
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/converter/UnitXConverterParameterValue.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/converter/UnitXConverterParameterValue.java
new file mode 100644
index 00000000..b7295ca0
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/converter/UnitXConverterParameterValue.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.converter;
+
+import org.apache.commons.lang3.Validate;
+
+import net.forwardfire.unitxc.model.UnitXCType;
+
+/**
+ * Holds the parameter value and type.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Mar 18, 2016
+ */
+public final class UnitXConverterParameterValue {
+
+ private double value;
+ private UnitXCType valueType;
+
+ public UnitXConverterParameterValue() {
+ }
+
+ public UnitXConverterParameterValue(double value,UnitXCType valueType) {
+ setValue(value);
+ setValueType(Validate.notNull(valueType));
+ }
+
+ /**
+ * @return the value
+ */
+ public double getValue() {
+ return value;
+ }
+
+ /**
+ * @param value the value to set
+ */
+ public void setValue(double value) {
+ this.value = value;
+ }
+
+ /**
+ * @return the valueType
+ */
+ public UnitXCType getValueType() {
+ return valueType;
+ }
+
+ /**
+ * @param valueType the valueType to set
+ */
+ public void setValueType(UnitXCType valueType) {
+ this.valueType = valueType;
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/converter/package-info.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/converter/package-info.java
new file mode 100644
index 00000000..e80f2f39
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/converter/package-info.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/**
+ * @author willemc
+ *
+ */
+package net.forwardfire.unitxc.converter;
\ No newline at end of file
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/AbstractUnitXCGroup.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/AbstractUnitXCGroup.java
new file mode 100644
index 00000000..3aa89964
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/AbstractUnitXCGroup.java
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.model;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.lang3.Validate;
+import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
+
+/**
+ * The unit group.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 10, 2015
+ */
+abstract public class AbstractUnitXCGroup implements UnitXCGroup {
+
+ private final String id;
+ private final UnitXCResourceValue name;
+ private final UnitXCResourceValue description;
+ private String baseTypeId;
+ private final List quantities;
+ private final List derivedFrom;
+ private final List unitTypes;
+ private final List groupJumps;
+
+ public AbstractUnitXCGroup(UnitXCResourceBundle bundle, String id) {
+ quantities = new ArrayList<>();
+ derivedFrom = new ArrayList<>();
+ unitTypes = new ArrayList<>();
+ groupJumps = new ArrayList<>();
+ this.name = new DefaultUnitXCResourceValue(bundle,"group."+id+".name");
+ this.description = new DefaultUnitXCResourceValue(bundle,"group."+id+".description");
+ this.id = id;
+ }
+
+ public AbstractUnitXCGroup validate() {
+ Validate.notBlank(id,"The id is blank");
+ Validate.notBlank(baseTypeId,"The baseTypeId is blank");
+ return this;
+ }
+
+ abstract long localUnitTypeSize();
+ abstract Iterator localUnitTypeIds();
+ abstract UnitXCType localUnitType(String id);
+
+ @Override
+ final public long getUnitTypeSize() {
+ return getUnitTypes().size() + localUnitTypeSize();
+ }
+
+ @Override
+ final public Iterator getUnitTypeIds() {
+ Iterator l = localUnitTypeIds();
+ List result = new ArrayList<>();
+ getUnitTypes().forEach(t -> result.add(t.getId()));
+ Iterator g = result.iterator();
+ return new Iterator() {
+ @Override
+ public boolean hasNext() {
+ if (l.hasNext()) {
+ return true;
+ }
+ return g.hasNext();
+ }
+ @Override
+ public String next() {
+ if (l.hasNext()) {
+ return l.next();
+ }
+ return g.next();
+ }
+ };
+ }
+
+ @Override
+ final public UnitXCType getUnitType(String id) {
+ for (UnitXCType type:getUnitTypes()) {
+ if (type.getId().equals(id)) {
+ return type;
+ }
+ if (type.getName().equals(id)) {
+ return type;
+ }
+ }
+ return localUnitType(id);
+ }
+
+
+
+ /**
+ * @return the id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @return the name
+ */
+ public UnitXCResourceValue getName() {
+ return name;
+ }
+
+ /**
+ * @return the description
+ */
+ public UnitXCResourceValue getDescription() {
+ return description;
+ }
+
+ /**
+ * @return the baseTypeId
+ */
+ public String getBaseTypeId() {
+ return baseTypeId;
+ }
+
+ /**
+ * @param baseTypeId the baseTypeId to set
+ */
+ public void setBaseTypeId(String baseTypeId) {
+ this.baseTypeId = baseTypeId;
+ }
+
+ /**
+ * @return the quantities of the group.
+ */
+ public List getQuantities() {
+ return quantities;
+ }
+
+ public void addQuantity(UnitXCGroupQuantity quantity) {
+ this.quantities.add(quantity);
+ }
+
+ /**
+ * @return the derivedFrom
+ */
+ public List getDerivedFrom() {
+ return derivedFrom;
+ }
+
+ /**
+ * @param derivedFrom the derivedFrom to add
+ */
+ public void addDerivedFrom(String derivedFrom) {
+ this.derivedFrom.add(derivedFrom);
+ }
+
+ /**
+ * @return the unit types.
+ */
+ public List getUnitTypes() {
+ return unitTypes;
+ }
+
+ public void addUnitType(DefaultUnitXCType type) {
+ Validate.notNull(type);
+ type.setUnitGroup(this);
+ type.validate();
+ unitTypes.add(type);
+ }
+
+ /**
+ * @return the groupJumps
+ */
+ public List getGroupJumps() {
+ return groupJumps;
+ }
+
+ /**
+ * @param groupJump the groupJump to add
+ */
+ public void addGroupJump(UnitXCGroupJump groupJump) {
+ this.groupJumps.add(groupJump);
+ }
+
+ @Override
+ final public String toString() {
+ return ReflectionToStringBuilder.toString(this);
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/DefaultUnitXCGroupJump.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/DefaultUnitXCGroupJump.java
new file mode 100644
index 00000000..6761af86
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/DefaultUnitXCGroupJump.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang3.Validate;
+
+import net.forwardfire.unitxc.model.step.UnitXConverterStep;
+
+/**
+ * The unit group jump.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Apr 1, 2016
+ */
+public class DefaultUnitXCGroupJump implements UnitXCGroupJump {
+
+ private String id;
+ private String unitGroupId;
+ private final List toGroupConverterSteps;
+ private final List jumpParameters;
+
+ public DefaultUnitXCGroupJump() {
+ toGroupConverterSteps = new ArrayList<>();
+ jumpParameters = new ArrayList<>();
+ }
+
+ public UnitXCGroupJump validate() {
+ Validate.notBlank(id,"The id is blank");
+ Validate.notBlank(unitGroupId,"The unitGroupId is blank of: "+id);
+ return this;
+ }
+
+ /**
+ * @return the id
+ */
+ public String getId() {
+ return id;
+ }
+ /**
+ * @param id the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the toGroupId
+ */
+ public String getUnitGroupId() {
+ return unitGroupId;
+ }
+
+ /**
+ * @param unitGroupId the unitGroupId to set
+ */
+ public void setUnitGroupId(String unitGroupId) {
+ this.unitGroupId = unitGroupId;
+ }
+
+ /**
+ * @return the toGroupConverterSteps
+ */
+ public List getToGroupConverterSteps() {
+ return toGroupConverterSteps;
+ }
+
+ /**
+ * @param toGroupConverterSteps the toGroupConverterSteps to set
+ */
+ public void setToBaseConverterSteps(List toGroupConverterSteps) {
+ this.toGroupConverterSteps.clear();
+ this.toGroupConverterSteps.addAll(toGroupConverterSteps);
+ }
+
+ /**
+ * @return the jumpParameters
+ */
+ public List getJumpParameters() {
+ return jumpParameters;
+ }
+
+ /**
+ * @param jumpParameters the jumpParameters to set
+ */
+ public void setJumpParameters(List jumpParameters) {
+ this.jumpParameters.clear();
+ this.jumpParameters.addAll(jumpParameters);
+ }
+
+ public void addJumpParameter(UnitXCGroupJumpParameter jumpParameter) {
+ this.jumpParameters.add(Validate.notNull(jumpParameter));
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/DefaultUnitXCGroupJumpParameter.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/DefaultUnitXCGroupJumpParameter.java
new file mode 100644
index 00000000..b8509082
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/DefaultUnitXCGroupJumpParameter.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.model;
+
+import org.apache.commons.lang3.Validate;
+
+/**
+ * The unit group jump.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Apr 1, 2016
+ */
+public class DefaultUnitXCGroupJumpParameter implements UnitXCGroupJumpParameter {
+
+ private String id;
+ private String unitGroupId;
+
+ public DefaultUnitXCGroupJumpParameter() {
+ }
+
+ public DefaultUnitXCGroupJumpParameter(String id,String unitGroupId) {
+ setId(id);
+ setUnitGroupId(unitGroupId);
+ }
+
+ public DefaultUnitXCGroupJumpParameter validate() {
+ Validate.notBlank(id,"The id is blank");
+ Validate.notBlank(unitGroupId,"The unitGroup is blank of: "+id);
+ return this;
+ }
+
+ /**
+ * @return the id
+ */
+ public String getId() {
+ return id;
+ }
+ /**
+ * @param id the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the unitGroupId
+ */
+ public String getUnitGroupId() {
+ return unitGroupId;
+ }
+
+ /**
+ * @param unitGroupId the unitGroupId to set
+ */
+ public void setUnitGroupId(String unitGroupId) {
+ this.unitGroupId = unitGroupId;
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/DefaultUnitXCGroupQuantity.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/DefaultUnitXCGroupQuantity.java
new file mode 100644
index 00000000..24fb0151
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/DefaultUnitXCGroupQuantity.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.model;
+
+/**
+ * The unit group quantity.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 31, 2016
+ */
+public class DefaultUnitXCGroupQuantity implements UnitXCGroupQuantity {
+
+ private final String id;
+ private final UnitXCResourceValue name;
+ private final UnitXCResourceValue wikiLink;
+
+ public DefaultUnitXCGroupQuantity(UnitXCResourceBundle bundle, String parentKey, String id) {
+ this.name = new DefaultUnitXCResourceValue(bundle,parentKey+"."+id+".name");
+ this.wikiLink = new DefaultUnitXCResourceValue(bundle,parentKey+"."+id+".wikiLink");
+ this.id = id;
+ }
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public UnitXCResourceValue getName() {
+ return name;
+ }
+
+ @Override
+ public UnitXCResourceValue getWikiLink() {
+ return wikiLink;
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/DefaultUnitXCResourceValue.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/DefaultUnitXCResourceValue.java
new file mode 100644
index 00000000..5f93b10a
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/DefaultUnitXCResourceValue.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.model;
+
+import java.util.List;
+
+/**
+ * The resource value wrapper holder
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 31, 2016
+ */
+public class DefaultUnitXCResourceValue implements UnitXCResourceValue {
+
+ private final UnitXCResourceBundle bundle;
+ private final String bundleKey;
+
+ public DefaultUnitXCResourceValue(UnitXCResourceBundle bundle, String bundleKey) {
+ super();
+ this.bundle = bundle;
+ this.bundleKey = bundleKey;
+ }
+
+ @Override
+ public String getBundleKey() {
+ return bundleKey;
+ }
+
+ @Override
+ public List getLanguages() {
+ return bundle.getValueLanguages(getBundleKey());
+ }
+
+ @Override
+ public String getValue(String language) {
+ return bundle.getValue(language, getBundleKey());
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/DefaultUnitXCType.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/DefaultUnitXCType.java
new file mode 100644
index 00000000..75119aa1
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/DefaultUnitXCType.java
@@ -0,0 +1,207 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang3.Validate;
+import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
+
+import net.forwardfire.unitxc.model.step.UnitXConverterStep;
+
+/**
+ * The unit type.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 10, 2015
+ */
+public class DefaultUnitXCType implements UnitXCType {
+
+ private String id;
+ private String name;
+ private String namePlural;
+ private String aliasOfType;
+ private UnitXCGroup unitGroup;
+ private String weblink;
+ private final List toBaseConverterSteps;
+ private final List fromBaseConverterSteps;
+ private final List typeFlags;
+
+ public DefaultUnitXCType() {
+ typeFlags = new ArrayList<>();
+ toBaseConverterSteps = new ArrayList<>();
+ fromBaseConverterSteps = new ArrayList<>();
+ }
+
+ public UnitXCType validate() {
+ Validate.notBlank(id,"The id is blank");
+ Validate.notBlank(name,"The name is blank of: "+id);
+ //Validate.notBlank(namePlural,"The namePlural is blank of: "+id);
+ Validate.notNull(unitGroup,"The unitGroup is null of: "+id);
+ return this;
+ }
+
+ /**
+ * @return the id
+ */
+ @Override
+ public String getId() {
+ return id;
+ }
+ /**
+ * @param id the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the name
+ */
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the namePlural
+ */
+ @Override
+ public String getNamePlural() {
+ return namePlural;
+ }
+
+ /**
+ * @param namePlural the namePlural to set
+ */
+ public void setNamePlural(String namePlural) {
+ this.namePlural = namePlural;
+ }
+
+ /**
+ * @return the aliasOfType
+ */
+ @Override
+ public String getAliasOfType() {
+ return aliasOfType;
+ }
+
+ /**
+ * @param aliasOfType the aliasOfType to set
+ */
+ public void setAliasOfType(String aliasOfType) {
+ this.aliasOfType = aliasOfType;
+ }
+
+ /**
+ * @return the unitGroup
+ */
+ @Override
+ public UnitXCGroup getUnitGroup() {
+ return unitGroup;
+ }
+
+ /**
+ * @param unitGroup the unitGroup to set
+ */
+ public void setUnitGroup(UnitXCGroup unitGroup) {
+ this.unitGroup = unitGroup;
+ }
+
+ /**
+ * @return the toBaseConverterSteps
+ */
+ @Override
+ public List getToBaseConverterSteps() {
+ return toBaseConverterSteps;
+ }
+
+ /**
+ * @param toBaseConverterSteps the toBaseConverterSteps to set
+ */
+ public void setToBaseConverterSteps(List toBaseConverterSteps) {
+ this.toBaseConverterSteps.clear();
+ this.toBaseConverterSteps.addAll(toBaseConverterSteps);
+ }
+
+ /**
+ * @return the fromBaseConverterSteps
+ */
+ @Override
+ public List getFromBaseConverterSteps() {
+ return fromBaseConverterSteps;
+ }
+
+ /**
+ * @param fromBaseConverterSteps the fromBaseConverterSteps to set
+ */
+ public void setFromBaseConverterSteps(List fromBaseConverterSteps) {
+ this.fromBaseConverterSteps.clear();
+ this.fromBaseConverterSteps.addAll(fromBaseConverterSteps);
+ }
+
+ /**
+ * @return the typeFlags
+ */
+ @Override
+ public List getTypeFlags() {
+ return typeFlags;
+ }
+
+ /**
+ * @param typeFlags the typeFlags to set
+ */
+ public void setTypeFlags(List typeFlags) {
+ this.typeFlags.clear();
+ this.typeFlags.addAll(typeFlags);
+ }
+
+ /**
+ * @return the weblink
+ */
+ @Override
+ public String getWebLink() {
+ return weblink;
+ }
+
+ /**
+ * @param webLink the webLink to set
+ */
+ public void setWebLink(String weblink) {
+ this.weblink = weblink;
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this);
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/DefaultUnitXConverterResult.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/DefaultUnitXConverterResult.java
new file mode 100644
index 00000000..c3b0bf9e
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/DefaultUnitXConverterResult.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.model;
+
+import java.util.List;
+
+import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
+
+/**
+ * Holds the convert result and meta steps how we got there.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 17, 2015
+ */
+public class DefaultUnitXConverterResult implements UnitXConverterResult {
+
+ private Double startValue;
+ private List resultSteps;
+ private Double resultValue;
+ private Long convertTime;
+ private String startTypeId;
+ private String resultTypeId;
+
+ /**
+ * @return the startValue
+ */
+ public Double getStartValue() {
+ return startValue;
+ }
+
+ /**
+ * @param startValue the startValue to set
+ */
+ public void setStartValue(Double startValue) {
+ this.startValue = startValue;
+ }
+
+ /**
+ * @return the resultSteps
+ */
+ public List getResultSteps() {
+ return resultSteps;
+ }
+
+ /**
+ * @param resultSteps the resultSteps to set
+ */
+ public void setResultSteps(List resultSteps) {
+ this.resultSteps = resultSteps;
+ }
+
+ /**
+ * @return the resultValue
+ */
+ public Double getResultValue() {
+ return resultValue;
+ }
+
+ /**
+ * @param resultValue the resultValue to set
+ */
+ public void setResultValue(Double resultValue) {
+ this.resultValue = resultValue;
+ }
+
+ /**
+ * @return the convertTime
+ */
+ public Long getConvertTime() {
+ return convertTime;
+ }
+
+ /**
+ * @param convertTime the convertTime to set
+ */
+ public void setConvertTime(Long convertTime) {
+ this.convertTime = convertTime;
+ }
+
+ /**
+ * @return the startTypeId
+ */
+ public String getStartTypeId() {
+ return startTypeId;
+ }
+
+ /**
+ * @param startTypeId the startTypeId to set
+ */
+ public void setStartTypeId(String startTypeId) {
+ this.startTypeId = startTypeId;
+ }
+
+ /**
+ * @return the resultTypeId
+ */
+ public String getResultTypeId() {
+ return resultTypeId;
+ }
+
+ /**
+ * @param resultTypeId the resultTypeId to set
+ */
+ public void setResultTypeId(String resultTypeId) {
+ this.resultTypeId = resultTypeId;
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this);
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/DefaultUnitXConverterResultStep.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/DefaultUnitXConverterResultStep.java
new file mode 100644
index 00000000..e917f87a
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/DefaultUnitXConverterResultStep.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.model;
+
+import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
+
+import net.forwardfire.unitxc.model.step.UnitXConverterStep;
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 17, 2015
+ */
+public class DefaultUnitXConverterResultStep implements UnitXConverterResultStep {
+
+ private Double startValue;
+ private Double resultValue;
+ private Long convertTime;
+ private UnitXConverterStep convertStep;
+
+ /**
+ * @return the startValue
+ */
+ public Double getStartValue() {
+ return startValue;
+ }
+
+ /**
+ * @param startValue the startValue to set
+ */
+ public void setStartValue(Double startValue) {
+ this.startValue = startValue;
+ }
+
+ /**
+ * @return the resultValue
+ */
+ public Double getResultValue() {
+ return resultValue;
+ }
+
+ /**
+ * @param resultValue the resultValue to set
+ */
+ public void setResultValue(Double resultValue) {
+ this.resultValue = resultValue;
+ }
+
+ /**
+ * @return the convertTime
+ */
+ public Long getConvertTime() {
+ return convertTime;
+ }
+
+ /**
+ * @param convertTime the convertTime to set
+ */
+ public void setConvertTime(Long convertTime) {
+ this.convertTime = convertTime;
+ }
+
+ /**
+ * @return the convertStep
+ */
+ public UnitXConverterStep getConvertStep() {
+ return convertStep;
+ }
+
+ /**
+ * @param convertStep the convertStep to set
+ */
+ public void setConvertStep(UnitXConverterStep convertStep) {
+ this.convertStep = convertStep;
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this);
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/UnitXCConfig.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/UnitXCConfig.java
new file mode 100644
index 00000000..7950f6d7
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/UnitXCConfig.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.commons.lang3.Validate;
+
+/**
+ * The unit config.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 17, 2015
+ */
+public class UnitXCConfig {
+
+ private UnitXCRounding rounding;
+ private final List unitGroups;
+ private final List languages;
+
+ public UnitXCConfig() {
+ unitGroups = new ArrayList<>();
+ languages = new ArrayList<>();
+ }
+
+ /**
+ * @return the rounding
+ */
+ public UnitXCRounding getRounding() {
+ return rounding;
+ }
+
+ /**
+ * @param rounding the rounding to set
+ */
+ public void setRounding(UnitXCRounding rounding) {
+ this.rounding = rounding;
+ }
+
+ /**
+ * @return the unit groups.
+ */
+ public List getUnitGroups() {
+ return unitGroups;
+ }
+
+ public void addUnitGroup(AbstractUnitXCGroup group) {
+ Validate.notNull(group);
+ group.validate();
+ unitGroups.add(group);
+ }
+
+ public List getLanguages() {
+ return languages;
+ }
+
+ public void addLanguage(Locale language) {
+ languages.add(Validate.notNull(language));
+ }
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/UnitXCGroup.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/UnitXCGroup.java
new file mode 100644
index 00000000..57334c18
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/UnitXCGroup.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.model;
+
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * The unit group.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 10, 2015
+ */
+public interface UnitXCGroup {
+
+ /**
+ * @return the id
+ */
+ String getId();
+
+ /**
+ * @return the name
+ */
+ UnitXCResourceValue getName();
+
+ /**
+ * @return the description
+ */
+ UnitXCResourceValue getDescription();
+
+ /**
+ * @return the baseTypeId
+ */
+ String getBaseTypeId();
+
+ /**
+ * @return the quantities of the group.
+ */
+ List getQuantities();
+
+ /**
+ * @return the derivedFrom
+ */
+ List getDerivedFrom();
+
+ /**
+ * @return the groupJumps
+ */
+ List getGroupJumps();
+
+ /**
+ * @return the totalUnitTypes
+ */
+ long getUnitTypeSize();
+
+ Iterator getUnitTypeIds();
+
+ UnitXCType getUnitType(String id);
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/UnitXCGroupBase.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/UnitXCGroupBase.java
new file mode 100644
index 00000000..c8f79ffb
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/UnitXCGroupBase.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.model;
+
+import java.util.Collections;
+import java.util.Iterator;
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 28, 2016
+ */
+public class UnitXCGroupBase extends AbstractUnitXCGroup {
+
+ public UnitXCGroupBase(UnitXCResourceBundle bundle, String id) {
+ super(bundle, id);
+ }
+
+ @Override
+ public long localUnitTypeSize() {
+ return 0L;
+ }
+
+ @Override
+ public Iterator localUnitTypeIds() {
+ return Collections.emptyIterator();
+ }
+
+ @Override
+ public UnitXCType localUnitType(String id) {
+ return null;
+ }
+
+}
diff --git a/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/UnitXCGroupCompoundExponent.java b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/UnitXCGroupCompoundExponent.java
new file mode 100644
index 00000000..bb83cb73
--- /dev/null
+++ b/gdxapp4d-unitxc/src/main/java/net/forwardfire/unitxc/model/UnitXCGroupCompoundExponent.java
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2013-2015, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.unitxc.model;
+
+import java.util.Iterator;
+
+import org.apache.commons.lang3.Validate;
+
+import net.forwardfire.unitxc.config.builder.UnitXCTypeBuilder;
+import net.forwardfire.unitxc.model.step.UnitXCConverterStepReference;
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 28, 2016
+ */
+public class UnitXCGroupCompoundExponent extends AbstractUnitXCGroup {
+
+ private final UnitXCGroup parentGroup;
+ private final int exponent;
+ private String unitIdPostfix;
+ private String unitNamePrefix;
+
+ public UnitXCGroupCompoundExponent(UnitXCResourceBundle bundle, String id,UnitXCGroup parentGroup,int exponent) {
+ super(bundle, id);
+ this.parentGroup = Validate.notNull(parentGroup);
+ this.exponent = exponent;
+ Validate.isTrue(exponent > 1);
+ }
+
+ @Override
+ public long localUnitTypeSize() {
+ return getParentGroup().getUnitTypeSize();
+ }
+
+ @Override
+ public Iterator localUnitTypeIds() {
+ Iterator g = getParentGroup().getUnitTypeIds();
+ return new Iterator() {
+ @Override
+ public boolean hasNext() {
+ return g.hasNext();
+ }
+ @Override
+ public String next() {
+ return g.next()+unitIdPostfix;
+ }
+ };
+ }
+
+ @Override
+ public UnitXCType localUnitType(String id) {
+ if (!id.endsWith(unitIdPostfix)) {
+ return null;
+ }
+ String idRaw = id.substring(0, id.length()-unitIdPostfix.length());
+ UnitXCGroup group = getParentGroup();
+ UnitXCType unitType = group.getUnitType(idRaw);
+ if (unitType == null) {
+ return null;
+ }
+
+ DefaultUnitXCType result = new DefaultUnitXCType();
+ UnitXCTypeBuilder