001
014
015 package com.liferay.portal.kernel.nio.intraband.test;
016
017 import com.liferay.portal.kernel.nio.intraband.Intraband;
018 import com.liferay.portal.kernel.nio.intraband.RegistrationReference;
019
020 import java.nio.channels.GatheringByteChannel;
021 import java.nio.channels.ScatteringByteChannel;
022
023
026 public class MockRegistrationReference implements RegistrationReference {
027
028 public MockRegistrationReference(Intraband intraband) {
029 this(intraband, null, null);
030 }
031
032 public MockRegistrationReference(
033 ScatteringByteChannel scatteringByteChannel,
034 GatheringByteChannel gatheringByteChannel) {
035
036 this(null, scatteringByteChannel, gatheringByteChannel);
037 }
038
039 @Override
040 public void cancelRegistration() {
041 _cancelled = true;
042 }
043
044 public GatheringByteChannel getGatheringByteChannel() {
045 return _gatheringByteChannel;
046 }
047
048 @Override
049 public Intraband getIntraband() {
050 return _intraband;
051 }
052
053 public ScatteringByteChannel getScatteringByteChannel() {
054 return _scatteringByteChannel;
055 }
056
057 @Override
058 public boolean isValid() {
059 return !_cancelled;
060 }
061
062 private MockRegistrationReference(
063 Intraband intraband, ScatteringByteChannel scatteringByteChannel,
064 GatheringByteChannel gatherByteChannel) {
065
066 _intraband = intraband;
067 _scatteringByteChannel = scatteringByteChannel;
068 _gatheringByteChannel = gatherByteChannel;
069 }
070
071 private boolean _cancelled;
072 private final GatheringByteChannel _gatheringByteChannel;
073 private final Intraband _intraband;
074 private final ScatteringByteChannel _scatteringByteChannel;
075
076 }