Skip to content

Commit

Permalink
Add copy implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
XyperCode committed Oct 22, 2023
1 parent a4c24fa commit b81e5f9
Show file tree
Hide file tree
Showing 23 changed files with 108 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
project_version=1.0.0
project_version=1.1.0
5 changes: 5 additions & 0 deletions src/main/java/com/ultreon/data/types/BigDecType.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,9 @@ public boolean equals(Object other) {
public int hashCode() {
return Objects.hash(obj);
}

@Override
public BigDecType copy() {
return new BigDecType(obj);
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/ultreon/data/types/BigIntType.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,9 @@ public boolean equals(Object other) {
public int hashCode() {
return Objects.hash(obj);
}

@Override
public BigIntType copy() {
return new BigIntType(obj);
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/ultreon/data/types/BooleanType.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ public boolean equals(Object other) {
public int hashCode() {
return Objects.hash(obj);
}

@Override
public BooleanType copy() {
return new BooleanType(obj);
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/ultreon/data/types/ByteArrayType.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,9 @@ public boolean equals(Object other) {
public int hashCode() {
return Arrays.hashCode(obj);
}

@Override
public ByteArrayType copy() {
return new ByteArrayType(obj.clone());
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/ultreon/data/types/ByteType.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ public boolean equals(Object other) {
public int hashCode() {
return Objects.hash(obj);
}

@Override
public ByteType copy() {
return new ByteType(obj);
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/ultreon/data/types/CharType.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ public boolean equals(Object other) {
public int hashCode() {
return Objects.hash(obj);
}

@Override
public CharType copy() {
return new CharType(obj);
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/ultreon/data/types/DoubleArrayType.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,9 @@ public boolean equals(Object other) {
public int hashCode() {
return Arrays.hashCode(obj);
}

@Override
public DoubleArrayType copy() {
return new DoubleArrayType(obj.clone());
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/ultreon/data/types/DoubleType.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ public boolean equals(Object other) {
public int hashCode() {
return Objects.hash(obj);
}

@Override
public DoubleType copy() {
return new DoubleType(obj);
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/ultreon/data/types/FloatArrayType.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,9 @@ public boolean equals(Object other) {
public int hashCode() {
return Arrays.hashCode(obj);
}

@Override
public FloatArrayType copy() {
return new FloatArrayType(obj.clone());
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/ultreon/data/types/FloatType.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ public boolean equals(Object other) {
public int hashCode() {
return Objects.hash(obj);
}

@Override
public FloatType copy() {
return new FloatType(obj);
}
}
2 changes: 2 additions & 0 deletions src/main/java/com/ultreon/data/types/IType.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ public interface IType<T> {
boolean equals(Object other);

int hashCode();

IType<T> copy();
}
5 changes: 5 additions & 0 deletions src/main/java/com/ultreon/data/types/IntArrayType.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,9 @@ public boolean equals(Object other) {
public int hashCode() {
return Arrays.hashCode(obj);
}

@Override
public IntArrayType copy() {
return new IntArrayType(obj.clone());
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/ultreon/data/types/IntType.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ public boolean equals(Object other) {
public int hashCode() {
return Objects.hash(obj);
}

@Override
public IntType copy() {
return new IntType(obj);
}
}
7 changes: 7 additions & 0 deletions src/main/java/com/ultreon/data/types/ListType.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

public class ListType<T extends IType<?>> implements IType<List<T>>, Iterable<T> {
private final int id;
Expand Down Expand Up @@ -157,4 +158,10 @@ public boolean equals(Object other) {
public int hashCode() {
return Objects.hash(id, obj);
}

@Override
@SuppressWarnings("unchecked")
public ListType<T> copy() {
return new ListType<T>(obj.stream().map(t -> (T) t.copy()).collect(Collectors.toList()));
}
}
6 changes: 6 additions & 0 deletions src/main/java/com/ultreon/data/types/LongArrayType.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.util.Arrays;
import java.util.stream.Collectors;

public class LongArrayType implements IType<long[]> {
private long[] obj;
Expand Down Expand Up @@ -59,4 +60,9 @@ public boolean equals(Object other) {
public int hashCode() {
return Arrays.hashCode(obj);
}

@Override
public LongArrayType copy() {
return new LongArrayType(obj.clone());
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/ultreon/data/types/LongType.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ public boolean equals(Object other) {
public int hashCode() {
return Objects.hash(obj);
}

@Override
public LongType copy() {
return new LongType(obj);
}
}
6 changes: 6 additions & 0 deletions src/main/java/com/ultreon/data/types/MapType.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Collectors;

public class MapType implements IType<Map<String, IType<?>>> {
private Map<String, IType<?>> obj;
Expand Down Expand Up @@ -446,4 +447,9 @@ public boolean equals(Object other) {
public int hashCode() {
return Objects.hash(obj);
}

@Override
public MapType copy() {
return new MapType(obj.entrySet().stream().collect(Collectors.toMap(Entry::getKey, entry -> entry.getValue().copy(), (a, b) -> b)));
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/ultreon/data/types/ShortArrayType.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,9 @@ public boolean equals(Object other) {
public int hashCode() {
return Arrays.hashCode(obj);
}

@Override
public ShortArrayType copy() {
return new ShortArrayType(obj.clone());
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/ultreon/data/types/ShortType.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ public boolean equals(Object other) {
public int hashCode() {
return Objects.hash(obj);
}

@Override
public ShortType copy() {
return new ShortType(obj);
}
}
5 changes: 4 additions & 1 deletion src/main/java/com/ultreon/data/types/StringType.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,8 @@ public static StringType read(DataInputStream stream) throws IOException {
return new StringType(new String(bytes, StandardCharsets.UTF_8));
}


@Override
public StringType copy() {
return new StringType(obj);
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/ultreon/data/types/UUIDType.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,9 @@ public boolean equals(Object other) {
public int hashCode() {
return Objects.hash(obj);
}

@Override
public UUIDType copy() {
return new UUIDType(new UUID(obj.getMostSignificantBits(), obj.getLeastSignificantBits()));
}
}

0 comments on commit b81e5f9

Please sign in to comment.