add some convenience methods

This commit is contained in:
zzz
2011-09-24 21:47:51 +00:00
parent 4822e47156
commit ce5acb490a
2 changed files with 48 additions and 0 deletions

View File

@ -34,6 +34,27 @@ public interface TunnelInfo {
/** retrieve the peer at the given hop. the gateway is hop 0 */
public Hash getPeer(int hop);
/**
* For convenience
* @return getPeer(0)
* @since 0.8.9
*/
public Hash getGateway();
/**
* For convenience
* @return getPeer(getLength() - 1)
* @since 0.8.9
*/
public Hash getEndpoint();
/**
* For convenience
* @return isInbound() ? getGateway() : getEndpoint()
* @since 0.8.9
*/
public Hash getFarEnd();
/** is this an inbound tunnel? */
public boolean isInbound();

View File

@ -81,6 +81,33 @@ public class TunnelCreatorConfig implements TunnelInfo {
public Hash getPeer(int hop) { return _peers[hop]; }
public void setPeer(int hop, Hash peer) { _peers[hop] = peer; }
/**
* For convenience
* @return getPeer(0)
* @since 0.8.9
*/
public Hash getGateway() {
return _peers[0];
}
/**
* For convenience
* @return getPeer(getLength() - 1)
* @since 0.8.9
*/
public Hash getEndpoint() {
return _peers[_peers.length - 1];
}
/**
* For convenience
* @return isInbound() ? getGateway() : getEndpoint()
* @since 0.8.9
*/
public Hash getFarEnd() {
return _peers[_isInbound ? 0 : _peers.length - 1];
}
/** is this an inbound tunnel? */
public boolean isInbound() { return _isInbound; }