package org.jboss.gwt.circuit.sample.todo.client.stores;
import javax.annotation.Generated;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import org.jboss.gwt.circuit.Action;
import org.jboss.gwt.circuit.Agreement;
import org.jboss.gwt.circuit.Dispatcher;
import org.jboss.gwt.circuit.PropagatesChange.Handler;
import org.jboss.gwt.circuit.StoreCallback;
/*
* WARNING! This class is generated. Do not modify.
*/
@ApplicationScoped
@Generated("org.jboss.gwt.circuit.processor.StoreProcessor")
public class TodoStoreAdapter {
private final TodoStore delegate;
@Inject
public TodoStoreAdapter(final TodoStore delegate, final Dispatcher dispatcher) {
this.delegate = delegate;
dispatcher.register(TodoStore.class, new StoreCallback() {
@Override
public Agreement voteFor(final Action action) {
if (action instanceof org.jboss.gwt.circuit.sample.todo.client.actions.SelectUser) {
return new Agreement(true, org.jboss.gwt.circuit.sample.todo.client.stores.UserStore.class);
}
else if (action instanceof org.jboss.gwt.circuit.sample.todo.client.actions.RemoveUser) {
return new Agreement(true, org.jboss.gwt.circuit.sample.todo.client.stores.UserStore.class);
}
else if (action instanceof org.jboss.gwt.circuit.sample.todo.client.actions.ListTodos) {
return new Agreement(true);
}
else if (action instanceof org.jboss.gwt.circuit.sample.todo.client.actions.ResolveTodo) {
return new Agreement(true);
}
else if (action instanceof org.jboss.gwt.circuit.sample.todo.client.actions.SelectTodo) {
return new Agreement(true);
}
else if (action instanceof org.jboss.gwt.circuit.sample.todo.client.actions.SaveTodo) {
return new Agreement(true);
}
else if (action instanceof org.jboss.gwt.circuit.sample.todo.client.actions.RemoveTodo) {
return new Agreement(true);
}
else {
return Agreement.NONE;
}
}
@Override
public void complete(final Action action, final Dispatcher.Channel channel) {
if (action instanceof org.jboss.gwt.circuit.sample.todo.client.actions.SelectUser) {
delegate.onSelectUser(((org.jboss.gwt.circuit.sample.todo.client.actions.SelectUser)action).getPayload(), channel);
}
else if (action instanceof org.jboss.gwt.circuit.sample.todo.client.actions.RemoveUser) {
delegate.onRemoveUser(((org.jboss.gwt.circuit.sample.todo.client.actions.RemoveUser)action).getPayload(), channel);
}
else if (action instanceof org.jboss.gwt.circuit.sample.todo.client.actions.ListTodos) {
delegate.onList(channel);
}
else if (action instanceof org.jboss.gwt.circuit.sample.todo.client.actions.ResolveTodo) {
delegate.onResolve(((org.jboss.gwt.circuit.sample.todo.client.actions.ResolveTodo)action).getPayload(), channel);
}
else if (action instanceof org.jboss.gwt.circuit.sample.todo.client.actions.SelectTodo) {
delegate.onSelect(((org.jboss.gwt.circuit.sample.todo.client.actions.SelectTodo)action).getPayload(), channel);
}
else if (action instanceof org.jboss.gwt.circuit.sample.todo.client.actions.SaveTodo) {
delegate.onStore(((org.jboss.gwt.circuit.sample.todo.client.actions.SaveTodo)action).getPayload(), channel);
}
else if (action instanceof org.jboss.gwt.circuit.sample.todo.client.actions.RemoveTodo) {
delegate.onRemove(((org.jboss.gwt.circuit.sample.todo.client.actions.RemoveTodo)action).getPayload(), channel);
}
else {
System.out.println("WARN: Unmatched action " + action.getClass().getName() + " in store " + delegate.getClass());
channel.ack();
}
}
@Override
public void signalChange(final Action action) {
Class<? extends Action> actionType = action.getClass();
Iterable<Handler> actionHandlers = delegate.getActionHandler(actionType);
for (Handler actionHandler : actionHandlers) {
actionHandler.onChange(actionType);
}
Iterable<Handler> storeHandlers = delegate.getHandler();
for (Handler storeHandler : storeHandlers) {
storeHandler.onChange(actionType);
}
}
});
}
}