Easter cleaning git

This commit is contained in:
Willem Cazander 2025-04-27 00:09:28 +02:00
commit d0529bfadf
500 changed files with 116670 additions and 0 deletions

53
gdxapp4d-unitxc/pom.xml Normal file
View file

@ -0,0 +1,53 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>love.distributedrebirth.gdxapp4d</groupId>
<artifactId>gdxapp4d</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>gdxapp4d-unitxc</artifactId>
<name>GDXApp⁴ᴰ-Unitˣᶜ</name>
<packaging>bundle</packaging>
<dependencies>
<dependency>
<groupId>love.distributedrebirth.gdxapp4d</groupId>
<artifactId>gdxapp4d-tos4</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<exportScr>true</exportScr>
<niceManifest>true</niceManifest>
<instructions>
<_donotcopy>(.git)</_donotcopy>
<_dsannotations>*</_dsannotations>
<_metatypeannotations>*</_metatypeannotations>
<Import-Package>
${tos4.packages},
org.slf4j,
org.slf4j.event,
org.slf4j.helpers,
org.slf4j.spi,
${lang3.packages},
</Import-Package>
<Export-Package>
${unitxc.packages}
</Export-Package>
<Bundle-Activator>love.distributedrebirth.gdxapp4d.unitxc.UnitXrossConverterActivator</Bundle-Activator>
<Bundle-Vendor>distributedrebirth.love</Bundle-Vendor>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

View file

@ -0,0 +1,62 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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 love.distributedrebirth.gdxapp4d.unitxc;
import java.util.Hashtable;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemGdxLog;
import net.forwardfire.unitxc.UnitXCFactory;
import net.forwardfire.unitxc.UnitXCManager;
import ᒢᐩᐩ.ᔆʸᔆᐪᓫᔿ.ᒃᣔᒃᓫᒻ.ᑊᐣᓑᖮᐪᔆ.DuytsDocAuthor注;
@DuytsDocAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
public class UnitXrossConverterActivator implements BundleActivator {
private UnitXCManager unitManager;
@Override
public void stop(final BundleContext context) {
ServiceReference<SystemGdxLog> loggerRef = context.getServiceReference(SystemGdxLog.class);
SystemGdxLog logger = context.getService(loggerRef);
logger.debug(this, SystemGdxLog.DEACTIVATE);
unitManager = null;
}
@Override
public void start(final BundleContext context) {
ServiceReference<SystemGdxLog> loggerRef = context.getServiceReference(SystemGdxLog.class);
SystemGdxLog logger = context.getService(loggerRef);
logger.debug(this, SystemGdxLog.ACTIVATE);
unitManager = UnitXCFactory.createManager();
context.registerService(UnitXCManager.class.getName(), unitManager, new Hashtable<String, String>());
}
}

View file

@ -0,0 +1,124 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import net.forwardfire.unitxc.config.UnitXCConfigManager;
import net.forwardfire.unitxc.config.UnitXCConfigModule;
import net.forwardfire.unitxc.config.builder.UnitXCConfigBuilder;
import net.forwardfire.unitxc.model.UnitXCConfig;
import net.forwardfire.unitxc.module.UnitXCModuleMole;
import net.forwardfire.unitxc.module.UnitXCModuleAmpere;
import net.forwardfire.unitxc.module.UnitXCModuleMetre;
import net.forwardfire.unitxc.module.UnitXCModuleCandela;
import net.forwardfire.unitxc.module.UnitXCModuleKilogram;
import net.forwardfire.unitxc.module.UnitXCModuleKelvin;
import net.forwardfire.unitxc.module.UnitXCModuleSecond;
import net.forwardfire.unitxc.module.derived.UnitXCModuleMetrePerSecondSquared;
import net.forwardfire.unitxc.module.derived.UnitXCModuleSquareMetre;
import net.forwardfire.unitxc.module.derived.UnitXCModuleKilogramPerSquareMetre;
import net.forwardfire.unitxc.module.derived.UnitXCModuleMetrePerSecondCubed;
import net.forwardfire.unitxc.module.derived.UnitXCModuleMetrePerQuarticSecond;
import net.forwardfire.unitxc.module.derived.UnitXCModuleKilogramPerCubicMetre;
import net.forwardfire.unitxc.module.derived.UnitXCModuleMolePerCubicMetre;
import net.forwardfire.unitxc.module.derived.UnitXCModuleCubicMetrePerMole;
import net.forwardfire.unitxc.module.derived.UnitXCModuleNewtonPerSecond;
import net.forwardfire.unitxc.module.derived.UnitXCModuleCubicMetrePerKilogram;
import net.forwardfire.unitxc.module.derived.UnitXCModuleMetrePerSecond;
import net.forwardfire.unitxc.module.derived.UnitXCModuleCubicMetre;
import net.forwardfire.unitxc.module.derived.UnitXCModuleCubicMetrePerSecond;
import net.forwardfire.unitxc.module.named.UnitXCModuleNewton;
/**
* The unit cross converter factory to create the manager.
*
* @author Willem Cazander
* @version 1.0 Oct 9, 2015
*/
public final class UnitXCFactory {
private static final List<UnitXCConfigModule> DEFAULT_CONFIG_MODULES = Collections.unmodifiableList(Arrays.asList(
new UnitXCModuleKelvin(),
new UnitXCModuleAmpere(),
new UnitXCModuleCandela(),
new UnitXCModuleMole(),
new UnitXCModuleMetre(),
new UnitXCModuleKilogram(),
new UnitXCModuleSecond(),
// currently ordered here
new UnitXCModuleSquareMetre(),
new UnitXCModuleCubicMetre(),
new UnitXCModuleMetrePerSecond(),
new UnitXCModuleCubicMetrePerSecond(),
new UnitXCModuleMetrePerSecondSquared(),
new UnitXCModuleMetrePerSecondCubed(),
new UnitXCModuleMetrePerQuarticSecond(),
// named
new UnitXCModuleNewton(),
// more derived
new UnitXCModuleKilogramPerSquareMetre(),
new UnitXCModuleKilogramPerCubicMetre(),
new UnitXCModuleCubicMetrePerKilogram(),
new UnitXCModuleMolePerCubicMetre(),
new UnitXCModuleCubicMetrePerMole(),
new UnitXCModuleNewtonPerSecond()
));
protected UnitXCFactory() {
}
private static UnitXCConfig buildAll(UnitXCConfig config,List<UnitXCConfigModule> configInit) {
UnitXCConfigBuilder builder = new UnitXCConfigBuilder(config);
configInit.forEach(ci -> ci.configModule(builder));
return config;
}
public static UnitXCConfig createConfig() {
return createConfig(DEFAULT_CONFIG_MODULES);
}
public static UnitXCConfig createConfig(List<UnitXCConfigModule> configInit) {
return buildAll(new UnitXCConfig(), configInit);
}
public static UnitXCManager createManager() {
return createManager(createConfig());
}
public static UnitXCManager createManager(UnitXCConfig config) {
return new UnitXCConfigManager(config);
}
}

View file

@ -0,0 +1,52 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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;
import net.forwardfire.unitxc.converter.UnitXConverter;
import net.forwardfire.unitxc.model.UnitXCType;
import net.forwardfire.unitxc.model.UnitXCConfig;
import net.forwardfire.unitxc.model.UnitXCGroup;
/**
* The unit manager which holds all units/groups and provides access to the converter.
*
* @author Willem Cazander
* @version 1.0 Oct 9, 2015
*/
public interface UnitXCManager {
UnitXCType getUnitType(String id);
UnitXCGroup getUnitGroup(String id);
boolean isUnitGroup(String id);
UnitXConverter getConverter();
UnitXCConfig getConfig();
}

View file

@ -0,0 +1,101 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.Validate;
import net.forwardfire.unitxc.UnitXCManager;
import net.forwardfire.unitxc.converter.UnitXConverter;
import net.forwardfire.unitxc.model.UnitXCType;
import net.forwardfire.unitxc.model.UnitXCConfig;
import net.forwardfire.unitxc.model.UnitXCGroup;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 17, 2015
*/
public class UnitXCConfigManager implements UnitXCManager {
private final UnitXCConfig config;
private final Map<String,UnitXCGroup> unitGroups;
private final UnitXConverter converter;
public UnitXCConfigManager(UnitXCConfig config) {
this.config = Validate.notNull(config);
this.unitGroups = Collections.unmodifiableMap(createUnitGroups(config.getUnitGroups()));
this.converter = new UnitXConverter(this);
}
private static Map<String,UnitXCGroup> createUnitGroups(Collection<UnitXCGroup> values) {
Map<String,UnitXCGroup> result = new HashMap<>();
values.forEach((value) -> {
result.put(value.getId(), value);
});
return result;
}
@Override
public UnitXCConfig getConfig() {
return config;
}
@Override
public UnitXCType getUnitType(String id) {
UnitXCType result = null;
for (UnitXCGroup group:unitGroups.values()) {
result = group.getUnitType(id);
if (result != null) {
break;
}
}
return result;
}
@Override
public UnitXCGroup getUnitGroup(String id) {
return Validate.notNull(unitGroups.get(Validate.notNull(id,"Null is not a validate id.")),"No group for: "+id);
}
@Override
public boolean isUnitGroup(String id) {
return unitGroups.containsKey(Validate.notBlank(id));
}
@Override
public UnitXConverter getConverter() {
return converter;
}
}

View file

@ -0,0 +1,49 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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;
import java.util.Arrays;
import net.forwardfire.unitxc.config.builder.UnitXCConfigBuilder;
/**
* Config module to build groups and types.
*
* @author Willem Cazander
* @version 1.0 Oct 17, 2015
*/
public interface UnitXCConfigModule {
void configModule(UnitXCConfigBuilder config);
static String buildFlag(String...flag) {
StringBuilder buf = new StringBuilder();
Arrays.asList(flag).forEach(f -> buf.append(f.toUpperCase()).append("_"));
return buf.deleteCharAt(buf.length()-1).toString();
}
}

View file

@ -0,0 +1,91 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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 java.util.function.Consumer;
import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.builder.Builder;
/**
* Abstract object builder with parent builder.
*
*
* @param <P> The parent builder.
* @param <T> The object to build.
* @param <B> This builder.
* @author Willem Cazander
* @version 1.0 Oct 22, 2015
*/
public abstract class AbstractUnitXCBuilder<P,T,B> implements Builder<P> {
private final P parent;
private final T value;
private final BiConsumer<P, T> parentBuilder;
/**
* Creates the builder.
* @param parent The parent builder.
* @param value The object to build.
*/
public AbstractUnitXCBuilder(P parent,T value,BiConsumer<P, T> 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<T> mixer) {
mixer.accept(getValue());
return getBuilder();
}
}

View file

@ -0,0 +1,73 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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<P,T extends AbstractUnitXCGroup,B> extends AbstractUnitXCBuilder<P,T,B> {
public AbstractUnitXCGroupBuilder(P parent, T model, BiConsumer<P, T> parentBuilder) {
super(parent, model, parentBuilder);
}
public UnitXCGroupJumpBuilder<AbstractUnitXCGroupBuilder<P,T,B>> createGroupJump(String unitGroupId) {
return new UnitXCGroupJumpBuilder<>(this,getValue(),unitGroupId,(p,v) -> p.getValue().addGroupJump(v));
}
public UnitXCTypeBuilder<AbstractUnitXCGroupBuilder<P,T,B>> 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));
// }
}

View file

@ -0,0 +1,128 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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<P,B> extends AbstractUnitXCBuilder<P,DefaultUnitXCType,B> {
public AbstractUnitXCTypeBuilder(P parent,DefaultUnitXCType model,BiConsumer<P, DefaultUnitXCType> 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<String> flags) {
return make(v -> flags.forEach(flag -> v.getTypeFlags().add(flag)));
}
public B addTypeFlags(String[] flags) {
return addTypeFlags(Arrays.asList(flags));
}
public UnitXConverterStepBuilder<AbstractUnitXCTypeBuilder<P,B>> createFromBaseConverterSteps() {
return new UnitXConverterStepBuilder<>(this,(p,v) -> p.addFromBaseConverterSteps(v),() -> "convert "+getValue().getId());
}
public UnitXConverterStepBuilder<AbstractUnitXCTypeBuilder<P,B>> 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<UnitXConverterStep> 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<UnitXConverterStep> unitTypeConverters) {
return make((v) -> unitTypeConverters.forEach(c -> v.getToBaseConverterSteps().add(c)));
}
}

View file

@ -0,0 +1,106 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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);
}
}

View file

@ -0,0 +1,43 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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 {
}

View file

@ -0,0 +1,54 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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<UnitXCConfigBuilder,UnitXCGroupBase,UnitXCGroupBaseBuilder> {
public UnitXCGroupBaseBuilder(UnitXCConfigBuilder parent, UnitXCGroupBase model, BiConsumer<UnitXCConfigBuilder, UnitXCGroupBase> parentBuilder) {
super(parent, model, parentBuilder);
}
@Override
protected UnitXCGroupBaseBuilder getBuilder() {
return this;
}
public UnitXCTypeSIPrefixBuilder<UnitXCGroupBaseBuilder> createSIUnitTypes() {
return new UnitXCTypeSIPrefixBuilder<>(this,this);
}
}

View file

@ -0,0 +1,65 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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<UnitXCConfigBuilder,UnitXCGroupCompoundExponent,UnitXCGroupCompoundExponentBuilder> {
public UnitXCGroupCompoundExponentBuilder(UnitXCConfigBuilder parent, UnitXCGroupCompoundExponent model, BiConsumer<UnitXCConfigBuilder, UnitXCGroupCompoundExponent> 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));
}
}

View file

@ -0,0 +1,116 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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<UnitXCConfigBuilder,UnitXCGroupCompoundPair,UnitXCGroupCompoundPairBuilder> {
public UnitXCGroupCompoundPairBuilder(UnitXCConfigBuilder parent, UnitXCGroupCompoundPair model, BiConsumer<UnitXCConfigBuilder, UnitXCGroupCompoundPair> 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();
}
}

View file

@ -0,0 +1,50 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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<UnitXCConfigBuilder,AbstractUnitXCGroup,UnitXCGroupExtendBuilder> {
public UnitXCGroupExtendBuilder(UnitXCConfigBuilder parent, AbstractUnitXCGroup model, BiConsumer<UnitXCConfigBuilder, AbstractUnitXCGroup> parentBuilder) {
super(parent, model, parentBuilder);
}
@Override
protected UnitXCGroupExtendBuilder getBuilder() {
return this;
}
}

View file

@ -0,0 +1,67 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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<P> extends AbstractUnitXCBuilder<P,DefaultUnitXCGroupJump,UnitXCGroupJumpBuilder<P>> {
public UnitXCGroupJumpBuilder(P parent, UnitXCGroup forGroup, String unitGroupId,BiConsumer<P, DefaultUnitXCGroupJump> parentBuilder) {
super(parent, new DefaultUnitXCGroupJump(), parentBuilder);
getValue().setUnitGroupId(unitGroupId);
getValue().setId(forGroup.getId()+"_"+unitGroupId);
}
@Override
protected UnitXCGroupJumpBuilder<P> getBuilder() {
return this;
}
public UnitXCGroupJumpBuilder<P> setId(String id) {
return make((v) -> v.setId(id));
}
public UnitXCGroupJumpBuilder<P> addJumpParameter(String id,String unitGroupId) {
return make((v) -> v.addJumpParameter(new DefaultUnitXCGroupJumpParameter(id, unitGroupId)));
}
public UnitXConverterStepBuilder<UnitXCGroupJumpBuilder<P>> createToGroupConverterSteps() {
return new UnitXConverterStepBuilder<>(this,(p,v) -> getValue().getToGroupConverterSteps().addAll(v),() -> "group jump");
}
}

View file

@ -0,0 +1,62 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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;
/**
*
*
* @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;
}
}

View file

@ -0,0 +1,50 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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<P> extends AbstractUnitXCTypeBuilder<P,UnitXCTypeBuilder<P>> {
public UnitXCTypeBuilder(P parent,DefaultUnitXCType model, BiConsumer<P, DefaultUnitXCType> parentBuilder) {
super(parent,model, parentBuilder);
}
@Override
protected UnitXCTypeBuilder<P> getBuilder() {
return this;
}
}

View file

@ -0,0 +1,136 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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<String> flags;
private final List<String> 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<String> 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<String> 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<String> getFlags() {
return flags;
}
public List<String> getNameAliases() {
return nameAliases;
}
}

View file

@ -0,0 +1,113 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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<P> extends AbstractUnitXCTypeBuilder<P,UnitXCTypeSIPrefixBuilder<P>> {
private final UnitXCGroupBaseBuilder builder;
private final List<UnitXCTypeSIPrefix> commonSIPrefixes;
public UnitXCTypeSIPrefixBuilder(P parent, UnitXCGroupBaseBuilder builder) {
super(parent,new DefaultUnitXCType(), (p,v) -> {});
this.builder = builder;
this.commonSIPrefixes = new ArrayList<>();
}
@Override
protected UnitXCTypeSIPrefixBuilder<P> getBuilder() {
return this;
}
@Override
protected void buildModel(UnitXCType v) {
// FIXME: if v.getAliasOfType() != null than skip copy steps
builder.createUnitType()
.setId(v.getId())
.setName(v.getName())
.setNamePlural(v.getNamePlural())
.setWebLink(v.getWebLink())
.addTypeFlags(v.getTypeFlags())
.addFromBaseConverterSteps(v.getFromBaseConverterSteps())
.addToBaseConverterSteps(v.getToBaseConverterSteps())
.build();
for (UnitXCTypeSIPrefix sim:UnitXCTypeSIPrefix.values()) {
List<String> typeFlags = new ArrayList<>();
typeFlags.addAll(v.getTypeFlags());
typeFlags.addAll(sim.getFlags());
if (commonSIPrefixes.contains(sim)) {
typeFlags.add(UnitXCTypeSIPrefix.TYPE_FLAG_SI_UNIT_COMMON);
}
builder.createUnitType()
.setId(sim.getPrefixId()+v.getId())
.setName(sim.getPrefixName()+v.getName())
.setNamePlural(sim.getPrefixName()+v.getNamePlural())
.addTypeFlags(typeFlags)
//.addWebsiteLinks(v.getWebsiteLinks())
.addToBaseConverterStep(new UnitXCConverterStepPowerOfTen(sim.getExponent(),false,UnitXConverterStepContext.createStepValue(),UnitXConverterStepContext.createStepValue()).buildReason("Move dot for SI"))
.addToBaseConverterSteps(v.getToBaseConverterSteps())
.addFromBaseConverterSteps(v.getFromBaseConverterSteps())
.addFromBaseConverterStep(new UnitXCConverterStepPowerOfTen(sim.getExponent(),true,UnitXConverterStepContext.createStepValue(),UnitXConverterStepContext.createStepValue()).buildReason("Move dot for SI"))
.build();
//for (String typeAlias:sim.getNameAliases()) {
//
//}
}
}
public UnitXCTypeSIPrefixBuilder<P> addCommonSIPrefixes(UnitXCTypeSIPrefix[] prefixes) {
return make(t -> addCommonSIPrefixes(Arrays.asList(prefixes)));
}
public UnitXCTypeSIPrefixBuilder<P> addCommonSIPrefixes(Collection<UnitXCTypeSIPrefix> prefixes) {
return make(t -> prefixes.forEach(prefix -> addCommonSIPrefix(prefix)));
}
public UnitXCTypeSIPrefixBuilder<P> addCommonSIPrefix(UnitXCTypeSIPrefix prefix) {
return make((v) -> commonSIPrefixes.add(prefix));
}
}

View file

@ -0,0 +1,151 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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<P extends AbstractUnitXCBuilder<?,?,?>> extends AbstractUnitXCBuilder<P,List<UnitXConverterStep>,UnitXConverterStepBuilder<P>> {
private final Supplier<String> stepReason;
public UnitXConverterStepBuilder(P parent, BiConsumer<P, List<UnitXConverterStep>> parentBuilder, Supplier<String> stepReason) {
super(parent, new ArrayList<>(), parentBuilder);
this.stepReason = Validate.notNull(stepReason);
}
@Override
protected UnitXConverterStepBuilder<P> getBuilder() {
return this;
}
private String createStepReason() {
return stepReason.get();
//return "convert "+getParent().getValue().getId();
}
private UnitXCConverterStepOperation createStepOperation(UnitXCConverterStepOperationOperator op,UnitXConverterStepValueRead opB) {
return new UnitXCConverterStepOperation(op,UnitXConverterStepContext.createStepValue(),opB,UnitXConverterStepContext.createStepValue());
}
public UnitXConverterStepBuilder<P> offsetUp(double offset,String stepReason) {
return make(v -> v.add(createStepOperation(UnitXCConverterStepOperationOperator.ADD,new UnitXConverterStepValueReferenceDouble(offset))));
}
public UnitXConverterStepBuilder<P> offsetDown(double offset,String stepReason) {
return make(v -> v.add(createStepOperation(UnitXCConverterStepOperationOperator.SUBTRACT,new UnitXConverterStepValueReferenceDouble(offset))));
}
public UnitXConverterStepBuilder<P> offsetUp(double offset) {
return offsetUp(offset,createStepReason());
}
public UnitXConverterStepBuilder<P> offsetDown(double offset) {
return offsetDown(offset,createStepReason());
}
public UnitXConverterStepBuilder<P> multiply(Fraction fraction,String stepReason) {
return multiply(fraction.getNumerator(),fraction.getDenominator(),stepReason);
}
public UnitXConverterStepBuilder<P> multiply(int numerator,int denominator,String stepReason) {
return make(v -> v.add(createStepOperation(UnitXCConverterStepOperationOperator.MULTIPLY,new UnitXConverterStepValueReferenceDoubleFraction(numerator,denominator))));
}
public UnitXConverterStepBuilder<P> multiply(Fraction fraction) {
return multiply(fraction,createStepReason());
}
public UnitXConverterStepBuilder<P> multiply(int numerator,int denominator) {
return multiply(numerator,denominator,createStepReason());
}
public UnitXConverterStepBuilder<P> multiply(UnitXConverterStepValueRead factor,String stepReason) {
return make(v -> v.add(createStepOperation(UnitXCConverterStepOperationOperator.MULTIPLY,factor)));
}
public UnitXConverterStepBuilder<P> multiply(double factor,String stepReason) {
return multiply(new UnitXConverterStepValueReferenceDouble(factor),stepReason);
}
public UnitXConverterStepBuilder<P> divide(UnitXConverterStepValueRead factor,String stepReason) {
return make(v -> v.add(createStepOperation(UnitXCConverterStepOperationOperator.DIVIDE,factor)));
}
public UnitXConverterStepBuilder<P> divide(double factor,String stepReason) {
return divide(new UnitXConverterStepValueReferenceDouble(factor),stepReason);
}
public UnitXConverterStepBuilder<P> multiply(double factor) {
return multiply(factor,createStepReason());
}
public UnitXConverterStepBuilder<P> multiply(UnitXConverterStepValueRead factor) {
return multiply(factor,createStepReason());
}
public UnitXConverterStepBuilder<P> divide(UnitXConverterStepValueRead factor) {
return divide(factor,createStepReason());
}
public UnitXConverterStepBuilder<P> divide(double factor) {
return divide(factor,createStepReason());
}
public UnitXConverterStepBuilder<P> power(double exponent,String stepReason) {
return make(v -> v.add(createStepOperation(UnitXCConverterStepOperationOperator.POWER,new UnitXConverterStepValueReferenceDouble(exponent))));
}
public UnitXConverterStepBuilder<P> power(double exponent) {
return power(exponent,createStepReason());
}
private UnitXConverterStepBuilder<P> powerOfTen(int exponent,boolean rev,String stepReason) {
return make(v -> v.add(new UnitXCConverterStepPowerOfTen(exponent,rev,UnitXConverterStepContext.createStepValue(),UnitXConverterStepContext.createStepValue()).buildReason(stepReason)));
}
public UnitXConverterStepBuilder<P> power10Up(UnitXCTypeSIPrefix exponent,String stepReason) {
return powerOfTen(exponent.getExponent(), true,stepReason);
}
public UnitXConverterStepBuilder<P> power10Down(UnitXCTypeSIPrefix exponent,String stepReason) {
return powerOfTen(exponent.getExponent(), false,stepReason);
}
public UnitXConverterStepBuilder<P> power10Up(UnitXCTypeSIPrefix exponent) {
return power10Up(exponent,createStepReason());
}
public UnitXConverterStepBuilder<P> power10Down(UnitXCTypeSIPrefix exponent) {
return power10Down(exponent,createStepReason());
}
}

View file

@ -0,0 +1,28 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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;

View file

@ -0,0 +1,28 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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;

View file

@ -0,0 +1,82 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.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<String, UnitXConverterParameterValue> 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<String,UnitXConverterParameterValue> parameters) {
return convertEngine.convertStepped(value, fromType, toType, parameters);
}
}

View file

@ -0,0 +1,221 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.MathContext;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.Validate;
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(double valueConvert,UnitXCType fromType,UnitXCType toType, Map<String,UnitXConverterParameterValue> parameters) {
Validate.notNull(valueConvert,"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(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<UnitXConverterResultStep> resultSteps = new ArrayList<>();
Map<String,UnitXConverterStepValueReadWrite> namedVariables = new HashMap<>();
Map<String,UnitXConverterStepValueRead> 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<UnitXConverterStep> 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;
// }
}
}

View file

@ -0,0 +1,80 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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;
}
}

View file

@ -0,0 +1,28 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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;

View file

@ -0,0 +1,210 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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<UnitXCGroupQuantity> quantities;
private final List<String> derivedFrom;
private final List<UnitXCType> unitTypes;
private final List<UnitXCGroupJump> 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<String> localUnitTypeIds();
abstract UnitXCType localUnitType(String id);
@Override
final public long getUnitTypeSize() {
return getUnitTypes().size() + localUnitTypeSize();
}
@Override
final public Iterator<String> getUnitTypeIds() {
Iterator<String> l = localUnitTypeIds();
List<String> result = new ArrayList<>();
getUnitTypes().forEach(t -> result.add(t.getId()));
Iterator<String> g = result.iterator();
return new Iterator<String>() {
@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<UnitXCGroupQuantity> getQuantities() {
return quantities;
}
public void addQuantity(UnitXCGroupQuantity quantity) {
this.quantities.add(quantity);
}
/**
* @return the derivedFrom
*/
public List<String> getDerivedFrom() {
return derivedFrom;
}
/**
* @param derivedFrom the derivedFrom to add
*/
public void addDerivedFrom(String derivedFrom) {
this.derivedFrom.add(derivedFrom);
}
/**
* @return the unit types.
*/
public List<UnitXCType> getUnitTypes() {
return unitTypes;
}
public void addUnitType(DefaultUnitXCType type) {
Validate.notNull(type);
type.setUnitGroup(this);
type.validate();
unitTypes.add(type);
}
/**
* @return the groupJumps
*/
public List<UnitXCGroupJump> 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);
}
}

View file

@ -0,0 +1,121 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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<UnitXConverterStep> toGroupConverterSteps;
private final List<UnitXCGroupJumpParameter> 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<UnitXConverterStep> getToGroupConverterSteps() {
return toGroupConverterSteps;
}
/**
* @param toGroupConverterSteps the toGroupConverterSteps to set
*/
public void setToBaseConverterSteps(List<UnitXConverterStep> toGroupConverterSteps) {
this.toGroupConverterSteps.clear();
this.toGroupConverterSteps.addAll(toGroupConverterSteps);
}
/**
* @return the jumpParameters
*/
public List<UnitXCGroupJumpParameter> getJumpParameters() {
return jumpParameters;
}
/**
* @param jumpParameters the jumpParameters to set
*/
public void setJumpParameters(List<UnitXCGroupJumpParameter> jumpParameters) {
this.jumpParameters.clear();
this.jumpParameters.addAll(jumpParameters);
}
public void addJumpParameter(UnitXCGroupJumpParameter jumpParameter) {
this.jumpParameters.add(Validate.notNull(jumpParameter));
}
}

View file

@ -0,0 +1,83 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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;
}
}

View file

@ -0,0 +1,62 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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;
}
}

View file

@ -0,0 +1,63 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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<String> getLanguages() {
return bundle.getValueLanguages(getBundleKey());
}
@Override
public String getValue(String language) {
return bundle.getValue(language, getBundleKey());
}
}

View file

@ -0,0 +1,211 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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<UnitXConverterStep> toBaseConverterSteps;
private final List<UnitXConverterStep> fromBaseConverterSteps;
private final List<String> 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<UnitXConverterStep> getToBaseConverterSteps() {
return toBaseConverterSteps;
}
/**
* @param toBaseConverterSteps the toBaseConverterSteps to set
*/
public void setToBaseConverterSteps(List<UnitXConverterStep> toBaseConverterSteps) {
this.toBaseConverterSteps.clear();
this.toBaseConverterSteps.addAll(toBaseConverterSteps);
}
/**
* @return the fromBaseConverterSteps
*/
@Override
public List<UnitXConverterStep> getFromBaseConverterSteps() {
return fromBaseConverterSteps;
}
/**
* @param fromBaseConverterSteps the fromBaseConverterSteps to set
*/
public void setFromBaseConverterSteps(List<UnitXConverterStep> fromBaseConverterSteps) {
this.fromBaseConverterSteps.clear();
this.fromBaseConverterSteps.addAll(fromBaseConverterSteps);
}
/**
* @return the typeFlags
*/
@Override
public List<String> getTypeFlags() {
return typeFlags;
}
/**
* @param typeFlags the typeFlags to set
*/
public void setTypeFlags(List<String> 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);
}
}

View file

@ -0,0 +1,137 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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<UnitXConverterResultStep> 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<UnitXConverterResultStep> getResultSteps() {
return resultSteps;
}
/**
* @param resultSteps the resultSteps to set
*/
public void setResultSteps(List<UnitXConverterResultStep> 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);
}
}

View file

@ -0,0 +1,107 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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);
}
}

View file

@ -0,0 +1,87 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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<UnitXCGroup> unitGroups;
private final List<Locale> 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<UnitXCGroup> getUnitGroups() {
return unitGroups;
}
public void addUnitGroup(AbstractUnitXCGroup group) {
Validate.notNull(group);
group.validate();
unitGroups.add(group);
}
public List<Locale> getLanguages() {
return languages;
}
public void addLanguage(Locale language) {
languages.add(Validate.notNull(language));
}
}

View file

@ -0,0 +1,84 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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<UnitXCGroupQuantity> getQuantities();
/**
* @return the derivedFrom
*/
List<String> getDerivedFrom();
/**
* @return the groupJumps
*/
List<UnitXCGroupJump> getGroupJumps();
/**
* @return the totalUnitTypes
*/
long getUnitTypeSize();
Iterator<String> getUnitTypeIds();
UnitXCType getUnitType(String id);
}

View file

@ -0,0 +1,60 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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<String> localUnitTypeIds() {
return Collections.emptyIterator();
}
@Override
public UnitXCType localUnitType(String id) {
return null;
}
}

View file

@ -0,0 +1,148 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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<String> localUnitTypeIds() {
Iterator<String> g = getParentGroup().getUnitTypeIds();
return new Iterator<String>() {
@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<Object> typeBuilder = new UnitXCTypeBuilder<>(this,result,(p,v) -> {});
typeBuilder
.setId(unitType.getId()+unitIdPostfix)
.setName(unitNamePrefix+unitType.getName())
.addTypeFlags(unitType.getTypeFlags());
for (int i=0;i<exponent;i++) {
typeBuilder.addToBaseConverterStep(new UnitXCConverterStepReference(unitType,true));
typeBuilder.addFromBaseConverterStep(new UnitXCConverterStepReference(unitType,false));
}
typeBuilder.build();
result.setUnitGroup(this);
return result;
}
/**
* @return the exponent
*/
public int getExponent() {
return exponent;
}
/**
* @return the unitIdPostfix
*/
public String getUnitIdPostfix() {
return unitIdPostfix;
}
/**
* @param unitIdPostfix the unitIdPostfix to set
*/
public void setUnitIdPostfix(String unitIdPostfix) {
this.unitIdPostfix = unitIdPostfix;
}
/**
* @return the unitNamePrefix
*/
public String getUnitNamePrefix() {
return unitNamePrefix;
}
/**
* @param unitNamePrefix the unitNamePrefix to set
*/
public void setUnitNamePrefix(String unitNamePrefix) {
this.unitNamePrefix = unitNamePrefix;
}
/**
* @return the parentGroup
*/
public UnitXCGroup getParentGroup() {
return parentGroup;
}
}

View file

@ -0,0 +1,185 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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 UnitXCGroupCompoundPair extends AbstractUnitXCGroup {
public static final String PER_ID = "/";
public static final String PER_NAME = " per ";
private final UnitXCGroup parentGroup;
private final UnitXCGroup parentPerGroup;
public UnitXCGroupCompoundPair(UnitXCResourceBundle bundle, String id,UnitXCGroup parentGroup,UnitXCGroup parentPerGroup) {
super(bundle, id);
this.parentGroup = Validate.notNull(parentGroup);
this.parentPerGroup = Validate.notNull(parentPerGroup);
}
@Override
public long localUnitTypeSize() {
return getParentGroup().getUnitTypeSize()*getParentPerGroup().getUnitTypeSize();
}
@Override
public Iterator<String> localUnitTypeIds() {
Iterator<String> groupIt = getParentGroup().getUnitTypeIds();
return new Iterator<String>() {
String groupId2;
Iterator<String> perGroupIt;
@Override
public boolean hasNext() {
if (perGroupIt!=null && perGroupIt.hasNext()) {
return true;
}
if (groupIt.hasNext()) {
groupId2 = groupIt.next();
perGroupIt = getParentPerGroup().getUnitTypeIds();
return true;
}
return false;
}
@Override
public String next() {
return groupId2+PER_ID+perGroupIt.next();
}
};
}
@Override
public UnitXCType localUnitType(String id) {
// if (!id.contains(PER_ID)) {
// return null;
// }
String[] units = id.split(PER_ID);
if (units.length < 2) {
return null;
}
// System.out.println("checking pair: "+id);
for (int i=1;i<units.length;i++) {
StringBuilder idGroup = new StringBuilder();
StringBuilder idGroupPer = new StringBuilder();
for (int ii=0;ii<i;ii++) {
idGroup.append(units[ii]);
if (ii+1<i) {
idGroup.append(PER_ID);
}
}
String checkExponent = null;
boolean checkExponentUse = false;
for (int ii=i;ii<units.length;ii++) {
if (checkExponent!=null && !checkExponent.equals(units[ii])) {
checkExponentUse = true;
}
checkExponent = units[ii];
idGroupPer.append(units[ii]);
if (ii+1<units.length) {
idGroupPer.append(PER_ID);
}
}
if (checkExponentUse) {
}
UnitXCType result = getUnitType(id,idGroup.toString(),idGroupPer.toString());
if (result != null) {
return result;
}
}
return null;
//String idGroup = id.substring(0,id.lastIndexOf(PER_ID)); // FIXME parse correctly see newton
//String idGroupPer = id.substring(id.lastIndexOf(PER_ID)+1);
}
private UnitXCType getUnitType(String id,String idGroup,String idGroupPer) {
// System.out.println("checking: "+idGroup+" and "+idGroupPer);
UnitXCType unitType = getParentGroup().getUnitType(idGroup);
if (unitType == null) {
return null;
}
UnitXCType perUnitType = getParentPerGroup().getUnitType(idGroupPer);
if (perUnitType == null) {
return null;
}
return createUnitType(id, unitType, perUnitType);
}
private UnitXCType createUnitType(String id,UnitXCType unitType,UnitXCType perUnitType) {
// TODO: add name/name alias
DefaultUnitXCType result = new DefaultUnitXCType();
UnitXCTypeBuilder<Object> typeBuilder = new UnitXCTypeBuilder<>(this,result,(p,v) -> {});
typeBuilder
.setId(id)
.setName(unitType.getName()+PER_NAME+perUnitType.getName())
.addTypeFlags(unitType.getTypeFlags())
.addTypeFlags(perUnitType.getTypeFlags());
typeBuilder.addToBaseConverterStep(new UnitXCConverterStepReference(unitType,true));
typeBuilder.addToBaseConverterStep(new UnitXCConverterStepReference(perUnitType,false));
typeBuilder.addFromBaseConverterStep(new UnitXCConverterStepReference(perUnitType,true));
typeBuilder.addFromBaseConverterStep(new UnitXCConverterStepReference(unitType,false));
typeBuilder.build();
result.setUnitGroup(this);
return result;
}
/**
* @return the parentGroup
*/
public UnitXCGroup getParentGroup() {
return parentGroup;
}
/**
* @return the parentPerGroup
*/
public UnitXCGroup getParentPerGroup() {
return parentPerGroup;
}
}

View file

@ -0,0 +1,63 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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 net.forwardfire.unitxc.model.step.UnitXConverterStep;
/**
* The unit group jump.
*
* @author Willem Cazander
* @version 1.0 Apr 1, 2016
*/
public interface UnitXCGroupJump {
UnitXCGroupJump validate();
/**
* @return the id
*/
String getId();
/**
* @return the toGroupId
*/
String getUnitGroupId();
/**
* @return the toGroupConverterSteps
*/
List<UnitXConverterStep> getToGroupConverterSteps();
/**
* @return the jumpParameters
*/
List<UnitXCGroupJumpParameter> getJumpParameters();
}

View file

@ -0,0 +1,49 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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 jump.
*
* @author Willem Cazander
* @version 1.0 Apr 1, 2016
*/
public interface UnitXCGroupJumpParameter {
UnitXCGroupJumpParameter validate();
/**
* @return the id
*/
String getId();
/**
* @return the unitGroupId
*/
String getUnitGroupId();
}

View file

@ -0,0 +1,52 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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 interface UnitXCGroupQuantity {
/**
* @return the id
*/
String getId();
/**
* @return the name
*/
UnitXCResourceValue getName();
/**
* @return the wikilink
*/
UnitXCResourceValue getWikiLink();
}

View file

@ -0,0 +1,54 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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 source.
*
* @author Willem Cazander
* @version 1.0 Dec 4, 2016
*/
public interface UnitXCGroupSource {
/**
* @return the derivedFrom
*/
List<String> getDerivedFrom();
/**
* @return the totalUnitTypes
*/
long getUnitTypeSize();
Iterator<String> getUnitTypeIds();
UnitXCType getUnitType(String id);
}

View file

@ -0,0 +1,47 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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
*
* @author Willem Cazander
* @version 1.0 Oct 31, 2016
*/
public @interface UnitXCModule {
String groupId();
String[] dependencies();
// public @interface UnitXCModuleDependency {
// String groupId();
// }
}

View file

@ -0,0 +1,77 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.Validate;
/**
* The resource value wrapper
*
* @author Willem Cazander
* @version 1.0 Oct 31, 2016
*/
public class UnitXCResourceBundle {
private Map<String,Map<String,String>> data = new HashMap<>();
// FIXME: not public or interface or x
public void addData(String language,String key,String value) {
Map<String,String> ld = data.get(language);
if (ld == null) {
ld = new HashMap<>();
data.put(language, ld);
}
ld.put(key, value);
}
public List<String> getLanguages() {
return new ArrayList<>(data.keySet());
}
public List<String> getValueLanguages(String key) {
List<String> result = new ArrayList<>();
data.forEach((k,v) -> {
if (v.containsKey(key)) {
result.add(k);
}
});
return result;
}
public String getValue(String lang,String key) {
if (lang.isEmpty()) {
lang = "und"; // undefined
}
return Validate.notNull(Validate.notNull(data.get(lang),"Could not find langauge: "+lang).get(key),"Could not find key: "+key);
}
}

View file

@ -0,0 +1,48 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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
*
* @author Willem Cazander
* @version 1.0 Oct 31, 2016
*/
public interface UnitXCResourceValue {
/**
* @return the bundle key.
*/
String getBundleKey();
List<String> getLanguages();
String getValue(String language);
}

View file

@ -0,0 +1,41 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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;
/**
*
*
* @author Willem Cazander
* @version 1.0 Mar 23, 2016
*/
public enum UnitXCRounding {
OFF,
PRE_STEP;
/* PER_CONVERT */
}

View file

@ -0,0 +1,88 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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 net.forwardfire.unitxc.model.step.UnitXConverterStep;
/**
* The unit type.
*
* @author Willem Cazander
* @version 1.0 Oct 10, 2015
*/
public interface UnitXCType {
/**
* @return the id
*/
String getId();
/**
* @return the name
*/
String getName();
/**
* The name in plugal form.
* @return the namePlural.
*/
String getNamePlural();
/**
* @return the aliasOfType
*/
String getAliasOfType();
/**
* @return the unitGroup
*/
UnitXCGroup getUnitGroup();
/**
* @return the toBaseConverterSteps
*/
List<UnitXConverterStep> getToBaseConverterSteps();
/**
* @return the fromBaseConverterSteps
*/
List<UnitXConverterStep> getFromBaseConverterSteps();
/**
* @return the typeFlags
*/
List<String> getTypeFlags();
/**
* @return the weblink
*/
String getWebLink();
}

View file

@ -0,0 +1,69 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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;
/**
* Holds the convert result and meta steps how we got there.
*
* @author Willem Cazander
* @version 1.0 Oct 17, 2015
*/
public interface UnitXConverterResult {
/**
* @return the startValue
*/
Double getStartValue();
/**
* @return the resultSteps
*/
List<UnitXConverterResultStep> getResultSteps();
/**
* @return the resultValue
*/
Double getResultValue();
/**
* @return the convertTime
*/
Long getConvertTime();
/**
* @return the startTypeId
*/
String getStartTypeId();
/**
* @return the resultTypeId
*/
String getResultTypeId();
}

View file

@ -0,0 +1,60 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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 net.forwardfire.unitxc.model.step.UnitXConverterStep;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 17, 2015
*/
public interface UnitXConverterResultStep {
/**
* @return the startValue
*/
Double getStartValue();
/**
* @return the resultValue
*/
Double getResultValue();
/**
* @return the convertTime
*/
Long getConvertTime();
/**
* @return the convertStep
*/
UnitXConverterStep getConvertStep();
}

View file

@ -0,0 +1,28 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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;

View file

@ -0,0 +1,72 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.step;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 17, 2015
*/
public abstract class AbstractUnitXConverterStep implements UnitXConverterStep {
private final List<String> stepReasons;
protected AbstractUnitXConverterStep() {
this.stepReasons = new ArrayList<>();
}
public AbstractUnitXConverterStep buildReason(String reason) {
addStepReason(reason);
return this;
}
public final List<String> getStepReasons() {
return stepReasons;
}
public final void setStepReasons(List<String> stepReasons) {
this.stepReasons.clear();
this.stepReasons.addAll(stepReasons);
}
public final void addStepReason(String stepReason) {
stepReasons.add(Validate.notBlank(stepReason));
}
@Override
public final String toString() {
return ReflectionToStringBuilder.toString(this);
}
}

View file

@ -0,0 +1,107 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.step;
public class RuleStepCode {
private String id;
private String type;
private String style;
private String code;
private String matcher;
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType(String type) {
this.type = type;
}
/**
* @return the style
*/
public String getStyle() {
return style;
}
/**
* @param style the style to set
*/
public void setStyle(String style) {
this.style = style;
}
/**
* @return the code
*/
public String getCode() {
return code;
}
/**
* @param code the code to set
*/
public void setCode(String code) {
this.code = code;
}
/**
* @return the matcher
*/
public String getMatcher() {
return matcher;
}
/**
* @param matcher the matcher to set
*/
public void setMatcher(String matcher) {
this.matcher = matcher;
}
}

View file

@ -0,0 +1,132 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.step;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
public class RuleStepCodePrinter {
private final StringBuilder result = new StringBuilder();
private final RuleStepCodeStyle codeStyle;
private int indentLevel = 0;
public RuleStepCodePrinter(RuleStepCodeStyle codeStyle) {
this.codeStyle = Validate.notNull(codeStyle);
}
public static String print(RuleStepCodeStyle codeStyle, List<UnitXConverterStep> steps, String id) {
RuleStepCodePrinter printer = new RuleStepCodePrinter(codeStyle);
printer.line(); // make copy/paste easy
if (printer.isEnglish()) {
printer.line("Description of: ",id);
printer.line();
} else {
printer.line("code['",id,"'] = function(ctx) {");
printer.pushIndent();
}
printer.printSteps(steps);
if (printer.isJavascript()) {
printer.popIndent();
printer.line("}");
}
return printer.getResult();
}
public void printSteps(List<UnitXConverterStep> steps) {
steps.forEach(s -> s.toRuleCode(this));
}
public String getResult() {
return result.toString();
}
public RuleStepCodeStyle getCodeStyle() {
return codeStyle;
}
public boolean isEnglish() {
return RuleStepCodeStyle.ENGLISH.equals(getCodeStyle());
}
public boolean isJavascript() {
return RuleStepCodeStyle.JAVASCRIPT.equals(getCodeStyle());
}
/*
public boolean isXslt() {
return RuleStepCodeType.XSLT.equals(getCodeStyle());
}
*/
public void pushIndent() {
indentLevel++;
}
public void popIndent() {
if (indentLevel > 0) {
indentLevel--;
}
}
private void appendIndent() {
for (int i = 0;i < indentLevel*4; i++) {
appendSpace();
}
}
public void line(String...text) {
lineStart(text);
lineEnd();
}
public void lineStart(String...text) {
appendIndent();
append(text);
}
public void lineEnd(String...text) {
append(text);
result.append(StringUtils.LF);
}
public void append(String...texts) {
Arrays.asList(texts).forEach(text -> result.append(text));
}
public void appendJS(String...texts) {
if (isJavascript()) {
append(texts);
}
}
public void appendSpace() {
result.append(StringUtils.SPACE);
}
}

View file

@ -0,0 +1,34 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.step;
public enum RuleStepCodeStyle {
ENGLISH,
JAVASCRIPT
;
}

View file

@ -0,0 +1,131 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.step;
import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueNamedVariable;
import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueRead;
import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueReadWrite;
public class UnitXCConverterStepAutoRounding extends AbstractUnitXConverterStep {
private UnitXConverterStepValueRead operand;
private UnitXConverterStepValueReadWrite result;
public UnitXCConverterStepAutoRounding() {
}
public UnitXCConverterStepAutoRounding(UnitXConverterStepValueRead operand,UnitXConverterStepValueReadWrite result) {
setOperand(operand);
setResult(result);
}
@Override
public void toRuleCode(RuleStepCodePrinter printer) {
if (printer.isEnglish()) {
printer.lineStart("Rounding ");
getOperand().toRuleCodeRead(printer);
printer.append(" to ");
getResult().toRuleCodeRead(printer);
printer.lineEnd(".");
return;
}
printer.lineStart();
getResult().toRuleCodeWrite(printer);
printer.append(" = ");
getOperand().toRuleCodeRead(printer);
printer.lineEnd();
}
private double round(double value,double prevValue) {
String valueStr = Double.toString(value);
String valueOrgStr = Double.toString(prevValue);
int valueDotIndex = valueStr.indexOf(".");
int valueOrgDotIndex = valueOrgStr.indexOf(".");
int valueDotSize = valueStr.length() - valueDotIndex;
int valueOrgDotSize = valueOrgStr.length() - valueOrgDotIndex;
if (valueDotSize<10) {
return value;
}
if (valueDotSize<=valueOrgDotSize) {
return value;
}
int valueEIndex = valueStr.indexOf("E");
String valueShortStr = null;
if (valueEIndex>0) {
int sub = valueOrgStr.length();
if (sub > valueEIndex) {
sub = valueEIndex;
}
valueShortStr = valueStr.substring(0, sub)+ valueStr.substring(valueEIndex);
} else {
int endIndex = valueOrgStr.length();
if (endIndex > valueStr.length()) {
endIndex = valueStr.length();
}
valueShortStr = valueStr.substring(0, endIndex);
}
Double result = Double.valueOf(valueShortStr);
return result.doubleValue();
}
@Override
public void runStep(UnitXConverterStepContext ctx) {
// FIXME: rm obj and casting
UnitXConverterStepValueReadWrite startValue = new UnitXConverterStepValueNamedVariable(Double.class,UnitXConverterStepContext.VALUE_START);
getResult().valueWrite(ctx, round((Double)getOperand().valueRead(ctx),(Double)startValue.valueRead(ctx)));
}
/**
* @return the operand
*/
public UnitXConverterStepValueRead getOperand() {
return operand;
}
/**
* @param operand the operand to set
*/
public void setOperand(UnitXConverterStepValueRead operand) {
this.operand = operand;
}
/**
* @return the result
*/
public UnitXConverterStepValueReadWrite getResult() {
return result;
}
/**
* @param result the result to set
*/
public void setResult(UnitXConverterStepValueReadWrite result) {
this.result = result;
}
}

View file

@ -0,0 +1,183 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.step;
import java.util.ArrayList;
import java.util.List;
import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueRead;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 17, 2015
*/
public class UnitXCConverterStepCondition extends AbstractUnitXConverterStep {
private UnitXCConverterStepConditionEquality equality;
private UnitXConverterStepValueRead operandA;
private UnitXConverterStepValueRead operandB;
private final List<UnitXConverterStep> conditionalSteps;
public UnitXCConverterStepCondition() {
this.conditionalSteps = new ArrayList<>();
}
@Override
public void runStep(UnitXConverterStepContext ctx) {
if (equality.execute(operandA.valueRead(ctx),operandB.valueRead(ctx))) {
ctx.runSteps(conditionalSteps);
}
}
@Override
public void toRuleCode(RuleStepCodePrinter printer) {
if (printer.isEnglish()) {
printer.lineStart("If ");
toPseudoCodeExpression(printer);
printer.lineEnd(" then;");
printer.pushIndent();
printer.printSteps(getConditionalSteps());
printer.popIndent();
// if (!stepsFalse.isEmpty()) {
// printer.line("Else do;");
// printer.pushIndent();
// printer.printSteps(getStepsFalse());
// printer.popIndent();
// }
printer.line(); // for readablity
return;
}
printer.lineStart("if");
toPseudoCodeExpression(printer);
printer.lineEnd("{");
printer.pushIndent();
printer.printSteps(getConditionalSteps());
printer.popIndent();
// if (stepsFalse.isEmpty()) {
// printer.line("}");
// } else {
// printer.line("} else {");
// printer.pushIndent();
// printer.printSteps(getStepsFalse());
// printer.popIndent();
// printer.line("}");
// }
}
public void toPseudoCodeExpression(RuleStepCodePrinter printer/*, List<RuleStepConditionExpression> expressions*/) {
printer.appendJS(" ( ");
getEquality().toRuleCode(printer, operandA, operandB);
printer.appendJS(" ) ");
// Iterator<RuleStepConditionExpression> i = expressions.iterator();
// if (!i.hasNext()) {
// return;
// }
// printer.appendJS(" ( ");
// while (i.hasNext()) {
// RuleStepConditionExpression ex = i.next();
// ex.getEquality().toRuleCode(printer, ex.getOperandA(), ex.getOperandB());
// // TODO: this not yet looks correctly,,.somewhere here?
// if (i.hasNext()) {
// if (printer.isEnglish()) {
// printer.append(" and ");
// } else {
// printer.append(" && ");
// }
// }
// if (!ex.getExpressions().isEmpty()) {
// if (printer.isEnglish()) {
// printer.append(" or ");
// } else {
// printer.append(" || ");
// }
// toPseudoCodeExpression(printer,ex.getExpressions());
// }
// }
// printer.appendJS(" ) ");
}
/**
* @return the equality
*/
public UnitXCConverterStepConditionEquality getEquality() {
return equality;
}
/**
* @param equality the equality to set
*/
public void setEquality(UnitXCConverterStepConditionEquality equality) {
this.equality = equality;
}
/**
* @return the operandA
*/
public UnitXConverterStepValueRead getOperandA() {
return operandA;
}
/**
* @param operandA the operandA to set
*/
public void setOperandA(UnitXConverterStepValueRead operandA) {
this.operandA = operandA;
}
/**
* @return the operandB
*/
public UnitXConverterStepValueRead getOperandB() {
return operandB;
}
/**
* @param operandB the operandB to set
*/
public void setOperandB(UnitXConverterStepValueRead operandB) {
this.operandB = operandB;
}
/**
* @return the conditionalSteps
*/
public List<UnitXConverterStep> getConditionalSteps() {
return conditionalSteps;
}
/**
* @param conditionalSteps the conditionalSteps to set
*/
public void setConditionalSteps(List<UnitXConverterStep> conditionalSteps) {
this.conditionalSteps.clear();
this.conditionalSteps.addAll(conditionalSteps);
}
}

View file

@ -0,0 +1,90 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.step;
import java.util.function.BiFunction;
import org.apache.commons.lang3.StringUtils;
import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueRead;
public enum UnitXCConverterStepConditionEquality {
EQUALS ("===",(l,r) -> l.compareTo(r) == 0, (l,r) -> l.compareTo(r) == 0, (l,r) -> l.compareTo(r) == 0),
NOT_EQUALS ("!==",(l,r) -> l.compareTo(r) != 0, (l,r) -> l.compareTo(r) != 0, (l,r) -> l.compareTo(r) != 0),
GREATER_THEN (">", (l,r) -> l.compareTo(r) > 0, (l,r) -> l.compareTo(r) > 0, (l,r) -> l.compareTo(r) > 0),
LESSER_THEN ("<", (l,r) -> l.compareTo(r) < 0, (l,r) -> l.compareTo(r) < 0, (l,r) -> l.compareTo(r) < 0),
GREATER_OR_EQUALS (">=",(l,r) -> l.compareTo(r) >= 0, (l,r) -> l.compareTo(r) >= 0, (l,r) -> l.compareTo(r) >= 0),
LESSER_OR_EQUALS ("<=",(l,r) -> l.compareTo(r) <= 0, (l,r) -> l.compareTo(r) <= 0, (l,r) -> l.compareTo(r) <= 0),
;
private final String jsCode;
private final String enCode;
private final BiFunction<Double,Double,Boolean> opertionDouble; // TODO: convert to IntPredicate
private final BiFunction<Integer,Integer,Boolean> opertionInteger;
private final BiFunction<String,String,Boolean> opertionString;
private UnitXCConverterStepConditionEquality(String jsCode, BiFunction<Double,Double,Boolean> opertionDouble,BiFunction<Integer,Integer,Boolean> opertionInteger,BiFunction<String,String,Boolean> opertionString) {
this.jsCode = jsCode;
this.enCode = name().toLowerCase().replaceAll("_", StringUtils.SPACE);
this.opertionDouble = opertionDouble;
this.opertionInteger = opertionInteger;
this.opertionString = opertionString;
}
public boolean execute(Object left, Object right) {
if (Double.class.equals(left.getClass())) {
return opertionDouble.apply(Double.class.cast(left), Double.class.cast(right));
}
if (Integer.class.equals(left.getClass())) {
return opertionInteger.apply(Integer.class.cast(left), Integer.class.cast(right));
}
if (String.class.equals(left.getClass())) {
return opertionString.apply(String.class.cast(left), String.class.cast(right));
}
throw new IllegalArgumentException("Unknown typeClass: "+left.getClass());
}
public void toRuleCode(RuleStepCodePrinter printer, UnitXConverterStepValueRead operandA, UnitXConverterStepValueRead operandB) {
if (printer.isEnglish()) {
operandA.toRuleCodeRead(printer);
printer.append(" is ", enCode);
if (jsCode.contains("=")) {
printer.append(" to");
}
printer.appendSpace();
operandB.toRuleCodeRead(printer);
return;
}
operandA.toRuleCodeRead(printer);
printer.appendSpace();
printer.append(jsCode);
printer.appendSpace();
operandB.toRuleCodeRead(printer);
}
}

View file

@ -0,0 +1,133 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.step;
import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueRead;
import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueReadWrite;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 17, 2015
*/
public class UnitXCConverterStepOperation extends AbstractUnitXConverterStep {
private UnitXCConverterStepOperationOperator operator;
private UnitXConverterStepValueRead operandA;
private UnitXConverterStepValueRead operandB;
private UnitXConverterStepValueReadWrite result;
public UnitXCConverterStepOperation() {
}
public UnitXCConverterStepOperation(UnitXCConverterStepOperationOperator operator,UnitXConverterStepValueRead operandA,UnitXConverterStepValueRead operandB,UnitXConverterStepValueReadWrite result) {
setOperator(operator);
setOperandA(operandA);
setOperandB(operandB);
setResult(result);
}
@Override
public void runStep(UnitXConverterStepContext ctx) {
result.valueWrite(ctx, operator.execute(operandA.valueRead(ctx),operandB.valueRead(ctx)));
}
@Override
public void toRuleCode(RuleStepCodePrinter printer) {
if (printer.isEnglish()) {
printer.lineStart("Update ");
getResult().toRuleCodeWrite(printer);
printer.append(" with value from ");
getOperator().toRuleCode(printer, getOperandA(), getOperandB());
printer.lineEnd(".");
return;
}
printer.lineStart();
getResult().toRuleCodeWrite(printer);
printer.append(" = ");
getOperator().toRuleCode(printer, getOperandA(), getOperandB());
printer.lineEnd();
}
/**
* @return the operator
*/
public UnitXCConverterStepOperationOperator getOperator() {
return operator;
}
/**
* @param operator the operator to set
*/
public void setOperator(UnitXCConverterStepOperationOperator operator) {
this.operator = operator;
}
/**
* @return the operandA
*/
public UnitXConverterStepValueRead getOperandA() {
return operandA;
}
/**
* @param operandA the operandA to set
*/
public void setOperandA(UnitXConverterStepValueRead operandA) {
this.operandA = operandA;
}
/**
* @return the operandB
*/
public UnitXConverterStepValueRead getOperandB() {
return operandB;
}
/**
* @param operandB the operandB to set
*/
public void setOperandB(UnitXConverterStepValueRead operandB) {
this.operandB = operandB;
}
/**
* @return the result
*/
public UnitXConverterStepValueReadWrite getResult() {
return result;
}
/**
* @param result the result to set
*/
public void setResult(UnitXConverterStepValueReadWrite result) {
this.result = result;
}
}

View file

@ -0,0 +1,113 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.step;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.function.BinaryOperator;
import org.apache.commons.lang3.StringUtils;
import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueRead;
public enum UnitXCConverterStepOperationOperator {
ADD ("+",(l,r) -> l+r, (l,r) -> l+r, (l,r) -> l+r),
SUBTRACT ("-",(l,r) -> l-r, (l,r) -> l-r, (l,r) -> l.replaceAll(l, StringUtils.EMPTY)),
MULTIPLY ("*",(l,r) -> l*r, (l,r) -> l*r, null),
DIVIDE ("/",(l,r) -> l/r, (l,r) -> l/r, null),
POWER ("pow",(l,r) -> p(l,r), (l,r) -> p(l,r), null),
AND ("&", null, (l,r) -> l & r, null),
OR ("|",null, (l,r) -> l | r, null),
;
private final String jsCode;
private final String enCode;
private final BinaryOperator<Double> opertionDouble;
private final BinaryOperator<Integer> opertionInteger;
private final BinaryOperator<String> opertionString;
private UnitXCConverterStepOperationOperator(String jsCode, BinaryOperator<Double> opertionDouble,BinaryOperator<Integer> opertionInteger,BinaryOperator<String> opertionString) {
this.jsCode = jsCode;
this.enCode = name().toLowerCase();
this.opertionDouble = opertionDouble;
this.opertionInteger = opertionInteger;
this.opertionString = opertionString;
}
private static BigDecimal p(BigDecimal l,BigDecimal r) {
return l.pow(r.intValueExact(), MathContext.UNLIMITED);
}
private static double p(double l,double r) {
return Math.pow(l, r);
}
private static int p(int l,int r) {
for (int i=0;i<r;i++) {
l = l * l;
}
return l;
}
public Object execute(Object left, Object right) {
if (Double.class.equals(left.getClass())) {
return opertionDouble.apply(Double.class.cast(left), Double.class.cast(right));
}
if (Integer.class.equals(left.getClass())) {
return opertionInteger.apply(Integer.class.cast(left), Integer.class.cast(right));
}
if (String.class.equals(left.getClass())) {
return opertionString.apply(String.class.cast(left), String.class.cast(right));
}
throw new IllegalArgumentException("Unknown typeClass: "+left.getClass());
}
public void toRuleCode(RuleStepCodePrinter printer, UnitXConverterStepValueRead operandA, UnitXConverterStepValueRead operandB) {
if (printer.isEnglish()) {
printer.append(enCode," ");
operandA.toRuleCodeRead(printer);
printer.append(" and ");
operandB.toRuleCodeRead(printer);
return;
}
if (POWER.equals(this)) {
printer.append(jsCode,"(");
operandA.toRuleCodeRead(printer);
printer.append(", ");
operandB.toRuleCodeRead(printer);
printer.append(")");
return;
}
operandA.toRuleCodeRead(printer);
printer.appendSpace();
printer.append(jsCode);
printer.appendSpace();
operandB.toRuleCodeRead(printer);
}
}

View file

@ -0,0 +1,167 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.step;
import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueRead;
import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueReadWrite;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 17, 2015
*/
public class UnitXCConverterStepPowerOfTen extends AbstractUnitXConverterStep {
private UnitXConverterStepValueRead operand;
private UnitXConverterStepValueReadWrite result;
private int exponent;
private boolean exponentReverse;
public UnitXCConverterStepPowerOfTen() {
}
public UnitXCConverterStepPowerOfTen(int exponent,boolean exponentReverse,UnitXConverterStepValueRead operand,UnitXConverterStepValueReadWrite result) {
this();
setExponent(exponent);
setExponentReverse(exponentReverse);
setOperand(operand);
setResult(result);
}
@Override
public void runStep(UnitXConverterStepContext ctx) {
result.valueWrite(ctx, convert((Double)operand.valueRead(ctx)));
}
@Override
public void toRuleCode(RuleStepCodePrinter printer) {
if (printer.isEnglish()) {
printer.lineStart("Update ");
getResult().toRuleCodeWrite(printer);
printer.append(" with value from ");
printer.append(" * ");
if (exponentReverse) {
printer.append(" -1? "); // TODO: fix reverse
}
printer.append(" 10^", Integer.toString(exponent));
printer.lineEnd(".");
return;
}
printer.lineStart();
getResult().toRuleCodeWrite(printer);
printer.append(" = ");
getOperand().toRuleCodeRead(printer);
printer.append(" * ");
if (exponentReverse) {
printer.append(" -1? "); // TODO: fix reverse
}
printer.append(" 10^", Integer.toString(exponent));
printer.lineEnd();
}
public double convert(double value) {
int exponentShift = exponent<0?0-exponent:exponent;
for (int i=0;i<exponentShift;i++) {
value = shiftDotStatic(value,exponentReverse?!(exponent>0):exponent>0);
}
return value;
}
private double shiftDotStatic(double value,boolean up) {
String valueStr = ""+value;
int dotIdx = valueStr.indexOf('.');
StringBuilder buf = new StringBuilder();
buf.append(valueStr);
buf.deleteCharAt(dotIdx);
if (up) {
buf.insert(dotIdx+1, '.');
} else {
buf.insert(dotIdx-1, '.');
}
Double result = new Double(buf.toString());
return result.doubleValue();
}
/**
* @return the exponent
*/
public int getExponent() {
return exponent;
}
/**
* @param exponent the exponent to set
*/
public void setExponent(int exponent) {
this.exponent = exponent;
}
/**
* @return the exponentReverse
*/
public boolean isExponentReverse() {
return exponentReverse;
}
/**
* @param exponentReverse the exponentReverse to set
*/
public void setExponentReverse(boolean exponentReverse) {
this.exponentReverse = exponentReverse;
}
/**
* @return the operand
*/
public UnitXConverterStepValueRead getOperand() {
return operand;
}
/**
* @param operand the operand to set
*/
public void setOperand(UnitXConverterStepValueRead operand) {
this.operand = operand;
}
/**
* @return the result
*/
public UnitXConverterStepValueReadWrite getResult() {
return result;
}
/**
* @param result the result to set
*/
public void setResult(UnitXConverterStepValueReadWrite result) {
this.result = result;
}
}

View file

@ -0,0 +1,84 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.step;
import java.util.List;
import org.apache.commons.lang3.Validate;
import net.forwardfire.unitxc.model.UnitXCType;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 7, 2016
*/
public class UnitXCConverterStepReference extends AbstractUnitXConverterStep {
private final UnitXCType unitType;
private final boolean toBaseSteps;
public UnitXCConverterStepReference(UnitXCType unitType,boolean toBaseSteps) {
this.unitType = Validate.notNull(unitType);
this.toBaseSteps = toBaseSteps;
}
@Override
public void runStep(UnitXConverterStepContext ctx) {
List<UnitXConverterStep> steps = toBaseSteps?unitType.getToBaseConverterSteps():unitType.getFromBaseConverterSteps();
ctx.runSteps(steps);
}
@Override
public void toRuleCode(RuleStepCodePrinter printer) {
if (printer.isEnglish()) {
printer.lineStart("Call ", unitType.getName());
printer.append(" with base steps ... ");
printer.lineEnd(".");
return;
}
printer.lineStart();
printer.append(" TODO REF ");
printer.lineEnd();
}
/**
* @return the unitType
*/
public UnitXCType getUnitType() {
return unitType;
}
/**
* @return the toBaseSteps
*/
public boolean toBaseSteps() {
return toBaseSteps;
}
}

View file

@ -0,0 +1,47 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.step;
import java.util.List;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 10, 2015
*/
public interface UnitXConverterStep {
void runStep(UnitXConverterStepContext ctx);
List<String> getStepReasons();
void addStepReason(String stepReason); // TODO: rm : fix builder
void toRuleCode(RuleStepCodePrinter printer);
}

View file

@ -0,0 +1,62 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.step;
import java.math.MathContext;
import java.util.List;
import net.forwardfire.unitxc.UnitXCManager;
import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueNamedVariable;
import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueRead;
import net.forwardfire.unitxc.model.step.value.UnitXConverterStepValueReadWrite;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 10, 2015
*/
public interface UnitXConverterStepContext {
static final String VALUE = "value";
static final String VALUE_START = "valueStart";
MathContext getMathContext();
void setNamedVariable(String name,UnitXConverterStepValueReadWrite variable);
UnitXConverterStepValueReadWrite getNamedVariable(String name);
UnitXConverterStepValueRead getNamedParameter(String name);
void runSteps(List<UnitXConverterStep> steps);
public static UnitXConverterStepValueReadWrite createStepValue() {
return new UnitXConverterStepValueNamedVariable(Double.class,VALUE);
}
}

View file

@ -0,0 +1,28 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.step;

View file

@ -0,0 +1,82 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.step.value;
import net.forwardfire.unitxc.model.step.RuleStepCodePrinter;
import net.forwardfire.unitxc.model.step.UnitXConverterStepContext;
/**
*
*
* @author Willem Cazander
* @version 1.0 Apr 1, 2016
*/
public class UnitXConverterStepValueNamedParameter implements UnitXConverterStepValueRead {
private String parameterName;
public UnitXConverterStepValueNamedParameter() {
}
public UnitXConverterStepValueNamedParameter(String parameterName) {
setParameterName(parameterName);
}
@Override
public Object valueRead(UnitXConverterStepContext ctx) {
return ctx.getNamedParameter(parameterName).valueRead(ctx);
}
@Override
public void toRuleCodeRead(RuleStepCodePrinter printer) {
if (printer.isEnglish()) {
printer.append(parameterName);
return;
}
printer.append("ctx.params['",parameterName,"']");
}
// @Override
// public void toRuleCodeWrite(RuleStepCodePrinter printer) {
// toRuleCodeRead(printer);
// }
/**
* @return the parameterName
*/
public String getParameterName() {
return parameterName;
}
/**
* @param parameterName the parameterName to set
*/
public void setParameterName(String parameterName) {
this.parameterName = parameterName;
}
}

View file

@ -0,0 +1,103 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.step.value;
import net.forwardfire.unitxc.model.step.RuleStepCodePrinter;
import net.forwardfire.unitxc.model.step.UnitXConverterStepContext;
/**
*
*
* @author Willem Cazander
* @version 1.0 Apr 1, 2016
*/
public class UnitXConverterStepValueNamedVariable implements UnitXConverterStepValueReadWrite {
private Class<?> valueType;
private String variableName;
public UnitXConverterStepValueNamedVariable() {
}
public UnitXConverterStepValueNamedVariable(Class<?> valueType,String variableName) {
setValueType(valueType);
setVariableName(variableName);
}
@Override
public Object valueRead(UnitXConverterStepContext ctx) {
return ctx.getNamedVariable(variableName).valueRead(ctx);
}
@Override
public void valueWrite(UnitXConverterStepContext ctx,Object value) {
ctx.getNamedVariable(variableName).valueWrite(ctx,value);
}
@Override
public void toRuleCodeRead(RuleStepCodePrinter printer) {
if (printer.isEnglish()) {
printer.append(variableName);
} else {
printer.append("ctx.vars['",variableName,"']");
}
}
@Override
public void toRuleCodeWrite(RuleStepCodePrinter printer) {
toRuleCodeRead(printer);
}
/**
* @return the variableName
*/
public String getVariableName() {
return variableName;
}
/**
* @param variableName the variableName to set
*/
public void setVariableName(String variableName) {
this.variableName = variableName;
}
/**
* @return the valueType
*/
public Class<?> getValueType() {
return valueType;
}
/**
* @param valueType the valueType to set
*/
public void setValueType(Class<?> valueType) {
this.valueType = valueType;
}
}

View file

@ -0,0 +1,44 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.step.value;
import net.forwardfire.unitxc.model.step.RuleStepCodePrinter;
import net.forwardfire.unitxc.model.step.UnitXConverterStepContext;
/**
*
*
* @author Willem Cazander
* @version 1.0 Apr 1, 2016
*/
public interface UnitXConverterStepValueRead {
Object valueRead(UnitXConverterStepContext ctx);
void toRuleCodeRead(RuleStepCodePrinter printer);
}

View file

@ -0,0 +1,44 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.step.value;
import net.forwardfire.unitxc.model.step.RuleStepCodePrinter;
import net.forwardfire.unitxc.model.step.UnitXConverterStepContext;
/**
*
*
* @author Willem Cazander
* @version 1.0 Apr 1, 2016
*/
public interface UnitXConverterStepValueReadWrite extends UnitXConverterStepValueRead {
void valueWrite(UnitXConverterStepContext ctx,Object value);
void toRuleCodeWrite(RuleStepCodePrinter printer);
}

View file

@ -0,0 +1,85 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.step.value;
import org.apache.commons.lang3.StringUtils;
import net.forwardfire.unitxc.model.step.RuleStepCodePrinter;
import net.forwardfire.unitxc.model.step.UnitXConverterStepContext;
/**
* Holds an Double value.
*
* @author Willem Cazander
* @version 1.0 Apr 1, 2016
*/
public class UnitXConverterStepValueReferenceDouble implements UnitXConverterStepValueReadWrite {
private Double value;
public UnitXConverterStepValueReferenceDouble() {
}
public UnitXConverterStepValueReferenceDouble(Double value) {
setValue(value);
}
@Override
public Object valueRead(UnitXConverterStepContext ctx) {
return value;
}
@Override
public void valueWrite(UnitXConverterStepContext ctx,Object value) {
this.value = Double.class.cast(value);
}
@Override
public void toRuleCodeRead(RuleStepCodePrinter printer) {
printer.append(""+value);
}
@Override
public void toRuleCodeWrite(RuleStepCodePrinter printer) {
printer.append(StringUtils.EMPTY);
}
/**
* @return the value
*/
public Double getValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(Double value) {
this.value = value;
}
}

View file

@ -0,0 +1,90 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.step.value;
import net.forwardfire.unitxc.model.step.RuleStepCodePrinter;
import net.forwardfire.unitxc.model.step.UnitXConverterStepContext;
/**
* Holds an Double value as a Fraction.
*
* @author Willem Cazander
* @version 1.0 Apr 1, 2016
*/
public class UnitXConverterStepValueReferenceDoubleFraction implements UnitXConverterStepValueRead {
private int numerator;
private int denominator;
public UnitXConverterStepValueReferenceDoubleFraction() {
}
public UnitXConverterStepValueReferenceDoubleFraction(int numerator,int denominator) {
setNumerator(numerator);
setDenominator(denominator);
}
@Override
public Object valueRead(UnitXConverterStepContext ctx) {
//new BigDecimal(numerator).divide(new BigDecimal(denominator));
return (Double)(((Integer)numerator).doubleValue()/((Integer)denominator).doubleValue()); // FIXME
}
@Override
public void toRuleCodeRead(RuleStepCodePrinter printer) {
printer.append(""+numerator+"/"+denominator);
}
/**
* @return the numerator
*/
public int getNumerator() {
return numerator;
}
/**
* @param numerator the numerator to set
*/
public void setNumerator(int numerator) {
this.numerator = numerator;
}
/**
* @return the denominator
*/
public int getDenominator() {
return denominator;
}
/**
* @param denominator the denominator to set
*/
public void setDenominator(int denominator) {
this.denominator = denominator;
}
}

View file

@ -0,0 +1,85 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.step.value;
import org.apache.commons.lang3.StringUtils;
import net.forwardfire.unitxc.model.step.RuleStepCodePrinter;
import net.forwardfire.unitxc.model.step.UnitXConverterStepContext;
/**
* Holds an Integer value.
*
* @author Willem Cazander
* @version 1.0 Apr 1, 2016
*/
public class UnitXConverterStepValueReferenceInteger implements UnitXConverterStepValueReadWrite {
private Integer value;
public UnitXConverterStepValueReferenceInteger() {
}
public UnitXConverterStepValueReferenceInteger(Integer value) {
setValue(value);
}
@Override
public Object valueRead(UnitXConverterStepContext ctx) {
return value;
}
@Override
public void valueWrite(UnitXConverterStepContext ctx,Object value) {
this.value = Integer.class.cast(value);
}
@Override
public void toRuleCodeRead(RuleStepCodePrinter printer) {
printer.append(""+value);
}
@Override
public void toRuleCodeWrite(RuleStepCodePrinter printer) {
printer.append(StringUtils.EMPTY);
}
/**
* @return the value
*/
public Integer getValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(Integer value) {
this.value = value;
}
}

View file

@ -0,0 +1,90 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.step.value;
import org.apache.commons.lang3.StringUtils;
import net.forwardfire.unitxc.model.step.RuleStepCodePrinter;
import net.forwardfire.unitxc.model.step.UnitXConverterStepContext;
/**
* Holds an String value.
*
* @author Willem Cazander
* @version 1.0 Apr 1, 2016
*/
public class UnitXConverterStepValueReferenceString implements UnitXConverterStepValueReadWrite {
private String value;
public UnitXConverterStepValueReferenceString() {
}
public UnitXConverterStepValueReferenceString(String value) {
setValue(value);
}
@Override
public Object valueRead(UnitXConverterStepContext ctx) {
return value;
}
@Override
public void valueWrite(UnitXConverterStepContext ctx,Object value) {
this.value = String.class.cast(value);
}
@Override
public void toRuleCodeRead(RuleStepCodePrinter printer) {
if (value instanceof String && printer.isJavascript()) {
String valueEscaped = value.toString().replaceAll("'", "\\\\'");
printer.append("'",valueEscaped,"'");
} else {
printer.append(""+value);
}
}
@Override
public void toRuleCodeWrite(RuleStepCodePrinter printer) {
printer.append(StringUtils.EMPTY);
}
/**
* @return the value
*/
public String getValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(String value) {
this.value = value;
}
}

View file

@ -0,0 +1,28 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.step.value;

View file

@ -0,0 +1,72 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.module;
import static net.forwardfire.unitxc.config.UnitXCConfigModule.buildFlag;
import net.forwardfire.unitxc.config.UnitXCConfigModule;
import net.forwardfire.unitxc.config.builder.UnitXCConfigBuilder;
import net.forwardfire.unitxc.config.builder.UnitXCTypeSIPrefix;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 18, 2015
*/
public class UnitXCModuleAmpere implements UnitXCConfigModule {
public static final String GROUP_ID = "ampere";
public static final String GROUP_BASE_TYPE_ID = "A";
private static final String[] GROUP_QUANTITIES = {"electric_current"};
public static final String TYPE_AMPERE_ID = GROUP_BASE_TYPE_ID;
public static final String TYPE_AMPERE_NAME = "ampere";
public static final String TYPE_AMPERE_FLAG = buildFlag(GROUP_ID,TYPE_AMPERE_NAME);
private static final String TYPE_AMPERE_WIKI = "Ampere";
@Override
public void configModule(UnitXCConfigBuilder builder) {
builder.createUnitGroupBase(GROUP_ID)
.addQuantityIds(GROUP_QUANTITIES)
.setBaseTypeId(GROUP_BASE_TYPE_ID)
.createSIUnitTypes()
.setId( TYPE_AMPERE_ID)
.setName( TYPE_AMPERE_NAME)
.addTypeFlag( TYPE_AMPERE_FLAG)
.setWebLinkWiki( TYPE_AMPERE_WIKI)
.addCommonSIPrefix(UnitXCTypeSIPrefix.MEGA)
.addCommonSIPrefix(UnitXCTypeSIPrefix.KILO)
.addCommonSIPrefix(UnitXCTypeSIPrefix.MILLI)
.addCommonSIPrefix(UnitXCTypeSIPrefix.MICRO)
.addCommonSIPrefix(UnitXCTypeSIPrefix.NANO)
.build()
.build()
;
}
}

View file

@ -0,0 +1,66 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.module;
import static net.forwardfire.unitxc.config.UnitXCConfigModule.buildFlag;
import net.forwardfire.unitxc.config.UnitXCConfigModule;
import net.forwardfire.unitxc.config.builder.UnitXCConfigBuilder;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 23, 2015
*/
public class UnitXCModuleCandela implements UnitXCConfigModule {
public static final String GROUP_ID = "candela";
public static final String GROUP_BASE_TYPE_ID = "cd";
private static final String[] GROUP_QUANTITIES = {"luminous_intensity"};
public static final String TYPE_CANDELA_ID = GROUP_BASE_TYPE_ID;
public static final String TYPE_CANDELA_NAME = "candela";
public static final String TYPE_CANDELA_FLAG = buildFlag(GROUP_ID,TYPE_CANDELA_NAME);
private static final String TYPE_CANDELA_WIKI = "Candela";
@Override
public void configModule(UnitXCConfigBuilder builder) {
builder.createUnitGroupBase(GROUP_ID)
.addQuantityIds(GROUP_QUANTITIES)
.setBaseTypeId(GROUP_BASE_TYPE_ID)
.createSIUnitTypes()
.setId( TYPE_CANDELA_ID)
.setName( TYPE_CANDELA_NAME)
.addTypeFlag( TYPE_CANDELA_FLAG)
.setWebLinkWiki( TYPE_CANDELA_WIKI)
.build()
.build()
;
}
}

View file

@ -0,0 +1,149 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.module;
import net.forwardfire.unitxc.config.UnitXCConfigModule;
import net.forwardfire.unitxc.config.builder.UnitXCConfigBuilder;
import static net.forwardfire.unitxc.config.UnitXCConfigModule.buildFlag;
import org.apache.commons.lang3.math.Fraction;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 17, 2015
*/
public class UnitXCModuleKelvin implements UnitXCConfigModule {
public static final String GROUP_ID = "kelvin";
public static final String GROUP_BASE_TYPE_ID = "K";
private static final String[] GROUP_QUANTITIES = {"thermodynamic_temperature"};
public static final String TYPE_KELVIN_ID = GROUP_BASE_TYPE_ID;
public static final String TYPE_KELVIN_NAME = GROUP_ID;
public static final String TYPE_KELVIN_FLAG = buildFlag(GROUP_ID,TYPE_KELVIN_NAME);
private static final String TYPE_KELVIN_WIKI = "Kelvin";
public static final String TYPE_CELSIUS_ID = "°C";
public static final String TYPE_CELSIUS_NAME = "celsius";
public static final String TYPE_CELSIUS_FLAG = buildFlag(GROUP_ID,TYPE_CELSIUS_NAME);
private static final double TYPE_CELSIUS_OFFSET = 273.15;
private static final String TYPE_CELSIUS_WIKI = "Celsius";
public static final String TYPE_FAHRENHEIT_ID = "°F";
public static final String TYPE_FAHRENHEIT_NAME = "fahrenheit";
public static final String TYPE_FAHRENHEIT_FLAG = buildFlag(GROUP_ID,TYPE_FAHRENHEIT_NAME);
private static final double TYPE_FAHRENHEIT_OFFSET = 459.67;
private static final Fraction TYPE_FAHRENHEIT_FRACTION = Fraction.getFraction(5,9);
private static final String TYPE_FAHRENHEIT_WIKI = "Fahrenheit";
public static final String TYPE_RANKINE_ID = "°R";
public static final String TYPE_RANKINE_NAME = "rankine";
public static final String TYPE_RANKINE_FLAG = buildFlag(GROUP_ID,TYPE_RANKINE_NAME);
private static final String TYPE_RANKINE_WIKI = "Rankine_scale";
public static final String TYPE_ROMER_ID = "";
public static final String TYPE_ROMER_NAME = "rømer";
public static final String TYPE_ROMER_FLAG = buildFlag(GROUP_ID,TYPE_ROMER_NAME);
public static final String TYPE_ROMER_ALIAS_NAME = "romer";
public static final String TYPE_ROMER_ALIAS_FLAG = buildFlag(GROUP_ID,TYPE_ROMER_ALIAS_NAME);
private static final Fraction TYPE_ROMER_FRACTION = Fraction.getFraction(40,21);
private static final double TYPE_ROMER_FRACTION_OFFSET = 7.5;
private static final String TYPE_ROMER_WIKI = "Rømer_scale";
@Override
public void configModule(UnitXCConfigBuilder builder) {
builder.createUnitGroupBase(GROUP_ID)
.addQuantityIds(GROUP_QUANTITIES)
.setBaseTypeId( TYPE_KELVIN_ID)
.createSIUnitTypes()
.setId( TYPE_KELVIN_ID)
.setName( TYPE_KELVIN_NAME)
.addTypeFlag( TYPE_KELVIN_FLAG)
.setWebLinkWiki(TYPE_KELVIN_WIKI)
.build()
.createSIUnitTypes()
.setId( TYPE_CELSIUS_ID)
.setName( TYPE_CELSIUS_NAME)
.addTypeFlag( TYPE_CELSIUS_FLAG)
.setWebLinkWiki(TYPE_CELSIUS_WIKI)
.createToBaseConverterSteps().offsetUp(TYPE_CELSIUS_OFFSET).build()
.createFromBaseConverterSteps().offsetDown(TYPE_CELSIUS_OFFSET).build()
.build()
.createSIUnitTypes()
.setId( TYPE_FAHRENHEIT_ID)
.setName( TYPE_FAHRENHEIT_NAME)
.addTypeFlag( TYPE_FAHRENHEIT_FLAG)
.addTypeFlag( UnitXCConfigBuilder.TYPE_FLAG_IMPERIAL)
.setWebLinkWiki( TYPE_FAHRENHEIT_WIKI)
.createToBaseConverterSteps()
.offsetUp( TYPE_FAHRENHEIT_OFFSET)
.multiply( TYPE_FAHRENHEIT_FRACTION)
.build()
.createFromBaseConverterSteps()
.multiply( TYPE_FAHRENHEIT_FRACTION.invert())
.offsetDown( TYPE_FAHRENHEIT_OFFSET)
.build()
.build()
.createSIUnitTypes()
.setId( TYPE_RANKINE_ID)
.setName( TYPE_RANKINE_NAME)
.addTypeFlag ( TYPE_RANKINE_FLAG)
.setWebLinkWiki( TYPE_RANKINE_WIKI)
.createToBaseConverterSteps().multiply(TYPE_FAHRENHEIT_FRACTION).build()
.createFromBaseConverterSteps().multiply(TYPE_FAHRENHEIT_FRACTION.invert()).build()
.build()
.createSIUnitTypes()
.setId( TYPE_ROMER_ID)
.setName( TYPE_ROMER_NAME)
.addTypeFlag( TYPE_ROMER_FLAG)
.setWebLinkWiki( TYPE_ROMER_WIKI)
.createToBaseConverterSteps()
.offsetUp( TYPE_CELSIUS_OFFSET)
.multiply( TYPE_ROMER_FRACTION)
.offsetUp( TYPE_ROMER_FRACTION_OFFSET)
.build()
.createFromBaseConverterSteps()
.offsetDown( TYPE_ROMER_FRACTION_OFFSET)
.multiply( TYPE_ROMER_FRACTION.invert())
.offsetDown( TYPE_CELSIUS_OFFSET)
.build()
.build()
.createSIUnitTypes()
.setAliasOfType( TYPE_ROMER_ID)
.setId( TYPE_ROMER_ALIAS_NAME)
.setName( TYPE_ROMER_ALIAS_NAME)
.addTypeFlag( TYPE_ROMER_ALIAS_FLAG)
.build()
.build()
;
}
}

View file

@ -0,0 +1,152 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.module;
import static net.forwardfire.unitxc.config.UnitXCConfigModule.buildFlag;
import net.forwardfire.unitxc.config.UnitXCConfigModule;
import net.forwardfire.unitxc.config.builder.UnitXCConfigBuilder;
import net.forwardfire.unitxc.config.builder.UnitXCTypeSIPrefix;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 25, 2015
*/
public class UnitXCModuleKilogram implements UnitXCConfigModule {
public static final String GROUP_ID = "kilogram";
public static final String GROUP_BASE_TYPE_ID = "g";
private static final String[] GROUP_QUANTITIES = {"mass"};
public static final String TYPE_GRAM_ID = GROUP_BASE_TYPE_ID;
public static final String TYPE_GRAM_NAME = "gram";
public static final String TYPE_GRAM_FLAG = buildFlag(GROUP_ID,TYPE_GRAM_NAME);
private static final String TYPE_GRAM_WIKI = "Kilogram";
public static final String TYPE_GRAIN_ID = "gr";
public static final String TYPE_GRAIN_NAME = "grain";
public static final String TYPE_GRAIN_FLAG = buildFlag(GROUP_ID,TYPE_GRAIN_NAME);
private static final double TYPE_GRAIN_FACTOR = 64.80;
private static final String TYPE_GRAIN_WIKI = "Grain_(unit)";
public static final String TYPE_DRAM_ID = "dr";
public static final String TYPE_DRAM_NAME = "dram";
public static final String TYPE_DRAM_FLAG = buildFlag(GROUP_ID,TYPE_DRAM_NAME);
private static final double TYPE_DRAM_FACTOR = 1.772;
private static final String TYPE_DRAM_WIKI = "Dram_(unit)";
public static final String TYPE_OUNCE_ID = "oz";
public static final String TYPE_OUNCE_NAME = "ounce";
public static final String TYPE_OUNCE_FLAG = buildFlag(GROUP_ID,TYPE_OUNCE_NAME);
private static final double TYPE_OUNCE_FACTOR = 28.35;
private static final String TYPE_OUNCE_WIKI = "Ounce";
public static final String TYPE_POUND_ID = "lb";
public static final String TYPE_POUND_NAME = "pound";
public static final String TYPE_POUND_FLAG = buildFlag(GROUP_ID,TYPE_POUND_NAME);
private static final double TYPE_POUND_FACTOR = 453.6;
private static final String TYPE_POUND_WIKI = "Pound_(mass)";
public static final String TYPE_STONE_ID = "st";
public static final String TYPE_STONE_NAME = "stone";
public static final String TYPE_STONE_FLAG = buildFlag(GROUP_ID,TYPE_STONE_NAME);
private static final double TYPE_STONE_FACTOR = 6.350;
private static final String TYPE_STONE_WIKI = "Stone_(unit)";
@Override
public void configModule(UnitXCConfigBuilder builder) {
builder.createUnitGroupBase(GROUP_ID)
.addQuantityIds(GROUP_QUANTITIES)
.setBaseTypeId(GROUP_BASE_TYPE_ID)
.createSIUnitTypes()
.setId( TYPE_GRAM_ID)
.setName( TYPE_GRAM_NAME)
.addTypeFlag( TYPE_GRAM_FLAG)
.setWebLinkWiki( TYPE_GRAM_WIKI)
.addCommonSIPrefix(UnitXCTypeSIPrefix.MEGA)
.addCommonSIPrefix(UnitXCTypeSIPrefix.KILO)
.addCommonSIPrefix(UnitXCTypeSIPrefix.HECTO)
.addCommonSIPrefix(UnitXCTypeSIPrefix.DECI)
.addCommonSIPrefix(UnitXCTypeSIPrefix.DECA)
.addCommonSIPrefix(UnitXCTypeSIPrefix.CENTI)
.addCommonSIPrefix(UnitXCTypeSIPrefix.MILLI)
.addCommonSIPrefix(UnitXCTypeSIPrefix.MICRO)
.build()
.createSIUnitTypes()
.setId( TYPE_GRAIN_ID)
.setName( TYPE_GRAIN_NAME)
.addTypeFlag( TYPE_GRAIN_FLAG)
.addTypeFlag( UnitXCConfigBuilder.TYPE_FLAG_IMPERIAL)
.setWebLinkWiki( TYPE_GRAIN_WIKI)
.createToBaseConverterSteps().multiply(TYPE_GRAIN_FACTOR).power10Down(UnitXCTypeSIPrefix.MILLI).build()
.createFromBaseConverterSteps().power10Up(UnitXCTypeSIPrefix.MILLI).divide(TYPE_GRAIN_FACTOR).build()
.build()
.createSIUnitTypes()
.setId( TYPE_DRAM_ID)
.setName( TYPE_DRAM_NAME)
.addTypeFlag( TYPE_DRAM_FLAG)
.addTypeFlag( UnitXCConfigBuilder.TYPE_FLAG_IMPERIAL)
.addTypeFlag( UnitXCConfigBuilder.TYPE_FLAG_IMPERIAL_EXTRA)
.setWebLinkWiki( TYPE_DRAM_WIKI)
.createToBaseConverterSteps().multiply(TYPE_DRAM_FACTOR).build()
.createFromBaseConverterSteps().divide(TYPE_DRAM_FACTOR).build()
.build()
.createSIUnitTypes()
.setId( TYPE_OUNCE_ID)
.setName( TYPE_OUNCE_NAME)
.addTypeFlag( TYPE_OUNCE_FLAG)
.addTypeFlag( UnitXCConfigBuilder.TYPE_FLAG_IMPERIAL)
.setWebLinkWiki( TYPE_OUNCE_WIKI)
.createToBaseConverterSteps().multiply(TYPE_OUNCE_FACTOR).build()
.createFromBaseConverterSteps().divide(TYPE_OUNCE_FACTOR).build()
.build()
.createSIUnitTypes()
.setId( TYPE_POUND_ID)
.setName( TYPE_POUND_NAME)
.addTypeFlag( TYPE_POUND_FLAG)
.addTypeFlag( UnitXCConfigBuilder.TYPE_FLAG_IMPERIAL)
.setWebLinkWiki( TYPE_POUND_WIKI)
.createToBaseConverterSteps().multiply(TYPE_POUND_FACTOR).build()
.createFromBaseConverterSteps().divide(TYPE_POUND_FACTOR).build()
.build()
.createSIUnitTypes()
.setId( TYPE_STONE_ID)
.setName( TYPE_STONE_NAME)
.addTypeFlag( TYPE_STONE_FLAG)
.addTypeFlag( UnitXCConfigBuilder.TYPE_FLAG_IMPERIAL)
.addTypeFlag( UnitXCConfigBuilder.TYPE_FLAG_IMPERIAL_EXTRA)
.setWebLinkWiki( TYPE_STONE_WIKI)
.createToBaseConverterSteps().multiply(TYPE_STONE_FACTOR).power10Up(UnitXCTypeSIPrefix.MILLI).build()
.createFromBaseConverterSteps().power10Down(UnitXCTypeSIPrefix.MILLI).divide(TYPE_STONE_FACTOR).build()
.build()
.build()
;
}
}

View file

@ -0,0 +1,247 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.module;
import static net.forwardfire.unitxc.config.UnitXCConfigModule.buildFlag;
import net.forwardfire.unitxc.config.UnitXCConfigModule;
import net.forwardfire.unitxc.config.builder.UnitXCConfigBuilder;
import net.forwardfire.unitxc.config.builder.UnitXCTypeSIPrefix;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 24, 2015
*/
public class UnitXCModuleMetre implements UnitXCConfigModule {
public static final String GROUP_ID = "metre";
public static final String GROUP_BASE_TYPE_ID = "m";
private static final String[] GROUP_QUANTITIES = {"length"};
public static final String TYPE_METRE_ID = GROUP_BASE_TYPE_ID;
public static final String TYPE_METRE_NAME = "metre";
public static final String TYPE_METRE_FLAG = buildFlag(GROUP_ID,TYPE_METRE_NAME);
public static final String TYPE_METRE_ALIAS_METER = "meter";
public static final String TYPE_METRE_ALIAS_METER_FLAG = buildFlag(GROUP_ID,TYPE_METRE_ALIAS_METER);
private static final String TYPE_METRE_WIKI = "Metre";
private static final UnitXCTypeSIPrefix[] TYPE_METRE_COMMON_SI = new UnitXCTypeSIPrefix[] {
UnitXCTypeSIPrefix.KILO,
UnitXCTypeSIPrefix.HECTO,
UnitXCTypeSIPrefix.DECA,
UnitXCTypeSIPrefix.DECI,
UnitXCTypeSIPrefix.CENTI,
UnitXCTypeSIPrefix.MILLI,
UnitXCTypeSIPrefix.MICRO,
UnitXCTypeSIPrefix.NANO,
UnitXCTypeSIPrefix.PICO,
UnitXCTypeSIPrefix.FEMTO
};
public static final String TYPE_INCH_ID = "in";
public static final String TYPE_INCH_NAME = "inch";
public static final String TYPE_INCH_NAME_PLURAL = "inches";
public static final String TYPE_INCH_FLAG = buildFlag(GROUP_ID,TYPE_INCH_NAME);
private static final double TYPE_INCH_FACTOR = 25.4;
private static final String TYPE_INCH_WIKI = "Inch";
public static final String TYPE_LINK_ID = "li";
public static final String TYPE_LINK_NAME = "link";
public static final String TYPE_LINK_FLAG = buildFlag(GROUP_ID,TYPE_LINK_NAME);
private static final double TYPE_LINK_FACTOR = 201.1;
public static final String TYPE_LINK_WIKI = "Link_(unit)";
public static final String TYPE_FOOT_ID = "ft";
public static final String TYPE_FOOT_NAME = "foot";
public static final String TYPE_FOOT_NAME_PLURAL = "feet";
public static final String TYPE_FOOT_FLAG = buildFlag(GROUP_ID,TYPE_FOOT_NAME);
private static final double TYPE_FOOT_FACTOR = 304.8;
private static final String TYPE_FOOT_WIKI = "Foot_(unit)";
public static final String TYPE_YARD_ID = "yd";
public static final String TYPE_YARD_NAME = "yard";
public static final String TYPE_YARD_FLAG = buildFlag(GROUP_ID,TYPE_YARD_NAME);
private static final double TYPE_YARD_FACTOR = 0.9144;
private static final String TYPE_YARD_WIKI = "Yard";
public static final String TYPE_ROD_ID = "rd";
public static final String TYPE_ROD_NAME = "rod";
public static final String TYPE_ROD_FLAG = buildFlag(GROUP_ID,TYPE_ROD_NAME);
private static final double TYPE_ROD_FACTOR = 5.029;
private static final String TYPE_ROD_WIKI = "Rod_(unit)";
public static final String TYPE_CHAIN_ID = "ch";
public static final String TYPE_CHAIN_NAME = "chain";
public static final String TYPE_CHAIN_FLAG = buildFlag(GROUP_ID,TYPE_CHAIN_NAME);
private static final double TYPE_CHAIN_FACTOR = 20.117;
private static final String TYPE_CHAIN_WIKI = "Chain_(unit)";
public static final String TYPE_FURLONG_ID = "fur";
public static final String TYPE_FURLONG_NAME = "furlong";
public static final String TYPE_FURLONG_FLAG = buildFlag(GROUP_ID,TYPE_FURLONG_NAME);
private static final double TYPE_FURLONG_FACTOR = 201.17;
private static final String TYPE_FURLONG_WIKI = "Furlong";
public static final String TYPE_MILE_ID = "mi";
public static final String TYPE_MILE_NAME = "mile";
public static final String TYPE_MILE_FLAG = buildFlag(GROUP_ID,TYPE_MILE_NAME);
private static final double TYPE_MILE_FACTOR = 1609.344;
private static final String TYPE_MILE_WIKI = "Mile";
public static final String TYPE_MILE_US_ID = "us-mi";
public static final String TYPE_MILE_US_NAME = "us-mile";
public static final String TYPE_MILE_US_FLAG = buildFlag(GROUP_ID,TYPE_MILE_US_NAME);
private static final double TYPE_MILE_US_FACTOR = 1609.34721869;
private static final String TYPE_MILE_US_WIKI = "Mile#US_survey_mile";
public static final String TYPE_MILE_NAUTICAL_ID = "nau-mi";
public static final String TYPE_MILE_NAUTICAL_NAME = "nautical-mile";
public static final String TYPE_MILE_NAUTICAL_FLAG = buildFlag(GROUP_ID,TYPE_MILE_NAUTICAL_NAME);
private static final double TYPE_MILE_NAUTICAL_FACTOR = 1852;
private static final String TYPE_MILE_NAUTICAL_WIKI = "Mile#Nautical_mile";
@Override
public void configModule(UnitXCConfigBuilder builder) {
builder.createUnitGroupBase(GROUP_ID)
.addQuantityIds(GROUP_QUANTITIES)
.setBaseTypeId( TYPE_METRE_ID)
.createSIUnitTypes()
.setId( TYPE_METRE_ID)
.setName( TYPE_METRE_NAME)
.addTypeFlag( TYPE_METRE_FLAG)
.setWebLinkWiki( TYPE_METRE_WIKI)
.addCommonSIPrefixes(TYPE_METRE_COMMON_SI)
.build()
.createSIUnitTypes()
.setAliasOfType(TYPE_METRE_ID)
.setId( TYPE_METRE_ALIAS_METER)
.setName( TYPE_METRE_ALIAS_METER)
.addTypeFlag( TYPE_METRE_ALIAS_METER_FLAG)
.addCommonSIPrefixes(TYPE_METRE_COMMON_SI)
.build()
.createSIUnitTypes()
.setId( TYPE_INCH_ID)
.setName( TYPE_INCH_NAME)
.setNamePlural( TYPE_INCH_NAME_PLURAL)
.addTypeFlag( TYPE_INCH_FLAG)
.addTypeFlag( UnitXCConfigBuilder.TYPE_FLAG_IMPERIAL)
.setWebLinkWiki( TYPE_INCH_WIKI)
.createToBaseConverterSteps().multiply(TYPE_INCH_FACTOR).power10Down(UnitXCTypeSIPrefix.MILLI).build()
.createFromBaseConverterSteps().power10Up(UnitXCTypeSIPrefix.MILLI).divide(TYPE_INCH_FACTOR).build()
.build()
.createSIUnitTypes()
.setId( TYPE_LINK_ID)
.setName( TYPE_LINK_NAME)
.addTypeFlag( TYPE_LINK_FLAG)
.addTypeFlag( UnitXCConfigBuilder.TYPE_FLAG_IMPERIAL)
.addTypeFlag( UnitXCConfigBuilder.TYPE_FLAG_IMPERIAL_EXTRA)
.setWebLinkWiki( TYPE_LINK_WIKI)
.createToBaseConverterSteps().multiply(TYPE_LINK_FACTOR).power10Down(UnitXCTypeSIPrefix.MILLI).build()
.createFromBaseConverterSteps().power10Up(UnitXCTypeSIPrefix.MILLI).divide(TYPE_LINK_FACTOR).build()
.build()
.createSIUnitTypes()
.setId( TYPE_FOOT_ID)
.setName( TYPE_FOOT_NAME)
.setNamePlural( TYPE_FOOT_NAME_PLURAL)
.addTypeFlag( TYPE_FOOT_FLAG)
.addTypeFlag( UnitXCConfigBuilder.TYPE_FLAG_IMPERIAL)
.setWebLinkWiki( TYPE_FOOT_WIKI)
.createToBaseConverterSteps().multiply(TYPE_FOOT_FACTOR).power10Down(UnitXCTypeSIPrefix.MILLI).build()
.createFromBaseConverterSteps().power10Up(UnitXCTypeSIPrefix.MILLI).divide(TYPE_FOOT_FACTOR).build()
.build()
.createSIUnitTypes()
.setId( TYPE_YARD_ID)
.setName( TYPE_YARD_NAME)
.addTypeFlag( TYPE_YARD_FLAG)
.addTypeFlag( UnitXCConfigBuilder.TYPE_FLAG_IMPERIAL)
.setWebLinkWiki( TYPE_YARD_WIKI)
.createToBaseConverterSteps().multiply(TYPE_YARD_FACTOR).build()
.createFromBaseConverterSteps().divide(TYPE_YARD_FACTOR).build()
.build()
.createSIUnitTypes()
.setId( TYPE_ROD_ID)
.setName( TYPE_ROD_NAME)
.addTypeFlag( TYPE_ROD_FLAG)
.addTypeFlag( UnitXCConfigBuilder.TYPE_FLAG_IMPERIAL)
.addTypeFlag( UnitXCConfigBuilder.TYPE_FLAG_IMPERIAL_EXTRA)
.setWebLinkWiki( TYPE_ROD_WIKI)
.createToBaseConverterSteps().multiply(TYPE_ROD_FACTOR).build()
.createFromBaseConverterSteps().divide(TYPE_ROD_FACTOR).build()
.build()
.createSIUnitTypes()
.setId( TYPE_CHAIN_ID)
.setName( TYPE_CHAIN_NAME)
.addTypeFlag( TYPE_CHAIN_FLAG)
.addTypeFlag( UnitXCConfigBuilder.TYPE_FLAG_IMPERIAL)
.addTypeFlag( UnitXCConfigBuilder.TYPE_FLAG_IMPERIAL_EXTRA)
.setWebLinkWiki( TYPE_CHAIN_WIKI)
.createToBaseConverterSteps().multiply(TYPE_CHAIN_FACTOR).build()
.createFromBaseConverterSteps().divide(TYPE_CHAIN_FACTOR).build()
.build()
.createSIUnitTypes()
.setId( TYPE_FURLONG_ID)
.setName( TYPE_FURLONG_NAME)
.addTypeFlag( TYPE_FURLONG_FLAG)
.addTypeFlag( UnitXCConfigBuilder.TYPE_FLAG_IMPERIAL)
.addTypeFlag( UnitXCConfigBuilder.TYPE_FLAG_IMPERIAL_EXTRA)
.setWebLinkWiki( TYPE_FURLONG_WIKI)
.createToBaseConverterSteps().multiply(TYPE_FURLONG_FACTOR).build()
.createFromBaseConverterSteps().divide(TYPE_FURLONG_FACTOR).build()
.build()
.createSIUnitTypes()
.setId( TYPE_MILE_ID)
.setName( TYPE_MILE_NAME)
.addTypeFlag( TYPE_MILE_FLAG)
.addTypeFlag( UnitXCConfigBuilder.TYPE_FLAG_IMPERIAL)
.setWebLinkWiki( TYPE_MILE_WIKI)
.createToBaseConverterSteps().multiply(TYPE_MILE_FACTOR).build()
.createFromBaseConverterSteps().divide(TYPE_MILE_FACTOR).build()
.build()
.createSIUnitTypes()
.setId( TYPE_MILE_US_ID)
.setName( TYPE_MILE_US_NAME)
.addTypeFlag( TYPE_MILE_US_FLAG)
.addTypeFlag( UnitXCConfigBuilder.TYPE_FLAG_IMPERIAL)
.setWebLinkWiki( TYPE_MILE_US_WIKI)
.createToBaseConverterSteps().multiply(TYPE_MILE_US_FACTOR).build()
.createFromBaseConverterSteps().divide(TYPE_MILE_US_FACTOR).build()
.build()
.createSIUnitTypes()
.setId( TYPE_MILE_NAUTICAL_ID)
.setName( TYPE_MILE_NAUTICAL_NAME)
.addTypeFlag( TYPE_MILE_NAUTICAL_FLAG)
.addTypeFlag( UnitXCConfigBuilder.TYPE_FLAG_IMPERIAL)
.setWebLinkWiki( TYPE_MILE_NAUTICAL_WIKI)
.createToBaseConverterSteps().multiply(TYPE_MILE_NAUTICAL_FACTOR).build()
.createFromBaseConverterSteps().divide(TYPE_MILE_NAUTICAL_FACTOR).build()
.build()
.build()
;
}
}

View file

@ -0,0 +1,86 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.module;
import static net.forwardfire.unitxc.config.UnitXCConfigModule.buildFlag;
import net.forwardfire.unitxc.config.UnitXCConfigModule;
import net.forwardfire.unitxc.config.builder.UnitXCConfigBuilder;
import net.forwardfire.unitxc.config.builder.UnitXCTypeSIPrefix;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 23, 2015
*/
public class UnitXCModuleMole implements UnitXCConfigModule {
public static final String GROUP_ID = "mole";
public static final String GROUP_BASE_TYPE_ID = "mol";
private static final String[] GROUP_QUANTITIES = {"amount_of_substance"};
public static final String TYPE_MOL_ID = GROUP_BASE_TYPE_ID;
public static final String TYPE_MOL_NAME = "mole";
public static final String TYPE_MOL_FLAG = buildFlag(GROUP_ID,TYPE_MOL_NAME);
private static final String TYPE_MOL_WIKI = "Mole_(unit)";
public static final String TYPE_POUND_MOLE_ID = "lbmol";// TODO: add lb-mol
public static final String TYPE_POUND_MOLE_NAME = "pound-mole";
public static final String TYPE_POUND_MOLE_FLAG = buildFlag(GROUP_ID,TYPE_POUND_MOLE_NAME);
private static final double TYPE_POUND_MOLE_FACTOR = 453.59237;
private static final String TYPE_POUND_MOLE_WIKI = "Mole_(unit)#Other_units_called_.22mole.22";
@Override
public void configModule(UnitXCConfigBuilder builder) {
builder.createUnitGroupBase(GROUP_ID)
.addQuantityIds( GROUP_QUANTITIES)
.setBaseTypeId( TYPE_MOL_ID)
.createSIUnitTypes()
.setId( TYPE_MOL_ID)
.setName( TYPE_MOL_NAME)
.addTypeFlag( TYPE_MOL_FLAG)
.setWebLinkWiki( TYPE_MOL_WIKI)
.addCommonSIPrefix(UnitXCTypeSIPrefix.MILLI)
.addCommonSIPrefix(UnitXCTypeSIPrefix.MICRO)
.addCommonSIPrefix(UnitXCTypeSIPrefix.NANO)
.addCommonSIPrefix(UnitXCTypeSIPrefix.PICO)
.addCommonSIPrefix(UnitXCTypeSIPrefix.FEMTO)
.build()
.createUnitType()
.setId( TYPE_POUND_MOLE_ID)
.setName( TYPE_POUND_MOLE_NAME)
.addTypeFlag( UnitXCConfigBuilder.TYPE_FLAG_IMPERIAL)
.setWebLinkWiki( TYPE_POUND_MOLE_WIKI)
.createToBaseConverterSteps().multiply(TYPE_POUND_MOLE_FACTOR).build()
.createFromBaseConverterSteps().divide(TYPE_POUND_MOLE_FACTOR).build()
.build()
.build()
;
}
}

View file

@ -0,0 +1,130 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.module;
import static net.forwardfire.unitxc.config.UnitXCConfigModule.buildFlag;
import net.forwardfire.unitxc.config.UnitXCConfigModule;
import net.forwardfire.unitxc.config.builder.UnitXCConfigBuilder;
import net.forwardfire.unitxc.config.builder.UnitXCTypeSIPrefix;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 25, 2015
*/
public class UnitXCModuleSecond implements UnitXCConfigModule {
public static final String GROUP_ID = "second";
public static final String GROUP_BASE_TYPE_ID = "s";
private static final String[] GROUP_QUANTITIES = {"time"};
public static final String TYPE_SECOND_ID = GROUP_BASE_TYPE_ID;
public static final String TYPE_SECOND_NAME = "second";
public static final String TYPE_SECOND_NAMES = TYPE_SECOND_NAME+TYPE_SECOND_ID;
public static final String TYPE_SECOND_FLAG = buildFlag(GROUP_ID,TYPE_SECOND_NAME);
private static final double TIME_EARTH_MINUTE = 60;
private static final double TIME_EARTH_HOUR = TIME_EARTH_MINUTE*60;
private static final double TIME_EARTH_DAY = TIME_EARTH_HOUR*24;
private static final double TIME_EARTH_WEEK = TIME_EARTH_DAY*7;
private static final double TIME_EARTH_YEAR = 31557600;
// related to the rotating earth, or change to be 794 243 384 928 000 hyperfine oscillations
public static final String TYPE_MINUTE_ID = "min";
public static final String TYPE_MINUTE_NAME = "minute";
public static final String TYPE_MINUTE_FLAG = buildFlag(GROUP_ID,TYPE_MINUTE_NAME);
public static final String TYPE_HOUR_ID = "h";
public static final String TYPE_HOUR_NAME = "hour";
public static final String TYPE_HOUR_FLAG = buildFlag(GROUP_ID,TYPE_HOUR_NAME);
public static final String TYPE_DAY_ID = "d";
public static final String TYPE_DAY_NAME = "day";
public static final String TYPE_DAY_FLAG = buildFlag(GROUP_ID,TYPE_DAY_NAME);
public static final String TYPE_WEEK_ID = "wk";
public static final String TYPE_WEEK_NAME = "week";
public static final String TYPE_WEEK_FLAG = buildFlag(GROUP_ID,TYPE_WEEK_NAME);
public static final String TYPE_YEAR_ID = "yr";
public static final String TYPE_YEAR_NAME = "year";
public static final String TYPE_YEAR_FLAG = buildFlag(GROUP_ID,TYPE_YEAR_NAME);
@Override
public void configModule(UnitXCConfigBuilder builder) {
builder.createUnitGroupBase(GROUP_ID)
.addQuantityIds(GROUP_QUANTITIES)
.setBaseTypeId( TYPE_SECOND_ID)
.createSIUnitTypes()
.setId( TYPE_SECOND_ID)
.setName( TYPE_SECOND_NAME)
.addTypeFlag( TYPE_SECOND_FLAG)
.addCommonSIPrefix(UnitXCTypeSIPrefix.MILLI)
.addCommonSIPrefix(UnitXCTypeSIPrefix.MICRO)
.addCommonSIPrefix(UnitXCTypeSIPrefix.NANO)
.addCommonSIPrefix(UnitXCTypeSIPrefix.PICO)
.addCommonSIPrefix(UnitXCTypeSIPrefix.FEMTO)
.addCommonSIPrefix(UnitXCTypeSIPrefix.ATTO)
.build()
.createSIUnitTypes()
.setId( TYPE_MINUTE_ID)
.setName( TYPE_MINUTE_NAME)
.addTypeFlag( TYPE_MINUTE_FLAG)
.createToBaseConverterSteps().multiply(TIME_EARTH_MINUTE).build()
.createFromBaseConverterSteps().divide(TIME_EARTH_MINUTE).build()
.build()
.createSIUnitTypes()
.setId( TYPE_HOUR_ID)
.setName( TYPE_HOUR_NAME)
.addTypeFlag( TYPE_HOUR_FLAG)
.createToBaseConverterSteps().multiply(TIME_EARTH_HOUR).build()
.createFromBaseConverterSteps().divide(TIME_EARTH_HOUR).build()
.build()
.createSIUnitTypes()
.setId( TYPE_DAY_ID)
.setName( TYPE_DAY_NAME)
.addTypeFlag( TYPE_DAY_FLAG)
.createToBaseConverterSteps().multiply(TIME_EARTH_DAY).build()
.createFromBaseConverterSteps().divide(TIME_EARTH_DAY).build()
.build()
.createSIUnitTypes()
.setId( TYPE_WEEK_ID)
.setName( TYPE_WEEK_NAME)
.addTypeFlag( TYPE_WEEK_FLAG)
.createToBaseConverterSteps().multiply(TIME_EARTH_WEEK).build()
.createFromBaseConverterSteps().divide(TIME_EARTH_WEEK).build()
.build()
.createSIUnitTypes()
.setId( TYPE_YEAR_ID)
.setName( TYPE_YEAR_NAME)
.addTypeFlag( TYPE_YEAR_FLAG)
.createToBaseConverterSteps().multiply(TIME_EARTH_YEAR).build()
.createFromBaseConverterSteps().divide(TIME_EARTH_YEAR).build()
.build()
.build()
;
}
}

View file

@ -0,0 +1,63 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.module.derived;
import static net.forwardfire.unitxc.config.builder.UnitXCNumberTypeSetting.toSuperScript;
import net.forwardfire.unitxc.config.UnitXCConfigModule;
import net.forwardfire.unitxc.config.builder.UnitXCConfigBuilder;
import net.forwardfire.unitxc.module.UnitXCModuleMetre;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 28, 2015
*/
public class UnitXCModuleCubicMetre implements UnitXCConfigModule {
private static final int UNIT_COMPOUND_EXPONENT = 3;
private static final String UNIT_ID_POSTFIX = toSuperScript(UNIT_COMPOUND_EXPONENT);
private static final String UNIT_NAME_PREFIX = "cubic ";
public static final String GROUP_ID = "cubic_metre";
public static final String GROUP_DESCRIPTION = "";
public static final String GROUP_BASE_TYPE_ID = UnitXCModuleMetre.GROUP_BASE_TYPE_ID+UNIT_ID_POSTFIX;
private static final String[] GROUP_QUANTITIES = {"volume"};
@Override
public void configModule(UnitXCConfigBuilder builder) {
builder.createUnitGroupCompoundExponent(GROUP_ID,UnitXCModuleMetre.GROUP_ID, UNIT_COMPOUND_EXPONENT)
.addQuantityIds(GROUP_QUANTITIES)
.setBaseTypeId(GROUP_BASE_TYPE_ID)
.setUnitIdPostfix(UNIT_ID_POSTFIX)
.setUnitNamePrefix(UNIT_NAME_PREFIX)
.build()
;
}
}

View file

@ -0,0 +1,55 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.module.derived;
import net.forwardfire.unitxc.config.UnitXCConfigModule;
import net.forwardfire.unitxc.config.builder.UnitXCConfigBuilder;
import net.forwardfire.unitxc.model.UnitXCGroupCompoundPair;
import net.forwardfire.unitxc.module.UnitXCModuleKilogram;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 12, 2016
*/
public class UnitXCModuleCubicMetrePerKilogram implements UnitXCConfigModule {
public static final String GROUP_ID = "cubic_metre_per_kilogram";
public static final String GROUP_BASE_TYPE_ID = UnitXCModuleCubicMetre.GROUP_BASE_TYPE_ID+UnitXCGroupCompoundPair.PER_ID+UnitXCModuleKilogram.GROUP_BASE_TYPE_ID;
private static final String[] GROUP_QUANTITIES = {"specific_volume"};
@Override
public void configModule(UnitXCConfigBuilder builder) {
builder.createUnitGroupCompoundPair(GROUP_ID, UnitXCModuleCubicMetre.GROUP_ID, UnitXCModuleKilogram.GROUP_ID)
.addQuantityIds(GROUP_QUANTITIES)
.setBaseTypeId(GROUP_BASE_TYPE_ID)
.build()
;
}
}

View file

@ -0,0 +1,55 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.module.derived;
import net.forwardfire.unitxc.config.UnitXCConfigModule;
import net.forwardfire.unitxc.config.builder.UnitXCConfigBuilder;
import net.forwardfire.unitxc.model.UnitXCGroupCompoundPair;
import net.forwardfire.unitxc.module.UnitXCModuleMole;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 12, 2016
*/
public class UnitXCModuleCubicMetrePerMole implements UnitXCConfigModule {
public static final String GROUP_ID = "cubic_metre_per_mole";
public static final String GROUP_BASE_TYPE_ID = UnitXCModuleCubicMetre.GROUP_BASE_TYPE_ID+UnitXCGroupCompoundPair.PER_ID+UnitXCModuleMole.GROUP_BASE_TYPE_ID;
private static final String[] GROUP_QUANTITIES = {"molar_volume"};
@Override
public void configModule(UnitXCConfigBuilder builder) {
builder.createUnitGroupCompoundPair(GROUP_ID, UnitXCModuleCubicMetre.GROUP_ID, UnitXCModuleMole.GROUP_ID)
.addQuantityIds(GROUP_QUANTITIES)
.setBaseTypeId(GROUP_BASE_TYPE_ID)
.build()
;
}
}

View file

@ -0,0 +1,55 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.module.derived;
import net.forwardfire.unitxc.config.UnitXCConfigModule;
import net.forwardfire.unitxc.config.builder.UnitXCConfigBuilder;
import net.forwardfire.unitxc.model.UnitXCGroupCompoundPair;
import net.forwardfire.unitxc.module.UnitXCModuleSecond;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 1, 2016
*/
public class UnitXCModuleCubicMetrePerSecond implements UnitXCConfigModule {
public static final String GROUP_ID = "cubic_metre_per_second";
public static final String GROUP_BASE_TYPE_ID = UnitXCModuleCubicMetre.GROUP_BASE_TYPE_ID+UnitXCGroupCompoundPair.PER_ID+UnitXCModuleSecond.GROUP_BASE_TYPE_ID;
private static final String[] GROUP_QUANTITIES = {"volumetric_flow"};
@Override
public void configModule(UnitXCConfigBuilder builder) {
builder.createUnitGroupCompoundPair(GROUP_ID,UnitXCModuleCubicMetre.GROUP_ID, UnitXCModuleSecond.GROUP_ID)
.addQuantityIds(GROUP_QUANTITIES)
.setBaseTypeId( GROUP_BASE_TYPE_ID)
.build()
;
}
}

View file

@ -0,0 +1,55 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.module.derived;
import net.forwardfire.unitxc.config.UnitXCConfigModule;
import net.forwardfire.unitxc.config.builder.UnitXCConfigBuilder;
import net.forwardfire.unitxc.model.UnitXCGroupCompoundPair;
import net.forwardfire.unitxc.module.UnitXCModuleKilogram;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 12, 2016
*/
public class UnitXCModuleKilogramPerCubicMetre implements UnitXCConfigModule {
public static final String GROUP_ID = "kilogram_per_cubic_metre";
public static final String GROUP_BASE_TYPE_ID = UnitXCModuleKilogram.GROUP_BASE_TYPE_ID+UnitXCGroupCompoundPair.PER_ID+UnitXCModuleCubicMetre.GROUP_BASE_TYPE_ID;
private static final String[] GROUP_QUANTITIES = {"density","mass_density"};
@Override
public void configModule(UnitXCConfigBuilder builder) {
builder.createUnitGroupCompoundPair(GROUP_ID, UnitXCModuleKilogram.GROUP_ID, UnitXCModuleCubicMetre.GROUP_ID)
.addQuantityIds(GROUP_QUANTITIES)
.setBaseTypeId(GROUP_BASE_TYPE_ID)
.build()
;
}
}

View file

@ -0,0 +1,55 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.module.derived;
import net.forwardfire.unitxc.config.UnitXCConfigModule;
import net.forwardfire.unitxc.config.builder.UnitXCConfigBuilder;
import net.forwardfire.unitxc.model.UnitXCGroupCompoundPair;
import net.forwardfire.unitxc.module.UnitXCModuleKilogram;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 12, 2016
*/
public class UnitXCModuleKilogramPerSquareMetre implements UnitXCConfigModule {
public static final String GROUP_ID = "kilogram_per_square_metre";
public static final String GROUP_BASE_TYPE_ID = UnitXCModuleKilogram.GROUP_BASE_TYPE_ID+UnitXCGroupCompoundPair.PER_ID+UnitXCModuleSquareMetre.GROUP_BASE_TYPE_ID;
private static final String[] GROUP_QUANTITIES = {"area_density"};
@Override
public void configModule(UnitXCConfigBuilder builder) {
builder.createUnitGroupCompoundPair(GROUP_ID, UnitXCModuleKilogram.GROUP_ID, UnitXCModuleSquareMetre.GROUP_ID)
.addQuantityIds(GROUP_QUANTITIES)
.setBaseTypeId( GROUP_BASE_TYPE_ID)
.build()
;
}
}

View file

@ -0,0 +1,56 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.module.derived;
import net.forwardfire.unitxc.config.UnitXCConfigModule;
import net.forwardfire.unitxc.config.builder.UnitXCConfigBuilder;
import net.forwardfire.unitxc.model.UnitXCGroupCompoundPair;
import net.forwardfire.unitxc.module.UnitXCModuleSecond;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 1, 2016
*/
public class UnitXCModuleMetrePerQuarticSecond implements UnitXCConfigModule {
public static final String GROUP_ID = "metre_per_quartic_second";
public static final String GROUP_BASE_TYPE_ID = UnitXCModuleMetrePerSecondCubed.GROUP_BASE_TYPE_ID+UnitXCGroupCompoundPair.PER_ID+UnitXCModuleSecond.GROUP_BASE_TYPE_ID;
private static final String[] GROUP_QUANTITIES = {"snap","jounce"};
// TODO: add aliases
@Override
public void configModule(UnitXCConfigBuilder builder) {
builder.createUnitGroupCompoundPair(GROUP_ID, UnitXCModuleMetrePerSecondCubed.GROUP_ID, UnitXCModuleSecond.GROUP_ID)
.addQuantityIds(GROUP_QUANTITIES)
.setBaseTypeId(GROUP_BASE_TYPE_ID)
.build()
;
}
}

View file

@ -0,0 +1,58 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.module.derived;
import net.forwardfire.unitxc.config.UnitXCConfigModule;
import net.forwardfire.unitxc.config.builder.UnitXCConfigBuilder;
import net.forwardfire.unitxc.model.UnitXCGroupCompoundPair;
import net.forwardfire.unitxc.model.UnitXCModule;
import net.forwardfire.unitxc.module.UnitXCModuleMetre;
import net.forwardfire.unitxc.module.UnitXCModuleSecond;
/**
*
*
* @author Willem Cazander
* @version 1.0 Nov 3, 2015
*/
@UnitXCModule(groupId=UnitXCModuleMetrePerSecond.GROUP_ID,dependencies={UnitXCModuleMetre.GROUP_ID, UnitXCModuleSecond.GROUP_ID})
public class UnitXCModuleMetrePerSecond implements UnitXCConfigModule {
public static final String GROUP_ID = "metre_per_second";
public static final String GROUP_BASE_TYPE_ID = UnitXCModuleMetre.GROUP_BASE_TYPE_ID+UnitXCGroupCompoundPair.PER_ID+UnitXCModuleSecond.GROUP_BASE_TYPE_ID;
private static final String[] GROUP_QUANTITIES = {"speed","velocity"};
@Override
public void configModule(UnitXCConfigBuilder builder) {
builder.createUnitGroupCompoundPair(GROUP_ID,UnitXCModuleMetre.GROUP_ID, UnitXCModuleSecond.GROUP_ID)
.addQuantityIds(GROUP_QUANTITIES)
.setBaseTypeId(GROUP_BASE_TYPE_ID)
.build()
;
}
}

View file

@ -0,0 +1,56 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.module.derived;
import net.forwardfire.unitxc.config.UnitXCConfigModule;
import net.forwardfire.unitxc.config.builder.UnitXCConfigBuilder;
import net.forwardfire.unitxc.model.UnitXCGroupCompoundPair;
import net.forwardfire.unitxc.module.UnitXCModuleSecond;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 1, 2016
*/
public class UnitXCModuleMetrePerSecondCubed implements UnitXCConfigModule {
public static final String GROUP_ID = "metre_per_second_cubed";
public static final String GROUP_BASE_TYPE_ID = UnitXCModuleMetrePerSecondSquared.GROUP_BASE_TYPE_ID+UnitXCGroupCompoundPair.PER_ID+UnitXCModuleSecond.GROUP_BASE_TYPE_ID;
private static final String[] GROUP_QUANTITIES = {"jerk","jolt","surge","lurch"};
// TODO: add aliases
@Override
public void configModule(UnitXCConfigBuilder builder) {
builder.createUnitGroupCompoundPair(GROUP_ID, UnitXCModuleMetrePerSecondSquared.GROUP_ID, UnitXCModuleSecond.GROUP_ID)
.addQuantityIds(GROUP_QUANTITIES)
.setBaseTypeId( GROUP_BASE_TYPE_ID)
.build()
;
}
}

View file

@ -0,0 +1,65 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.module.derived;
import static net.forwardfire.unitxc.config.builder.UnitXCNumberTypeSetting.toSuperScript;
import net.forwardfire.unitxc.config.UnitXCConfigModule;
import net.forwardfire.unitxc.config.builder.UnitXCConfigBuilder;
import net.forwardfire.unitxc.model.UnitXCGroupCompoundPair;
import net.forwardfire.unitxc.module.UnitXCModuleSecond;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 1, 2016
*/
public class UnitXCModuleMetrePerSecondSquared implements UnitXCConfigModule {
private static final int UNIT_COMPOUND_EXPONENT = 2;
private static final String UNIT_ID_POSTFIX = toSuperScript(UNIT_COMPOUND_EXPONENT);
public static final String GROUP_ID = "metre_per_second_squared";
public static final String GROUP_BASE_TYPE_ID = "m"+UnitXCGroupCompoundPair.PER_ID+UnitXCModuleSecond.GROUP_BASE_TYPE_ID+UNIT_ID_POSTFIX; //UnitXCModuleSpeed.GROUP_BASE_TYPE_ID;
private static final String[] GROUP_QUANTITIES = {"acceleration"};
@Override
public void configModule(UnitXCConfigBuilder builder) {
builder.createUnitGroupCompoundPair(GROUP_ID,UnitXCModuleMetrePerSecond.GROUP_ID, UnitXCModuleSecond.GROUP_ID)
.addQuantityIds(GROUP_QUANTITIES)
.setBaseTypeId(GROUP_BASE_TYPE_ID)
.createUnitType()
.setAliasOfType("m/s/s")
.setId(GROUP_BASE_TYPE_ID)
.setName("Meter per second squared")
.build()
.build()
;
}
}

View file

@ -0,0 +1,55 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.module.derived;
import net.forwardfire.unitxc.config.UnitXCConfigModule;
import net.forwardfire.unitxc.config.builder.UnitXCConfigBuilder;
import net.forwardfire.unitxc.model.UnitXCGroupCompoundPair;
import net.forwardfire.unitxc.module.UnitXCModuleMole;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 12, 2016
*/
public class UnitXCModuleMolePerCubicMetre implements UnitXCConfigModule {
public static final String GROUP_ID = "mole_per_cubic_metre";
public static final String GROUP_BASE_TYPE_ID = UnitXCModuleMole.GROUP_BASE_TYPE_ID+UnitXCGroupCompoundPair.PER_ID+UnitXCModuleCubicMetre.GROUP_BASE_TYPE_ID;
private static final String[] GROUP_QUANTITIES = {"molarity"};
@Override
public void configModule(UnitXCConfigBuilder builder) {
builder.createUnitGroupCompoundPair(GROUP_ID, UnitXCModuleMole.GROUP_ID, UnitXCModuleCubicMetre.GROUP_ID)
.addQuantityIds(GROUP_QUANTITIES)
.setBaseTypeId(GROUP_BASE_TYPE_ID)
.build()
;
}
}

View file

@ -0,0 +1,55 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.module.derived;
import net.forwardfire.unitxc.config.UnitXCConfigModule;
import net.forwardfire.unitxc.config.builder.UnitXCConfigBuilder;
import net.forwardfire.unitxc.module.UnitXCModuleSecond;
import net.forwardfire.unitxc.module.named.UnitXCModuleNewton;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 31, 2016
*/
public class UnitXCModuleNewtonPerSecond implements UnitXCConfigModule {
public static final String GROUP_ID = "newton_per_second";
public static final String GROUP_BASE_TYPE_ID = "kg/m/s/s/s"; //FIXME: UnitXCModuleNewton.GROUP_BASE_TYPE_ID+UnitXCGroupCompoundPair.PER_ID+UnitXCModuleTime.GROUP_BASE_TYPE_ID;
private static final String[] GROUP_QUANTITIES = {"yank"};
@Override
public void configModule(UnitXCConfigBuilder builder) {
builder.createUnitGroupCompoundPair(GROUP_ID, UnitXCModuleNewton.GROUP_ID, UnitXCModuleSecond.GROUP_ID)
.addQuantityIds(GROUP_QUANTITIES)
.setBaseTypeId( GROUP_BASE_TYPE_ID)
.build()
;
}
}

View file

@ -0,0 +1,95 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.module.derived;
import static net.forwardfire.unitxc.config.builder.UnitXCNumberTypeSetting.toSuperScript;
import net.forwardfire.unitxc.config.UnitXCConfigModule;
import net.forwardfire.unitxc.config.builder.UnitXCConfigBuilder;
import net.forwardfire.unitxc.module.UnitXCModuleMetre;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 26, 2015
*/
public class UnitXCModuleSquareMetre implements UnitXCConfigModule {
private static final int UNIT_COMPOUND_EXPONENT = 2;
private static final String UNIT_ID_POSTFIX = toSuperScript(UNIT_COMPOUND_EXPONENT);
private static final String UNIT_NAME_PREFIX = "square ";
public static final String GROUP_ID = "square_metre";
public static final String GROUP_BASE_TYPE_ID = UnitXCModuleMetre.GROUP_BASE_TYPE_ID+UNIT_ID_POSTFIX;
private static final String[] GROUP_QUANTITIES = {"area"};
public static final String TYPE_CENTIARE_ALIAS = "";
public static final String TYPE_CENTIARE_ID = "ca";
public static final String TYPE_CENTIARE_NAME = "centiare";
public static final String TYPE_CENTIARE_URL = "https://en.wikipedia.org/wiki/Hectare#Centiare";
public static final String TYPE_ARE_ALIAS = "dam²";
public static final String TYPE_ARE_ID = "a";
public static final String TYPE_ARE_NAME = "are";
public static final String TYPE_ARE_URL = "https://en.wikipedia.org/wiki/Hectare#Are";
public static final String TYPE_HECTARE_ALIAS = "hm²";
public static final String TYPE_HECTARE_ID = "ha";
public static final String TYPE_HECTARE_NAME = "hectare";
public static final String TYPE_HECTARE_URL = "https://en.wikipedia.org/wiki/Hectare";
@Override
public void configModule(UnitXCConfigBuilder builder) {
builder.createUnitGroupCompoundExponent(GROUP_ID, UnitXCModuleMetre.GROUP_ID, UNIT_COMPOUND_EXPONENT)
.addQuantityIds(GROUP_QUANTITIES)
.setBaseTypeId( GROUP_BASE_TYPE_ID)
.setUnitIdPostfix(UNIT_ID_POSTFIX)
.setUnitNamePrefix(UNIT_NAME_PREFIX)
.createUnitType()
.setAliasOfType( TYPE_CENTIARE_ALIAS)
.setId( TYPE_CENTIARE_ID)
.setName( TYPE_CENTIARE_NAME)
.setWebLink( TYPE_CENTIARE_URL)
.build()
.createUnitType()
.setAliasOfType( TYPE_ARE_ALIAS)
.setId( TYPE_ARE_ID)
.setName( TYPE_ARE_NAME)
.setWebLink( TYPE_ARE_URL)
.build()
.createUnitType()
.setAliasOfType( TYPE_HECTARE_ALIAS)
.setId( TYPE_HECTARE_ID)
.setName( TYPE_HECTARE_NAME)
.setWebLink( TYPE_HECTARE_URL)
.build()
.build()
;
}
}

View file

@ -0,0 +1,28 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.module.derived;

View file

@ -0,0 +1,63 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.module.named;
import net.forwardfire.unitxc.config.UnitXCConfigModule;
import net.forwardfire.unitxc.config.builder.UnitXCConfigBuilder;
import net.forwardfire.unitxc.model.UnitXCGroupCompoundPair;
import net.forwardfire.unitxc.module.UnitXCModuleKilogram;
import net.forwardfire.unitxc.module.derived.UnitXCModuleMetrePerSecondSquared;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 12, 2016
*/
public class UnitXCModuleNewton implements UnitXCConfigModule {
public static final String GROUP_ID = "newton";
public static final String GROUP_BASE_TYPE_ID = "N";
private static final String GROUP_BASE_TYPE_ID_ALIAS = "kg"+UnitXCGroupCompoundPair.PER_ID+UnitXCModuleMetrePerSecondSquared.GROUP_BASE_TYPE_ID;
private static final String[] GROUP_QUANTITIES = {"force","weight"};
// TODO: symbol N + fix builder
@Override
public void configModule(UnitXCConfigBuilder builder) {
builder.createUnitGroupCompoundPair(GROUP_ID, UnitXCModuleKilogram.GROUP_ID, UnitXCModuleMetrePerSecondSquared.GROUP_ID)
.addQuantityIds(GROUP_QUANTITIES)
.setBaseTypeId(GROUP_BASE_TYPE_ID)
.createUnitType()
.setId(GROUP_BASE_TYPE_ID)
.setName(GROUP_ID)
.setAliasOfType(GROUP_BASE_TYPE_ID_ALIAS)
.build()
.build();
}
}

View file

@ -0,0 +1,28 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.module.named;

View file

@ -0,0 +1,28 @@
/*
* Copyright ©Δ 仙上主天
* 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.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE 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.module;

View file

@ -0,0 +1,122 @@
group.mole.name = mole
group.mole.description = The mole is the amount of substance of a system which contains as many elementary entities as there are atoms in 0.012 kilogram of carbon 12.
group.mole.quantity.amount_of_substance.name = amount of substance
group.mole.quantity.amount_of_substance.wikiLink = Amount_of_substance
group.second.name = second
group.second.description = The second is the duration of 9192631770 periods of the radiation corresponding to the transition between the two hyperfine levels of the ground state of the caesium 133 atom.
group.second.quantity.time.name = time
group.second.quantity.time.wikiLink = Time
group.kelvin.name = kelvin
group.kelvin.description = The kelvin, unit of thermodynamic temperature, is the fraction 1/273.16 of the thermodynamic temperature of the triple point of water.
group.kelvin.quantity.thermodynamic_temperature.name = thermodynamic temperature
group.kelvin.quantity.thermodynamic_temperature.wikiLink = Thermodynamic_temperature
group.candela.name = candela
group.candela.description = The candela is the luminous intensity, in a given direction, of a source that emits monochromatic radiation of frequency 540×1012 hertz and that has a radiant intensity in that direction of 1/683 watt per steradian.
group.candela.quantity.luminous_intensity.name = luminous intensity
group.candela.quantity.luminous_intensity.wikiLink = Luminous_intensity
group.ampere.name = ampere
group.ampere.description = The ampere is a measure of the amount of electric charge passing a point in an electric circuit per unit time, with 6.241×1018 electrons (or one coulomb) per second constituting one ampere.
group.ampere.quantity.electric_current.name = electric current
group.ampere.quantity.electric_current.wikiLink = Electric_current
group.kilogram.name = kilogram
group.kilogram.description = The kilogram is the unit of mass; it is equal to the mass of the international prototype of the kilogram.
group.kilogram.quantity.mass.name = mass
group.kilogram.quantity.mass.wikiLink = Mass
group.metre.name = metre
group.metre.description = The metre is the length of the path travelled by light in vacuum during a time interval of 1/299792458 of a second.
group.metre.quantity.length.name = length
group.metre.quantity.length.wikiLink = Length
group.metre_per_second.name = metre per second
group.metre_per_second.description = Speed is the dimensions of a length divided by a time.
group.metre_per_second.quantity.speed.name = speed
group.metre_per_second.quantity.speed.wikiLink = Speed
group.metre_per_second.quantity.velocity.name = velocity
group.metre_per_second.quantity.velocity.wikiLink = Velocity
group.cubic_metre.name = cubic metre
group.cubic_metre.description = It is the volume of a cube with edges one metre in length.
group.cubic_metre.quantity.volume.name = volume
group.cubic_metre.quantity.volume.wikiLink = Volume
group.cubic_metre_per_second.name = cubic metre per second
group.cubic_metre_per_second.description = Volumetric flow is the volume of fluid which passes per unit time.
group.cubic_metre_per_second.quantity.volumetric_flow.name = volumetric flow
group.cubic_metre_per_second.quantity.volumetric_flow.wikiLink = Volumetric_flow
group.metre_per_second_squared.name = metre per second squared
group.metre_per_second_squared.description = Acceleration, is the rate of change of velocity of an object with respect to time.
group.metre_per_second_squared.acceleration.volumetric_flow.name = acceleration
group.metre_per_second_squared.acceleration.volumetric_flow.wikiLink = Acceleration
group.metre_per_second_cubed.name = metre per second cubed
group.metre_per_second_cubed.description = Jerk, also known as jolt, surge, or lurch, is the rate of change of acceleration, with respect to time.
group.metre_per_second_cubed.quantity.jerk.name = jerk
group.metre_per_second_cubed.quantity.jerk.wikiLink = Jerk_(physics)
group.metre_per_second_cubed.quantity.jolt.name = jolt
group.metre_per_second_cubed.quantity.surge.name = surge
group.metre_per_second_cubed.quantity.lurch.name = lurch
group.metre_per_quartic_second.name = metre per quartic second
group.metre_per_quartic_second.description = Is the fourth derivative of the position vector with respect to time or the rate of change of the jerk with respect to time.
group.metre_per_quartic_second.quantity.jounce.name = jounce
group.metre_per_quartic_second.quantity.jounce.wikiLink = Jounce
group.metre_per_quartic_second.quantity.snap.name = snap
group.kilogram_per_square_metre.name = kilogram per square metre
group.kilogram_per_square_metre.description = Area density is of a two-dimensional object is calculated as the mass per unit area.
group.kilogram_per_square_metre.quantity.area_density.name = area_density
group.kilogram_per_square_metre.quantity.area_density.wikiLink = Area_density
group.kilogram_per_cubic_metre.name = kilogram per cubic metre
group.kilogram_per_cubic_metre.description = The volumetric mass density, of a substance is its mass per unit volume.
group.kilogram_per_cubic_metre.quantity.density.name = density
group.kilogram_per_cubic_metre.quantity.density.wikiLink = Density
group.kilogram_per_cubic_metre.quantity.mass_density.name = mass_density
group.mole_per_cubic_metre.name = mole per cubic metre
group.mole_per_cubic_metre.description = Molar concentration is a measure of the concentration of a solute in a solution.
group.mole_per_cubic_metre.quantity.molarity.name = molarity
group.mole_per_cubic_metre.quantity.molarity.wikiLink = Molarity
group.cubic_metre_per_mole.name = cubic metre per mole
group.cubic_metre_per_mole.description = Molar volume is the volume occupied by one mole of a substance.
group.cubic_metre_per_mole.quantity.molar_volume.name = molar volume
group.cubic_metre_per_mole.quantity.molar_volume.wikiLink = Molar_volume
group.newton_per_second.name = newton per second
group.newton_per_second.description = Newton per second.
group.newton_per_second.quantity.yank.name = yank
group.cubic_metre_per_kilogram.name = cubic metre per kilogram
group.cubic_metre_per_kilogram.description = In thermodynamics, the specific volume of a substance is the ratio of the substance's volume to its mass.
group.cubic_metre_per_kilogram.quantity.specific_volume.name = specific volume
group.cubic_metre_per_kilogram.quantity.specific_volume.wikiLink = Specific_volume
group.square_metre.name = square metre
group.square_metre.description = It is defined as the area of a square whose sides measure exactly one metre. The square metre is derived from the SI base unit of the metre,
group.square_metre.quantity.area.name = area
group.square_metre.quantity.area.wikiLink = Area
group.newton.name = newton
group.newton.description = One newton is the force needed to accelerate one kilogram of mass at the rate of one metre per second squared in direction of the applied force.
group.newton.quantity.force.name = force
group.newton.quantity.force.wikiLink = Force
group.newton.quantity.weight.name = weigth
group.newton.quantity.weight.wikiLink = Weight
# type.mol.wikiLink = ${general.wiki.base.url}/Mole_(unit)
# type.mol.name = Mole

Some files were not shown because too many files have changed in this diff Show more