]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.document.server/src/org/simantics/document/server/handler/AbstractResponseHandler.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.document.server / src / org / simantics / document / server / handler / AbstractResponseHandler.java
1 package org.simantics.document.server.handler;
2
3 import org.simantics.document.server.io.CommandContext;
4 import org.simantics.document.server.io.CommandResult;
5 import org.simantics.scl.runtime.function.Function1;
6
7 public abstract class AbstractResponseHandler extends AbstractEventHandler {
8
9         private Function1<CommandContext, CommandResult> fn;
10         
11         public AbstractResponseHandler(Function1<CommandContext, CommandResult> fn) {
12                 this.fn = fn;
13         }
14
15         @Override
16         public int hashCode() {
17                 final int prime = 31;
18                 int result = 1;
19                 result = prime * result + ((fn == null) ? 0 : fn.hashCode());
20                 return result;
21         }
22
23         @Override
24         public boolean equals(Object obj) {
25                 if (this == obj)
26                         return true;
27                 if (obj == null)
28                         return false;
29                 if (getClass() != obj.getClass())
30                         return false;
31                 AbstractResponseHandler other = (AbstractResponseHandler) obj;
32                 if (fn == null) {
33                         if (other.fn != null)
34                                 return false;
35                 } else if (!fn.equals(other.fn))
36                         return false;
37                 return true;
38         }
39         
40 }