Skip to content

Commit

Permalink
Remove generics (#911)
Browse files Browse the repository at this point in the history
* Add some support

* Remove generics, various prototypes

* Remove unused stuff

* Remove unused stuff
  • Loading branch information
skjolber authored Aug 16, 2024
1 parent b6625e9 commit 1409bfa
Show file tree
Hide file tree
Showing 89 changed files with 1,472 additions and 2,706 deletions.
8 changes: 8 additions & 0 deletions api/src/main/java/com/github/skjolber/packing/api/Box.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ public Box(String id, String name, long volume, int weight, BoxStackValue[] stac

this.minimumArea = getMinimumArea(stackValues);
this.maximumArea = getMinimumArea(stackValues);

for (BoxStackValue boxStackValue : stackValues) {
boxStackValue.setStackable(this);
}
}

@Override
Expand All @@ -78,6 +82,10 @@ public long getVolume() {

@Override
public Box clone() {
BoxStackValue[] stackValues = new BoxStackValue[this.stackValues.length];
for(int i = 0; i < stackValues.length; i++) {
stackValues[i] = this.stackValues[i].clone();
}
return new Box(id, description, volume, weight, stackValues);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,31 @@
public class BoxStackValue extends StackValue {

private static final long serialVersionUID = 1L;

private Box stackable;

public BoxStackValue(int dx, int dy, int dz, StackConstraint constraint, List<Surface> surfaces) {
super(dx, dy, dz, constraint, surfaces);
}

public BoxStackValue(BoxStackValue boxStackValue) {
super(boxStackValue);

this.stackable = boxStackValue.stackable;
}

@Override
public BoxStackValue clone() {
return new BoxStackValue(this);
}

public void setStackable(Box stackable) {
this.stackable = stackable;
}

@Override
public Box getStackable() {
return stackable;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ public abstract class ContainerStackValue extends StackValue {

private static final long serialVersionUID = 1L;

private Container stackable;

protected final int loadDx; // x
protected final int loadDy; // y
protected final int loadDz; // z

protected final int maxLoadWeight;
protected final long maxLoadVolume;

public ContainerStackValue(
int dx, int dy, int dz,
StackConstraint constraint,
Expand All @@ -19,14 +28,7 @@ public ContainerStackValue(
this.maxLoadVolume = (long)loadDx * (long)loadDy * (long)loadDz;
this.maxLoadWeight = maxLoadWeight;
}

protected final int loadDx; // x
protected final int loadDy; // y
protected final int loadDz; // z

protected final int maxLoadWeight;
protected final long maxLoadVolume;


protected ContainerStackValue(ContainerStackValue other) {
super(other);

Expand All @@ -36,6 +38,8 @@ protected ContainerStackValue(ContainerStackValue other) {

this.maxLoadVolume = other.maxLoadVolume;
this.maxLoadWeight = other.maxLoadWeight;

this.stackable = other.stackable;
}

public long getMaxLoadVolume() {
Expand Down Expand Up @@ -78,5 +82,17 @@ protected boolean canLoad(Stackable stackable) {
public String toString() {
return "ContainerStackValue [" + dx + "x" + dy + "x" + dz + " " + loadDx + "x" + loadDy + "x" + loadDz + "]";
}

public void setStackable(Container stackable) {
this.stackable = stackable;
}

@Override
public Container getStackable() {
return stackable;
}

@Override
public abstract ContainerStackValue clone();

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public DefaultContainer(String id, String description, long volume, int emptyWei

this.stackValues = stackValues;
this.stack = stack;

for (ContainerStackValue stackValue : stackValues) {
stackValue.setStackable(this);
}
}

@Override
Expand All @@ -28,6 +32,10 @@ public Stack getStack() {

@Override
public DefaultContainer clone() {
ContainerStackValue[] stackValues = new ContainerStackValue[this.stackValues.length];
for(int i = 0; i < stackValues.length; i++) {
stackValues[i] = this.stackValues[i].clone();
}
return new DefaultContainer(id, description, volume, emptyWeight, stackValues, new DefaultStack());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class DefaultContainerStackValue extends ContainerStackValue {

private static final long serialVersionUID = 1L;

public DefaultContainerStackValue(
int dx, int dy, int dz,
StackConstraint constraint,
Expand Down
14 changes: 0 additions & 14 deletions api/src/main/java/com/github/skjolber/packing/api/Placement2D.java

This file was deleted.

11 changes: 0 additions & 11 deletions api/src/main/java/com/github/skjolber/packing/api/Placement3D.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.io.Serializable;

public class StackPlacement implements Placement3D, Serializable {
public class StackPlacement implements Serializable {

private static final long serialVersionUID = 1L;

Expand Down Expand Up @@ -109,19 +109,18 @@ public long getVolume() {
return stackable.getVolume();
}

public boolean intersects2D(Placement2D point) {
public boolean intersects2D(StackPlacement point) {
return !(point.getAbsoluteEndX() < x || point.getAbsoluteX() > getAbsoluteEndX() || point.getAbsoluteEndY() < y || point.getAbsoluteY() > getAbsoluteEndY());
}

@Override
public boolean intersects3D(Placement3D point) {
public boolean intersects3D(StackPlacement point) {
return !(point.getAbsoluteEndX() < x || point.getAbsoluteX() > getAbsoluteEndX() || point.getAbsoluteEndY() < y || point.getAbsoluteY() > point.getAbsoluteEndY() || point.getAbsoluteEndZ() < z
|| point.getAbsoluteZ() > point.getAbsoluteEndZ());
}

@Override
public String toString() {
return stackable.getDescription() + "[" + x + "x" + y + "x" + z + " " + getAbsoluteEndX() + "x" + getAbsoluteEndY() + "x" + getAbsoluteEndZ() + "]";
return (stackable != null ? stackable.getDescription() : "") + "[" + x + "x" + y + "x" + z + " " + getAbsoluteEndX() + "x" + getAbsoluteEndY() + "x" + getAbsoluteEndZ() + "]";
}

public void setX(int x) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public abstract class StackValue implements Serializable {

protected final List<Surface> surfaces;
protected long volume;

public StackValue(int dx, int dy, int dz, StackConstraint constraint, List<Surface> surfaces) {
this.dx = dx;
this.dy = dy;
Expand Down Expand Up @@ -101,5 +101,7 @@ public String toString() {

@Override
public abstract StackValue clone();

public abstract Stackable getStackable();

}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
package com.github.skjolber.packing.api.ep;

import java.io.Serializable;
import java.util.List;

import com.github.skjolber.packing.api.Placement2D;
import com.github.skjolber.packing.api.StackPlacement;

public interface ExtremePoints<P extends Placement2D & Serializable, Point extends Point2D<P>> {
public interface ExtremePoints {

boolean add(int index, P placement);
boolean add(int index, StackPlacement placement);

Point getValue(int i);
Point3D getValue(int i);

List<Point> getValues();
List<Point3D> getValues();

int getValueCount();

void reset(int dx, int dy, int dz);

void redo();

List<StackPlacement> getPlacements();
}
Loading

0 comments on commit 1409bfa

Please sign in to comment.