Fixed intterface and abstract class after consultansion
This commit is contained in:
parent
bd653482e5
commit
d3378d37d4
@ -1,22 +1,26 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.node;
|
package cz.cvut.fel.sit.omo.foodchain.node;
|
||||||
|
|
||||||
import cz.cvut.fel.sit.omo.foodchain.channel.IChannel;
|
import cz.cvut.fel.sit.omo.foodchain.channel.IChannel;
|
||||||
import cz.cvut.fel.sit.omo.foodchain.operation.Action;
|
import cz.cvut.fel.sit.omo.foodchain.operation.*;
|
||||||
import cz.cvut.fel.sit.omo.foodchain.operation.Transaction;
|
|
||||||
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
||||||
import cz.cvut.fel.sit.omo.foodchain.product.ProductType;
|
import cz.cvut.fel.sit.omo.foodchain.product.ProductType;
|
||||||
import cz.cvut.fel.sit.omo.foodchain.requirement.Requirement;
|
import cz.cvut.fel.sit.omo.foodchain.requirement.Requirement;
|
||||||
import cz.cvut.fel.sit.omo.foodchain.signature.Signature;
|
import cz.cvut.fel.sit.omo.foodchain.signature.Signature;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface INode {
|
public interface INode {
|
||||||
void sendTransaction(Product product, INode INode);
|
void sendTransaction(Product product, INode node);
|
||||||
|
|
||||||
void receiveTransaction(Transaction transaction);
|
void sendTransaction(MonetaryAmount amount, INode node);
|
||||||
|
|
||||||
void refuseTransaction(Transaction transaction);
|
void receiveTransaction(ProductTransaction transaction);
|
||||||
|
|
||||||
|
void receiveTransaction(FinancialTransaction transaction);
|
||||||
|
|
||||||
|
void refuseTransaction(ProductTransaction transaction);
|
||||||
|
|
||||||
|
void refuseTransaction(FinancialTransaction transaction);
|
||||||
|
|
||||||
Transaction readNextTransaction(IChannel channel);
|
Transaction readNextTransaction(IChannel channel);
|
||||||
|
|
||||||
@ -28,9 +32,9 @@ public interface INode {
|
|||||||
|
|
||||||
void unsubscribeFromChannel(IChannel channel);
|
void unsubscribeFromChannel(IChannel channel);
|
||||||
|
|
||||||
void doAction(Action action, Product product);
|
void doAction(ProductOperationType action, Product product);
|
||||||
|
|
||||||
void doAction(Action action);
|
void doAction(ProductOperationType action);
|
||||||
|
|
||||||
void storeProduct(Product product);
|
void storeProduct(Product product);
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.node;
|
package cz.cvut.fel.sit.omo.foodchain.node;
|
||||||
|
|
||||||
import cz.cvut.fel.sit.omo.foodchain.channel.IChannel;
|
import cz.cvut.fel.sit.omo.foodchain.channel.IChannel;
|
||||||
import cz.cvut.fel.sit.omo.foodchain.operation.Action;
|
import cz.cvut.fel.sit.omo.foodchain.operation.*;
|
||||||
import cz.cvut.fel.sit.omo.foodchain.operation.ProductTransaction;
|
|
||||||
import cz.cvut.fel.sit.omo.foodchain.operation.Transaction;
|
|
||||||
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
||||||
import cz.cvut.fel.sit.omo.foodchain.product.ProductType;
|
import cz.cvut.fel.sit.omo.foodchain.product.ProductType;
|
||||||
import cz.cvut.fel.sit.omo.foodchain.requirement.Requirement;
|
import cz.cvut.fel.sit.omo.foodchain.requirement.Requirement;
|
||||||
@ -14,17 +12,17 @@ import java.util.List;
|
|||||||
|
|
||||||
|
|
||||||
public class NodeBase implements INode {
|
public class NodeBase implements INode {
|
||||||
List<IChannel> subscribedChannels;
|
private final List<IChannel> subscribedChannels;
|
||||||
|
private final List<Product> products;
|
||||||
|
|
||||||
public NodeBase(){
|
public NodeBase(){
|
||||||
subscribedChannels = new LinkedList<>();
|
subscribedChannels = new LinkedList<>();
|
||||||
|
products = new LinkedList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendTransaction(Product product, INode node) {
|
public void sendTransaction(Product product, INode node) {
|
||||||
Transaction transaction = new ProductTransaction();
|
Transaction transaction = new ProductTransaction(product, node);
|
||||||
transaction.setProduct(product);
|
|
||||||
transaction.setGoal(node);
|
|
||||||
|
|
||||||
subscribedChannels.stream()
|
subscribedChannels.stream()
|
||||||
.filter(ch -> ch.getProductType().equals(product.getType()))
|
.filter(ch -> ch.getProductType().equals(product.getType()))
|
||||||
@ -32,15 +30,31 @@ public class NodeBase implements INode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void receiveTransaction(Transaction transaction) {
|
public void sendTransaction(MonetaryAmount amount, INode node) {
|
||||||
//TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refuseTransaction(Transaction transaction) {
|
public void receiveTransaction(ProductTransaction transaction) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void receiveTransaction(FinancialTransaction transaction) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refuseTransaction(ProductTransaction transaction) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refuseTransaction(FinancialTransaction transaction) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Transaction readNextTransaction(IChannel channel) {
|
public Transaction readNextTransaction(IChannel channel) {
|
||||||
return channel.getNextTransaction();
|
return channel.getNextTransaction();
|
||||||
@ -67,15 +81,16 @@ public class NodeBase implements INode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doAction(Action action, Product product) {
|
public void doAction(ProductOperationType action, Product product) {
|
||||||
action.doWithProduct(product);
|
//create new action
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doAction(Action action) {
|
public void doAction(ProductOperationType action) {
|
||||||
action.doActionWithNodeContext(this);
|
//create new action
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void storeProduct(Product product) {
|
public void storeProduct(Product product) {
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user