// Path: rdfagents-core/src/main/java/net/fortytwo/rdfagents/messaging/query/QueryProvider.java
// public abstract class QueryProvider<Q, A> extends Role {
// 
//     public QueryProvider(final RDFAgent agent) {
//         super(agent);
//     }
// 
//     /**
//      * @param conversationId the conversation of the query
//      * @param query          the query to be answered
//      * @param initiator      the requester of the query
//      * @return the commitment of this server towards answering the query
//      */
//     public abstract Commitment considerQueryRequest(String conversationId,
//                                                     Q query,
//                                                     AgentId initiator);
// 
//     /**
//      * Evaluate a query to produce a result.
//      * While the query request has previously been accepted or refused based on the identity of the initiator,
//      * the actual query is answered independently of the initiator.
//      *
//      * @param query the query to answer
//      * @return the answer to the query
//      * @throws LocalFailure if query answering fails
//      */
//     public abstract A answer(Q query) throws LocalFailure;
// 
//     /**
//      * Cancel a previously submitted query.
//      *
//      * @param conversationId the conversation of the query
//      * @throws LocalFailure if cancellation fails
//      */
//     public abstract void cancel(String conversationId) throws LocalFailure;
// }
// 
// Path: rdfagents-core/src/main/java/net/fortytwo/rdfagents/messaging/subscribe/PubsubProvider.java
// public abstract class PubsubProvider<T, U> extends Role {
//     private static final Logger logger = Logger.getLogger(PubsubProvider.class.getName());
// 
//     private class Subscription {
//         public final AgentId subscriber;
//         public final T topic;
//         public final UpdateHandler<U> handler;
// 
//         public Subscription(final AgentId subscriber,
//                             final T topic,
//                             final UpdateHandler<U> handler) {
//             this.subscriber = subscriber;
//             this.topic = topic;
//             this.handler = handler;
//         }
//     }
// 
//     private final Map<T, Set<String>> idsByTopic;
//     private final Map<String, Subscription> subscriptionsById;
//     private final Object mutex = "";
// 
//     public PubsubProvider(final RDFAgent agent) {
//         super(agent);
//         this.idsByTopic = new HashMap<>();
//         this.subscriptionsById = new HashMap<>();
//     }
// 
//     /**
//      * Renders a decision with respect to a subscription request.
//      *
//      * @param conversationId the conversation of the subscription
//      * @param topic          the topic of the desired stream
//      * @param initiator      the requester of the subscription
//      * @param handler        the handler for updates, provided this subscription request is accepted
//      * @return the commitment of this server towards handling the subscription
//      * @throws LocalFailure if decision making fails
//      */
//     public Commitment considerSubscriptionRequest(final String conversationId,
//                                                   final T topic,
//                                                   final AgentId initiator,
//                                                   final UpdateHandler<U> handler) throws LocalFailure {
//         Commitment c = considerSubscriptionRequestInternal(topic, initiator);
// 
//         switch (c.getDecision()) {
//             case AGREE_AND_NOTIFY:
//                 synchronized (mutex) {
//                     Set<String> ids = idsByTopic.get(topic);
//                     if (null == ids) {
//                         ids = new HashSet<>();
//                         idsByTopic.put(topic, ids);
//                     }
//                     ids.add(conversationId);
// 
//                     Subscription s = new Subscription(initiator, topic, handler);
//                     subscriptionsById.put(conversationId, s);
//                 }
// 
//                 return c;
//             case AGREE_SILENTLY:
//                 throw new LocalFailure("agreeing to a subscription without confirmation is not supported");
//             case REFUSE:
//                 return c;
//             default:
//                 throw new LocalFailure("unexpected decision: " + c.getDecision());
//         }
//     }
// 
//     /**
//      * Renders a decision with respect to a subscription request.
//      *
//      * @param topic     the topic of the desired stream
//      * @param initiator the requester of the subscription
//      * @return the commitment of this server towards handling the subscription
//      */
//     protected abstract Commitment considerSubscriptionRequestInternal(T topic,
//                                                                       AgentId initiator);
// 
//     /**
//      * Cancel a subscription.
//      *
//      * @param conversationId the conversation of the subscription
//      * @throws LocalFailure if cancellation fails
//      */
//     public void cancel(String conversationId) throws LocalFailure {
//         synchronized (mutex) {
//             Subscription s = subscriptionsById.get(conversationId);
// 
//             if (null == s) {
//                 logger.warning("attempted to cancel a Subscribe interaction which does not exist: " + conversationId);
//             } else {
//                 subscriptionsById.remove(conversationId);
//                 Set<String> ids = idsByTopic.get(s.topic);
//                 if (null != ids) {
//                     if (1 >= ids.size()) {
//                         idsByTopic.remove(s.topic);
//                     } else {
//                         ids.remove(conversationId);
//                     }
//                 }
//             }
//         }
//     }
// 
//     /**
//      * Communicates an update for each matching subscription to its respective subscriber
//      *
//      * @param topic  the topic of the subscription(s)
//      * @param update the update to communicate
//      * @throws LocalFailure if update communication fails
//      */
//     protected void produceUpdate(final T topic,
//                                  final U update) throws LocalFailure {
//         for (String id : idsByTopic.get(topic)) {
//             Subscription s = subscriptionsById.get(id);
//             s.handler.handle(update);
//         }
//     }
// 
//     /**
//      * @return the set of all topics of active subscriptions
//      */
//     protected Set<T> getTopics() {
//         return idsByTopic.keySet();
//     }
// }


import net.fortytwo.rdfagents.messaging.query.QueryProvider;
import net.fortytwo.rdfagents.messaging.subscribe.PubsubProvider;
import org.openrdf.model.Value;
package net.fortytwo.rdfagents.model;


/**
 * @author Joshua Shinavier (http://fortytwo.net)
 */
public abstract class RDFAgent {
    protected final AgentId identity;

    public RDFAgent(final RDFAgentsPlatform platform,
                    final AgentId id) throws RDFAgentException {

        if (0 == id.getTransportAddresses().length) {
            throw new IllegalArgumentException("at least one transport address must be specified");
        }

        identity = id;
    }

    public AgentId getIdentity() {
        return identity;
    }

    public abstract void setQueryProvider(QueryProvider<Value, Dataset> queryProvider);

// Path: rdfagents-core/src/main/java/net/fortytwo/rdfagents/messaging/query/QueryProvider.java
// public abstract class QueryProvider<Q, A> extends Role {
// 
//     public QueryProvider(final RDFAgent agent) {
//         super(agent);
//     }
// 
//     /**
//      * @param conversationId the conversation of the query
//      * @param query          the query to be answered
//      * @param initiator      the requester of the query
//      * @return the commitment of this server towards answering the query
//      */
//     public abstract Commitment considerQueryRequest(String conversationId,
//                                                     Q query,
//                                                     AgentId initiator);
// 
//     /**
//      * Evaluate a query to produce a result.
//      * While the query request has previously been accepted or refused based on the identity of the initiator,
//      * the actual query is answered independently of the initiator.
//      *
//      * @param query the query to answer
//      * @return the answer to the query
//      * @throws LocalFailure if query answering fails
//      */
//     public abstract A answer(Q query) throws LocalFailure;
// 
//     /**
//      * Cancel a previously submitted query.
//      *
//      * @param conversationId the conversation of the query
//      * @throws LocalFailure if cancellation fails
//      */
//     public abstract void cancel(String conversationId) throws LocalFailure;
// }
// 
// Path: rdfagents-core/src/main/java/net/fortytwo/rdfagents/messaging/subscribe/PubsubProvider.java
// public abstract class PubsubProvider<T, U> extends Role {
//     private static final Logger logger = Logger.getLogger(PubsubProvider.class.getName());
// 
//     private class Subscription {
//         public final AgentId subscriber;
//         public final T topic;
//         public final UpdateHandler<U> handler;
// 
//         public Subscription(final AgentId subscriber,
//                             final T topic,
//                             final UpdateHandler<U> handler) {
//             this.subscriber = subscriber;
//             this.topic = topic;
//             this.handler = handler;
//         }
//     }
// 
//     private final Map<T, Set<String>> idsByTopic;
//     private final Map<String, Subscription> subscriptionsById;
//     private final Object mutex = "";
// 
//     public PubsubProvider(final RDFAgent agent) {
//         super(agent);
//         this.idsByTopic = new HashMap<>();
//         this.subscriptionsById = new HashMap<>();
//     }
// 
//     /**
//      * Renders a decision with respect to a subscription request.
//      *
//      * @param conversationId the conversation of the subscription
//      * @param topic          the topic of the desired stream
//      * @param initiator      the requester of the subscription
//      * @param handler        the handler for updates, provided this subscription request is accepted
//      * @return the commitment of this server towards handling the subscription
//      * @throws LocalFailure if decision making fails
//      */
//     public Commitment considerSubscriptionRequest(final String conversationId,
//                                                   final T topic,
//                                                   final AgentId initiator,
//                                                   final UpdateHandler<U> handler) throws LocalFailure {
//         Commitment c = considerSubscriptionRequestInternal(topic, initiator);
// 
//         switch (c.getDecision()) {
//             case AGREE_AND_NOTIFY:
//                 synchronized (mutex) {
//                     Set<String> ids = idsByTopic.get(topic);
//                     if (null == ids) {
//                         ids = new HashSet<>();
//                         idsByTopic.put(topic, ids);
//                     }
//                     ids.add(conversationId);
// 
//                     Subscription s = new Subscription(initiator, topic, handler);
//                     subscriptionsById.put(conversationId, s);
//                 }
// 
//                 return c;
//             case AGREE_SILENTLY:
//                 throw new LocalFailure("agreeing to a subscription without confirmation is not supported");
//             case REFUSE:
//                 return c;
//             default:
//                 throw new LocalFailure("unexpected decision: " + c.getDecision());
//         }
//     }
// 
//     /**
//      * Renders a decision with respect to a subscription request.
//      *
//      * @param topic     the topic of the desired stream
//      * @param initiator the requester of the subscription
//      * @return the commitment of this server towards handling the subscription
//      */
//     protected abstract Commitment considerSubscriptionRequestInternal(T topic,
//                                                                       AgentId initiator);
// 
//     /**
//      * Cancel a subscription.
//      *
//      * @param conversationId the conversation of the subscription
//      * @throws LocalFailure if cancellation fails
//      */
//     public void cancel(String conversationId) throws LocalFailure {
//         synchronized (mutex) {
//             Subscription s = subscriptionsById.get(conversationId);
// 
//             if (null == s) {
//                 logger.warning("attempted to cancel a Subscribe interaction which does not exist: " + conversationId);
//             } else {
//                 subscriptionsById.remove(conversationId);
//                 Set<String> ids = idsByTopic.get(s.topic);
//                 if (null != ids) {
//                     if (1 >= ids.size()) {
//                         idsByTopic.remove(s.topic);
//                     } else {
//                         ids.remove(conversationId);
//                     }
//                 }
//             }
//         }
//     }
// 
//     /**
//      * Communicates an update for each matching subscription to its respective subscriber
//      *
//      * @param topic  the topic of the subscription(s)
//      * @param update the update to communicate
//      * @throws LocalFailure if update communication fails
//      */
//     protected void produceUpdate(final T topic,
//                                  final U update) throws LocalFailure {
//         for (String id : idsByTopic.get(topic)) {
//             Subscription s = subscriptionsById.get(id);
//             s.handler.handle(update);
//         }
//     }
// 
//     /**
//      * @return the set of all topics of active subscriptions
//      */
//     protected Set<T> getTopics() {
//         return idsByTopic.keySet();
//     }
// }


// Path: rdfagents-core/src/main/java/net/fortytwo/rdfagents/model/RDFAgent.java
import net.fortytwo.rdfagents.messaging.query.QueryProvider;
import net.fortytwo.rdfagents.messaging.subscribe.PubsubProvider;
import org.openrdf.model.Value;

package net.fortytwo.rdfagents.model;


/**
 * @author Joshua Shinavier (http://fortytwo.net)
 */
public abstract class RDFAgent {
    protected final AgentId identity;

    public RDFAgent(final RDFAgentsPlatform platform,
                    final AgentId id) throws RDFAgentException {

        if (0 == id.getTransportAddresses().length) {
            throw new IllegalArgumentException("at least one transport address must be specified");
        }

        identity = id;
    }

    public AgentId getIdentity() {
        return identity;
    }

    public abstract void setQueryProvider(QueryProvider<Value, Dataset> queryProvider);

    public abstract void setPubsubProvider(PubsubProvider<Value, Dataset> pubsubProvider);