generics LOL
This commit is contained in:
@@ -17,9 +17,7 @@
|
||||
|
||||
package tenor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ActuallyCraftTask extends TaskLeaf implements ISingularTask {
|
||||
public class ActuallyCraftTask extends SingularTaskLeaf {
|
||||
|
||||
public final CraftingTask parent;
|
||||
|
||||
@@ -35,7 +33,6 @@ public class ActuallyCraftTask extends TaskLeaf implements ISingularTask {
|
||||
|
||||
@Override
|
||||
public double priority() {
|
||||
List<ISingularChildTaskRelationship> parentTasks = (List) parentTasks(); // pog
|
||||
return parentTasks.stream().mapToDouble(ISingularChildTaskRelationship::allocatedPriority).sum();
|
||||
return parentTasks().stream().mapToDouble(ISingularChildTaskRelationship::allocatedPriority).sum();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,6 @@ public class AquireCraftingItems extends QuantizedTaskNode implements ClaimProvi
|
||||
this.parent = parent;
|
||||
this.parentRelationship = createRelationshipToParent(parent);
|
||||
addParent(parentRelationship);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class AquireItemTask extends QuantizedTaskNode implements ClaimProvider, IQuantizedDependentCostCalculator {
|
||||
public class AquireItemTask extends QuantizedTaskNode implements ClaimProvider, IQuantizedDependentCostCalculator<IQuantizedChildTaskRelationship> {
|
||||
|
||||
HashMap<IQuantizedChildTaskRelationship, Integer> allocation; // allocation of what tasks have claim over what items in our inventory i guess
|
||||
|
||||
|
||||
@@ -17,9 +17,7 @@
|
||||
|
||||
package tenor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GetToCraftingTableTask extends TaskLeaf implements ISingularTask {
|
||||
public class GetToCraftingTableTask extends SingularTaskLeaf {
|
||||
public static final GetToCraftingTableTask INSTANCE = new GetToCraftingTableTask(); // ? idk
|
||||
|
||||
@Override
|
||||
@@ -29,7 +27,6 @@ public class GetToCraftingTableTask extends TaskLeaf implements ISingularTask {
|
||||
|
||||
@Override
|
||||
public double priority() {
|
||||
List<ISingularChildTaskRelationship> parentTasks = (List) parentTasks(); // pog
|
||||
return parentTasks.stream().mapToDouble(ISingularChildTaskRelationship::allocatedPriority).sum();
|
||||
return parentTasks().stream().mapToDouble(ISingularChildTaskRelationship::allocatedPriority).sum();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package tenor;
|
||||
|
||||
public interface IQuantizedDependentCostCalculator extends ITaskNodeBase {
|
||||
public interface IQuantizedDependentCostCalculator<T extends ITaskRelationshipBase> extends ITaskNodeBase<T> {
|
||||
default IQuantityRelationship cost() {
|
||||
switch (type()) {
|
||||
case SERIAL:
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package tenor;
|
||||
|
||||
public interface IQuantizedTask extends ITask {
|
||||
public interface IQuantizedTask extends ITask<IQuantizedChildTaskRelationship> {
|
||||
|
||||
/*default QuantityRelationship priority() {
|
||||
return q -> {
|
||||
@@ -33,7 +33,7 @@ public interface IQuantizedTask extends ITask {
|
||||
|
||||
IQuantityRelationship cost();
|
||||
|
||||
default IQuantizedChildTaskRelationship<? extends ITaskNodeBase> createRelationshipToParent(ITaskNodeBase parent) {
|
||||
default IQuantizedChildTaskRelationship createRelationshipToParent(ITaskNodeBase parent) {
|
||||
if (parent instanceof IQuantizedTask) {
|
||||
return new QuantizedToQuantizedTaskRelationship((QuantizedTaskNode) parent, this, parent.type());
|
||||
} else {
|
||||
|
||||
@@ -21,6 +21,6 @@ package tenor;
|
||||
* @author Brady
|
||||
* @since 10/30/2018
|
||||
*/
|
||||
public interface IQuantizedTaskNode extends ITaskNodeBase, IQuantizedTask {
|
||||
public interface IQuantizedTaskNode extends ITaskNodeBase<IQuantizedChildTaskRelationship>, IQuantizedTask {
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package tenor;
|
||||
|
||||
public interface ISingularTask extends ITask {
|
||||
public interface ISingularTask extends ITask<ISingularChildTaskRelationship> {
|
||||
double cost();
|
||||
|
||||
double priority();
|
||||
|
||||
@@ -21,6 +21,6 @@ package tenor;
|
||||
* @author Brady
|
||||
* @since 10/30/2018
|
||||
*/
|
||||
public interface ISingularTaskNode extends ITaskNodeBase, ISingularTask {
|
||||
public interface ISingularTaskNode extends ITaskNodeBase<ISingularChildTaskRelationship>, ISingularTask {
|
||||
double priorityAllocatedToChild(ISingularParentTaskRelationship relationship);
|
||||
}
|
||||
|
||||
@@ -19,13 +19,13 @@ package tenor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ITask {
|
||||
public interface ITask<T extends ITaskRelationshipBase> {
|
||||
|
||||
List<ITaskRelationshipBase> parentTasks();
|
||||
List<T> parentTasks();
|
||||
|
||||
ITaskRelationshipBase createRelationshipToParent(ITaskNodeBase parent);
|
||||
T createRelationshipToParent(ITaskNodeBase parent);
|
||||
|
||||
void addParent(ITaskRelationshipBase relationship);
|
||||
void addParent(T relationship);
|
||||
|
||||
default void addParent(ITaskNodeBase parent) {
|
||||
addParent(createRelationshipToParent(parent));
|
||||
|
||||
@@ -19,7 +19,7 @@ package tenor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ITaskNodeBase extends ITask {
|
||||
public interface ITaskNodeBase<T extends ITaskRelationshipBase> extends ITask<T> {
|
||||
|
||||
List<ITaskRelationshipBase> childTasks();
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package tenor;
|
||||
|
||||
public class MineTask extends TaskLeaf implements IQuantizedTask {
|
||||
public class MineTask extends QuantizedTaskLeaf {
|
||||
@Override
|
||||
public IQuantityRelationship priority() {
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package tenor;
|
||||
|
||||
public abstract class QuantizedTaskLeaf extends TaskLeaf<IQuantizedChildTaskRelationship> implements IQuantizedTask {
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package tenor;
|
||||
|
||||
public abstract class QuantizedTaskNode extends TaskNode implements IQuantizedTask {
|
||||
public abstract class QuantizedTaskNode extends TaskNode<IQuantizedChildTaskRelationship> implements IQuantizedTask {
|
||||
|
||||
public QuantizedTaskNode(DependencyType type) {
|
||||
super(type);
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package tenor;
|
||||
|
||||
public abstract class SingularTaskLeaf extends TaskLeaf<ISingularChildTaskRelationship> implements ISingularTask {
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package tenor;
|
||||
|
||||
public abstract class SingularTaskNode extends TaskNode implements ISingularTaskNode {
|
||||
public abstract class SingularTaskNode extends TaskNode<ISingularChildTaskRelationship> implements ISingularTaskNode {
|
||||
|
||||
public SingularTaskNode(DependencyType type) {
|
||||
super(type);
|
||||
|
||||
@@ -19,17 +19,17 @@ package tenor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Task implements ITask {
|
||||
public abstract class Task<T extends ITaskRelationshipBase> implements ITask<T> {
|
||||
|
||||
List<ITaskRelationshipBase> parentRelationships;
|
||||
List<T> parentRelationships;
|
||||
|
||||
@Override
|
||||
public List<ITaskRelationshipBase> parentTasks() {
|
||||
public List<T> parentTasks() {
|
||||
return parentRelationships;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addParent(ITaskRelationshipBase relationship) {
|
||||
public void addParent(T relationship) {
|
||||
if (relationship.childTask() != this) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
@@ -17,5 +17,5 @@
|
||||
|
||||
package tenor;
|
||||
|
||||
public abstract class TaskLeaf extends Task {
|
||||
public abstract class TaskLeaf<T extends ITaskRelationshipBase> extends Task<T> {
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package tenor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class TaskNode extends Task implements ITaskNodeBase {
|
||||
public abstract class TaskNode<T extends ITaskRelationshipBase> extends Task<T> implements ITaskNodeBase<T> {
|
||||
|
||||
List<ITaskRelationshipBase> childRelationships;
|
||||
public final DependencyType type;
|
||||
|
||||
Reference in New Issue
Block a user