-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
188 additions
and
74 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
api/src/main/java/com/github/skjolber/packing/api/ContainerConstraint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.github.skjolber.packing.api; | ||
|
||
import com.github.skjolber.packing.api.packager.LoadableFilterBuilder; | ||
|
||
/** | ||
* | ||
* Interface for handling which Stackables, or combinations of Stackables go into a Container. | ||
* | ||
*/ | ||
|
||
public interface ContainerConstraint { | ||
|
||
LoadableFilterBuilder<?> newLoadableFilterBuilder(); | ||
|
||
} |
7 changes: 0 additions & 7 deletions
7
api/src/main/java/com/github/skjolber/packing/api/ContainerLoadConstraint.java
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
api/src/main/java/com/github/skjolber/packing/api/GravitySupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.github.skjolber.packing.api; | ||
|
||
public interface GravitySupport { | ||
|
||
void update(StackPlacement stackPlacement); | ||
} |
37 changes: 37 additions & 0 deletions
37
api/src/main/java/com/github/skjolber/packing/api/GravitySupportBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.github.skjolber.packing.api; | ||
|
||
/** | ||
* Builder scaffold. | ||
* | ||
* @see <a href= | ||
* "https://www.sitepoint.com/self-types-with-javas-generics/">https://www.sitepoint.com/self-types-with-javas-generics/</a> | ||
*/ | ||
|
||
@SuppressWarnings("unchecked") | ||
public abstract class GravitySupportBuilder<B extends GravitySupportBuilder<B>> { | ||
|
||
protected Container container; | ||
protected ContainerStackValue stackValue; | ||
protected Stack stack; | ||
protected StackPlacement stackPlacement; | ||
|
||
public B withContainer(Container container) { | ||
this.container = container; | ||
return (B)this; | ||
} | ||
|
||
public B withStack(Stack stack) { | ||
this.stack = stack; | ||
return (B)this; | ||
} | ||
|
||
public B withStackValue(ContainerStackValue stackValue) { | ||
this.stackValue = stackValue; | ||
return (B)this; | ||
} | ||
|
||
public abstract GravitySupport build(); | ||
|
||
|
||
|
||
} |
7 changes: 7 additions & 0 deletions
7
api/src/main/java/com/github/skjolber/packing/api/StackValueConstraint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.github.skjolber.packing.api; | ||
|
||
public interface StackValueConstraint { | ||
|
||
GravitySupportBuilder<?> newGravitySupportBuilder(); | ||
|
||
} |
15 changes: 0 additions & 15 deletions
15
api/src/main/java/com/github/skjolber/packing/api/StackableLoadConstraint.java
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...pi/packager/DefaultLoadableItemScope.java → ...i/packager/DefaultLoadableItemFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
api/src/main/java/com/github/skjolber/packing/api/packager/Loadable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.github.skjolber.packing.api.packager; | ||
|
||
import java.util.List; | ||
|
||
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 Loadable { | ||
|
||
protected final List<StackValue> values; | ||
protected final Stackable stackable; | ||
|
||
protected final long minVolumeLimit; | ||
protected final long minAreaLimit; | ||
|
||
public Loadable(Stackable stackable, List<StackValue> stackValues, int count) { | ||
this.values = stackValues; | ||
this.stackable = stackable; | ||
|
||
long minVolumeLimit = Long.MAX_VALUE; | ||
long minAreaLimit = Long.MAX_VALUE; | ||
|
||
for (int i = 0; i < values.size(); i++) { | ||
StackValue stackValue = values.get(i); | ||
|
||
if(minVolumeLimit > stackValue.getVolume()) { | ||
minVolumeLimit = stackValue.getVolume(); | ||
} | ||
|
||
if(minAreaLimit > stackValue.getArea()) { | ||
minAreaLimit = stackValue.getArea(); | ||
} | ||
} | ||
|
||
this.minAreaLimit = minAreaLimit; | ||
this.minVolumeLimit = minVolumeLimit; | ||
} | ||
|
||
public List<StackValue> getValues() { | ||
return values; | ||
} | ||
|
||
public long getMinAreaLimit() { | ||
return minAreaLimit; | ||
} | ||
|
||
public long getMinVolumeLimit() { | ||
return minVolumeLimit; | ||
} | ||
|
||
public Stackable getStackable() { | ||
return stackable; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
api/src/main/java/com/github/skjolber/packing/api/packager/LoadableFilterBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.github.skjolber.packing.api.packager; | ||
|
||
import java.util.List; | ||
|
||
import com.github.skjolber.packing.api.Container; | ||
import com.github.skjolber.packing.api.ContainerStackValue; | ||
import com.github.skjolber.packing.api.Stack; | ||
|
||
/** | ||
* Builder scaffold. | ||
* | ||
* @see <a href= | ||
* "https://www.sitepoint.com/self-types-with-javas-generics/">https://www.sitepoint.com/self-types-with-javas-generics/</a> | ||
*/ | ||
|
||
@SuppressWarnings("unchecked") | ||
public abstract class LoadableFilterBuilder<B extends LoadableFilterBuilder<B>> { | ||
|
||
protected Stack stack; | ||
protected Container container; | ||
protected ContainerStackValue stackValue; | ||
protected List<LoadableItem> loadableItems; | ||
|
||
public B withLoadableItems(List<LoadableItem> loadableItems) { | ||
this.loadableItems = loadableItems; | ||
return (B)this; | ||
} | ||
|
||
public B withContainer(Container container) { | ||
this.container = container; | ||
return (B)this; | ||
} | ||
|
||
public B withStack(Stack stack) { | ||
this.stack = stack; | ||
return (B)this; | ||
} | ||
|
||
public B withStackValue(ContainerStackValue stackValue) { | ||
this.stackValue = stackValue; | ||
return (B)this; | ||
} | ||
|
||
public abstract LoadableItemFilter build(); | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters