Added more classes and interfaces
This commit is contained in:
parent
1d04bb6dc7
commit
021c194839
Binary file not shown.
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain;
|
||||||
|
|
||||||
|
public class FoodChain {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.channel;
|
||||||
|
|
||||||
|
public interface Channel {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.channel;
|
||||||
|
|
||||||
|
public abstract class ChannelBase implements Channel {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.channel;
|
||||||
|
|
||||||
|
public class FruitChannel extends ChannelBase {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.channel;
|
||||||
|
|
||||||
|
public class MeetChannel extends ChannelBase {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.channel;
|
||||||
|
|
||||||
|
public class VegetableChannel extends ChannelBase {
|
||||||
|
}
|
||||||
@ -1,46 +1,52 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.factory;
|
package cz.cvut.fel.sit.omo.foodchain.factory;
|
||||||
|
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.pool.PoolDatabase;
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.util.Singleton;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
public class FactoryManager {
|
public class FactoryManager {
|
||||||
|
|
||||||
public NodeFactory getNodeFactoryInstance(){
|
public NodeFactory getNodeFactoryInstance() {
|
||||||
try {
|
try {
|
||||||
return Singleton.getInstance(NodeFactory.class);
|
return Singleton.getInstance(NodeFactory.class);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InstantiationException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChannelFactory getChannelFactoryInstance(){
|
public ChannelFactory getChannelFactoryInstance() {
|
||||||
try {
|
try {
|
||||||
return Singleton.getInstance(ChannelFactory.class);
|
return Singleton.getInstance(ChannelFactory.class);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InstantiationException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScenarioFactory getScenarioFactoryInstance(){
|
public ScenarioFactory getScenarioFactoryInstance() {
|
||||||
try {
|
try {
|
||||||
return Singleton.getInstance(ScenarioFactory.class);
|
return Singleton.getInstance(ScenarioFactory.class);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InstantiationException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProductFactory getProductFactoryInstance(){
|
public ProductFactory getProductFactoryInstance() {
|
||||||
try {
|
try {
|
||||||
return Singleton.getInstance(ProductFactory.class);
|
return Singleton.getInstance(ProductFactory.class);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (InstantiationException e) {
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PoolDatabase getPoolDatabaseInstance() {
|
||||||
|
try {
|
||||||
|
return Singleton.getInstance(PoolDatabase.class);
|
||||||
|
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -1,24 +0,0 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.factory;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class Singleton {
|
|
||||||
|
|
||||||
private static final Singleton instance = new Singleton();
|
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
private final Map<Class, Object> mapHolder = new HashMap<Class, Object>();
|
|
||||||
|
|
||||||
private Singleton() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> T getInstance(Class<T> tClass) throws IllegalAccessException, InstantiationException {
|
|
||||||
if (!instance.mapHolder.containsKey(tClass)) {
|
|
||||||
T obj = tClass.newInstance();
|
|
||||||
instance.mapHolder.put(tClass, obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (T) instance.mapHolder.get(tClass);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,4 +1,15 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.node;
|
package cz.cvut.fel.sit.omo.foodchain.node;
|
||||||
|
|
||||||
public class BuyerNodeBase implements NodeInterface {
|
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
||||||
|
|
||||||
|
public class BuyerNodeBase extends NodeBase implements BuyerNodeInterface {
|
||||||
|
@Override
|
||||||
|
public void sellProduct(Product product) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addMargin(Product product) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,10 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.node;
|
||||||
|
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
||||||
|
|
||||||
|
public interface BuyerNodeInterface {
|
||||||
|
|
||||||
|
void sellProduct(Product product);
|
||||||
|
|
||||||
|
void addMargin(Product product);
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.node;
|
||||||
|
|
||||||
|
public class Customer extends BuyerNodeBase {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.node;
|
||||||
|
|
||||||
|
public class Distributor extends RetailerNodeBase {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.node;
|
||||||
|
|
||||||
|
public class Farmer extends SellerNodeBase {
|
||||||
|
}
|
||||||
@ -0,0 +1,88 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.node;
|
||||||
|
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.channel.Channel;
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.operation.Action;
|
||||||
|
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.ProductType;
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.requirement.Requirement;
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.signature.Signature;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class NodeBase implements NodeInterface {
|
||||||
|
@Override
|
||||||
|
public void sendTransaction(Product product, NodeInterface node) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void receiveTransaction(Transaction transaction) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refuseTransaction(Transaction transaction) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Transaction readNextTransaction(Channel channel) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Requirement readNextRequirement(Channel channel) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void acceptRequirement(Requirement requirement) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void subscribeToChannel(Channel channel) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unsubscribeFromChannel(Channel channel) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doAction(Action action, Product product) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doAction(Action action) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void storeProduct(Product product) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void storeProducts(List products) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Product getProductFromStorage(String name, ProductType type) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Signature generateSignature(Transaction transaction) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean validateSignature(Signature signature) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,25 +1,43 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.node;
|
package cz.cvut.fel.sit.omo.foodchain.node;
|
||||||
|
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.channel.Channel;
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.operation.Action;
|
||||||
|
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.ProductType;
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.requirement.Requirement;
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.signature.Signature;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public interface NodeInterface {
|
public interface NodeInterface {
|
||||||
void sendTransaction(Product product, NodeInterface node);
|
void sendTransaction(Product product, NodeInterface node);
|
||||||
void receiveTransaction(Transaction transaction);
|
|
||||||
void refuseTransaction(Transaction transaction);
|
|
||||||
Transaction readNextTransaction(ChannelInterface channel);
|
|
||||||
|
|
||||||
Requirement readNextRequirement(ChannelInterface channel);
|
void receiveTransaction(Transaction transaction);
|
||||||
|
|
||||||
|
void refuseTransaction(Transaction transaction);
|
||||||
|
|
||||||
|
Transaction readNextTransaction(Channel channel);
|
||||||
|
|
||||||
|
Requirement readNextRequirement(Channel channel);
|
||||||
|
|
||||||
void acceptRequirement(Requirement requirement);
|
void acceptRequirement(Requirement requirement);
|
||||||
|
|
||||||
void subscribeToChannel(ChannelInterface channel);
|
void subscribeToChannel(Channel channel);
|
||||||
void unsubscribeFromChannel(ChannelInterface channel);
|
|
||||||
|
void unsubscribeFromChannel(Channel channel);
|
||||||
|
|
||||||
void doAction(Action action, Product product);
|
void doAction(Action action, Product product);
|
||||||
|
|
||||||
void doAction(Action action);
|
void doAction(Action action);
|
||||||
|
|
||||||
void storeProduct(Product product);
|
void storeProduct(Product product);
|
||||||
void storeProducts(List<Product> products);
|
|
||||||
|
void storeProducts(List products);
|
||||||
|
|
||||||
Product getProductFromStorage(String name, ProductType type);
|
Product getProductFromStorage(String name, ProductType type);
|
||||||
|
|
||||||
Signature generateSignature(Transaction transaction);
|
Signature generateSignature(Transaction transaction);
|
||||||
|
|
||||||
boolean validateSignature(Signature signature);
|
boolean validateSignature(Signature signature);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.node;
|
||||||
|
|
||||||
|
public class Processor extends RetailerNodeBase {
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.node;
|
||||||
|
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
||||||
|
|
||||||
|
public class RetailerNodeBase extends NodeBase implements BuyerNodeInterface, SellerNodeInterface {
|
||||||
|
@Override
|
||||||
|
public void sellProduct(Product product) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addMargin(Product product) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buyProduct(Product product) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.node;
|
||||||
|
|
||||||
|
public class Seller extends RetailerNodeBase {
|
||||||
|
}
|
||||||
@ -1,4 +1,10 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.node;
|
package cz.cvut.fel.sit.omo.foodchain.node;
|
||||||
|
|
||||||
public class SellerNodeBase implements NodeInterface {
|
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
||||||
|
|
||||||
|
public class SellerNodeBase extends NodeBase implements SellerNodeInterface {
|
||||||
|
@Override
|
||||||
|
public void buyProduct(Product product) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,8 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.node;
|
||||||
|
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
||||||
|
|
||||||
|
public interface SellerNodeInterface {
|
||||||
|
|
||||||
|
void buyProduct(Product product);
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.operation;
|
||||||
|
|
||||||
|
public class Action extends OperationBase {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.operation;
|
||||||
|
|
||||||
|
public class FinancialTransaction extends Transaction {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.operation;
|
||||||
|
|
||||||
|
public class OperationBase {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.operation;
|
||||||
|
|
||||||
|
public interface OperationInterface {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.operation;
|
||||||
|
|
||||||
|
public enum ProductOperationType {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.operation;
|
||||||
|
|
||||||
|
public class ProductTransaction extends Transaction {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.operation;
|
||||||
|
|
||||||
|
public abstract class Transaction extends OperationBase {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.operation;
|
||||||
|
|
||||||
|
public enum TransactionType {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.parser;
|
||||||
|
|
||||||
|
public class ConfigurationParser {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.parser;
|
||||||
|
|
||||||
|
public class ConsoleParser {
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.pool;
|
||||||
|
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.channel.Channel;
|
||||||
|
|
||||||
|
public class ChannelPool extends PoolListBase<Channel> {
|
||||||
|
}
|
||||||
@ -1,4 +1,44 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.pool;
|
package cz.cvut.fel.sit.omo.foodchain.pool;
|
||||||
|
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.util.Singleton;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
public class PoolDatabase {
|
public class PoolDatabase {
|
||||||
|
|
||||||
|
public ChannelPool getChannelPoolInstance() {
|
||||||
|
try {
|
||||||
|
return Singleton.getInstance(ChannelPool.class);
|
||||||
|
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NodePool getNodePoolInstance() {
|
||||||
|
try {
|
||||||
|
return Singleton.getInstance(NodePool.class);
|
||||||
|
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProductPool getProductPoolInstance() {
|
||||||
|
try {
|
||||||
|
return Singleton.getInstance(ProductPool.class);
|
||||||
|
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ScenarioPool getScenarioPoolInstance() {
|
||||||
|
try {
|
||||||
|
return Singleton.getInstance(ScenarioPool.class);
|
||||||
|
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,8 +6,10 @@ public interface PoolInterface<T> {
|
|||||||
Collection<T> findAll();
|
Collection<T> findAll();
|
||||||
|
|
||||||
void add(T element);
|
void add(T element);
|
||||||
|
|
||||||
void remove(T element);
|
void remove(T element);
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
boolean contains(T element);
|
boolean contains(T element);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.pool;
|
package cz.cvut.fel.sit.omo.foodchain.pool;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.Collection;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class PoolListBase<T> implements PoolInterface<T> {
|
public abstract class PoolListBase<T> implements PoolInterface<T> {
|
||||||
List<T> pool;
|
List<T> pool;
|
||||||
|
|
||||||
public PoolListBase() {
|
public PoolListBase() {
|
||||||
|
|||||||
@ -0,0 +1,6 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.pool;
|
||||||
|
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
||||||
|
|
||||||
|
public class ProductPool extends PoolListBase<Product> {
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.pool;
|
||||||
|
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.scenario.Scenario;
|
||||||
|
|
||||||
|
public class ScenarioPool extends PoolListBase<Scenario> {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.product;
|
||||||
|
|
||||||
|
public class Product {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.product;
|
||||||
|
|
||||||
|
public class ProductState {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.product;
|
||||||
|
|
||||||
|
public enum ProductType {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.reporting;
|
||||||
|
|
||||||
|
public class ReportTextFileVisitor {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.reporting;
|
||||||
|
|
||||||
|
public class ReportingManager {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.requirement;
|
||||||
|
|
||||||
|
public class Requirement {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.scenario;
|
||||||
|
|
||||||
|
public class Scenario {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.signature;
|
||||||
|
|
||||||
|
public class Signature {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.signature;
|
||||||
|
|
||||||
|
public class SignatureManager {
|
||||||
|
}
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.util;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class Singleton {
|
||||||
|
|
||||||
|
private static final Singleton instance = new Singleton();
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
private final Map<Class, Object> mapHolder = new HashMap<Class, Object>();
|
||||||
|
|
||||||
|
private Singleton() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T getInstance(Class<T> tClass) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, InstantiationException {
|
||||||
|
if (!instance.mapHolder.containsKey(tClass)) {
|
||||||
|
Constructor<T> cons = tClass.getConstructor();
|
||||||
|
Object object = cons.newInstance();
|
||||||
|
instance.mapHolder.put(tClass, object);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (T) instance.mapHolder.get(tClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user