Skip to content

Commit

Permalink
More refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
skjolber committed Sep 12, 2024
1 parent 9102523 commit 604560c
Show file tree
Hide file tree
Showing 23 changed files with 218 additions and 305 deletions.
19 changes: 17 additions & 2 deletions api/src/main/java/com/github/skjolber/packing/api/Box.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@ protected BoxStackValue newStackValue(int dx, int dy, int dz, StackConstraint co
protected final long minimumArea;
protected final long maximumArea;

public Box(String id, String name, long volume, int weight, BoxStackValue[] stackValues) {
super(id, name);
protected final String id;
protected final String description;

public Box(String id, String description, long volume, int weight, BoxStackValue[] stackValues) {
this.id = id;
this.description = description;

this.volume = volume;
this.weight = weight;
this.stackValues = stackValues;
Expand All @@ -65,6 +70,16 @@ public Box(String id, String name, long volume, int weight, BoxStackValue[] stac
boxStackValue.setStackable(this);
}
}

@Override
public String getDescription() {
return description;
}

@Override
public String getId() {
return id;
}

@Override
public int getWeight() {
Expand Down
18 changes: 16 additions & 2 deletions api/src/main/java/com/github/skjolber/packing/api/Container.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,13 @@ protected ContainerStackValue[] getStackValues() {
protected final long minArea;
protected final long maxArea;

public Container(String id, String name, long volume, int emptyWeight, long maxLoadVolume, int maxLoadWeight, long minArea, long maxArea) {
super(id, name);
protected final String id;
protected final String description;

public Container(String id, String description, long volume, int emptyWeight, long maxLoadVolume, int maxLoadWeight, long minArea, long maxArea) {
this.id = id;
this.description = description;

this.emptyWeight = emptyWeight;
this.maxLoadVolume = maxLoadVolume;
this.maxLoadWeight = maxLoadWeight;
Expand All @@ -159,6 +163,16 @@ public Container(String id, String name, long volume, int emptyWeight, long maxL
this.maxArea = maxArea;
}

@Override
public String getDescription() {
return description;
}

@Override
public String getId() {
return id;
}

@Override
public int getWeight() {
return emptyWeight + getStack().getWeight();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.skjolber.packing.api;

import com.github.skjolber.packing.api.packager.LoadableItemFilterBuilder;
import com.github.skjolber.packing.api.packager.StackableItemsFilterBuilder;

/**
*
Expand All @@ -10,6 +10,6 @@

public interface ContainerConstraint {

LoadableItemFilterBuilder<?> newLoadableFilterBuilder();
StackableItemsFilterBuilder<?> newLoadableFilterBuilder();

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public abstract class PlacementSupportBuilder<B extends PlacementSupportBuilder<
protected Container container;
protected ContainerStackValue stackValue;
protected Stack stack;
protected StackPlacement stackPlacement;

public B withContainer(Container container) {
this.container = container;
Expand Down
17 changes: 2 additions & 15 deletions api/src/main/java/com/github/skjolber/packing/api/Stackable.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,15 @@ public abstract class Stackable implements Serializable {

private static final long serialVersionUID = 1L;

protected final String id;
protected final String description;

public Stackable(String id, String description) {
super();
this.id = id;
this.description = description;
}

public abstract long getVolume();

public abstract int getWeight();

public abstract StackValue[] getStackValues();

public String getDescription() {
return description;
}
public abstract String getDescription();

public String getId() {
return id;
}
public abstract String getId();

public List<StackValue> fitsInside(Dimension bound) {
List<StackValue> list = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.github.skjolber.packing.api.packager;

import com.github.skjolber.packing.api.StackValue;
import com.github.skjolber.packing.api.Stackable;

/**
*
* Stackable item which fit within certain bounds, i.e. load dimensions of a container.
*
*/

public class BoundedStackable extends Stackable {

private static final long serialVersionUID = 1L;

protected final StackValue[] values;
protected final Stackable stackable;

protected final long minimumArea;
protected final long maximumArea;

public BoundedStackable(Stackable stackable, StackValue[] stackValues) {
this.values = stackValues;
this.stackable = stackable;

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

public Stackable getStackable() {
return stackable;
}

public StackValue getStackValue(int index) {
return values[index];
}

@Override
public long getVolume() {
return stackable.getVolume();
}

@Override
public int getWeight() {
return stackable.getWeight();
}

@Override
public StackValue[] getStackValues() {
return values;
}

@Override
public String getDescription() {
return stackable.getDescription();
}

@Override
public String getId() {
return stackable.getId();
}

@Override
public Stackable clone() {
return new BoundedStackable(stackable.clone(), values);
}

@Override
public long getMinimumArea() {
return minimumArea;
}

@Override
public long getMaximumArea() {
return maximumArea;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.github.skjolber.packing.api.packager;

public class DefaultStackableItemsFilter implements StackableItemsFilter {

protected final StackableItems loadableItems;

public DefaultStackableItemsFilter(StackableItems loadableItems) {
this.loadableItems = loadableItems;
}

@Override
public void loaded(int index) {
// do nothing
}

}

This file was deleted.

This file was deleted.

Loading

0 comments on commit 604560c

Please sign in to comment.