Calculator++ core module
This commit is contained in:
36
calculatorpp-core/pom.xml
Normal file
36
calculatorpp-core/pom.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.solovyev.android</groupId>
|
||||
<artifactId>calculatorpp-parent</artifactId>
|
||||
<version>1.3.1</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.solovyev.android</groupId>
|
||||
<artifactId>calculatorpp-core</artifactId>
|
||||
<version>1.3.1</version>
|
||||
<name>Calculator++ Application Core</name>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.intellij</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
@@ -0,0 +1,17 @@
|
||||
package org.solovyev.math.units;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 4/21/12
|
||||
* Time: 7:54 PM
|
||||
*/
|
||||
public interface Unit<V> {
|
||||
|
||||
@NotNull
|
||||
V getValue();
|
||||
|
||||
@NotNull
|
||||
UnitType<V> getUnitType();
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
package org.solovyev.math.units;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 4/21/12
|
||||
* Time: 7:53 PM
|
||||
*/
|
||||
public interface UnitConverter<T> {
|
||||
|
||||
boolean isSupported(@NotNull UnitType<?> from, @NotNull UnitType<T> to);
|
||||
|
||||
@NotNull
|
||||
Unit<T> convert(@NotNull Unit<?> from, @NotNull UnitType<T> toType);
|
||||
|
||||
public static class Dummy implements UnitConverter<Object> {
|
||||
|
||||
@NotNull
|
||||
private static final Dummy instance = new Dummy();
|
||||
|
||||
@NotNull
|
||||
public static <T> UnitConverter<T> getInstance() {
|
||||
return (UnitConverter<T>)instance;
|
||||
}
|
||||
|
||||
private Dummy() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSupported(@NotNull UnitType<?> from, @NotNull UnitType<Object> to) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Unit<Object> convert(@NotNull Unit<?> from, @NotNull UnitType<Object> toType) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
package org.solovyev.math.units;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 4/21/12
|
||||
* Time: 8:01 PM
|
||||
*/
|
||||
public class UnitImpl<V> implements Unit<V> {
|
||||
|
||||
@NotNull
|
||||
private V value;
|
||||
|
||||
@NotNull
|
||||
private UnitType<V> unitType;
|
||||
|
||||
private UnitImpl() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <V> Unit<V> newInstance(@NotNull V value, @NotNull UnitType<V> unitType) {
|
||||
final UnitImpl<V> result = new UnitImpl<V>();
|
||||
|
||||
result.value = value;
|
||||
result.unitType = unitType;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public V getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public UnitType<V> getUnitType() {
|
||||
return unitType;
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package org.solovyev.math.units;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 4/21/12
|
||||
* Time: 7:55 PM
|
||||
*/
|
||||
public interface UnitType<V> {
|
||||
|
||||
@NotNull
|
||||
Class<V> getUnitValueClass();
|
||||
|
||||
boolean equals(@NotNull Object o);
|
||||
}
|
Reference in New Issue
Block a user