remote.server.RemoteImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of remote4j Show documentation
Show all versions of remote4j Show documentation
Thin functional layer on top of RMI.
package remote.server;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.rmi.RemoteException;
import remote.Function;
import remote.Remote;
public class RemoteImpl extends RemoteObject implements Remote, Serializable {
private final RemoteFactory factory;
private final T value;
RemoteImpl(final T value, final RemoteFactory factory, final long num) {
super(num);
this.factory = factory;
this.value = value;
}
@Override
public Remote map(Function f) throws RemoteException {
return factory.apply(f.apply(value));
}
@Override
public Remote flatMap(Function> f) throws RemoteException {
return f.apply(value);
}
@Override
public T get() {
return value;
}
private Object writeReplace() throws ObjectStreamException {
return new RemoteImpl_Stub<>(factory.getId(), getNum(), factory);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy