Added builders to allow external use by other projects.

This commit is contained in:
Paul Gregoire 2015-10-29 21:20:45 -04:00 committed by Ingo Bauersachs
parent 5dbac4599d
commit 9e8c9690ed
3 changed files with 49 additions and 0 deletions

View File

@ -884,4 +884,19 @@ public class Component
else
return Integer.toString(componentID);
}
/**
* Use builder pattern to allow creation of immutable Component instances,
* from outside the current package.
*
* @param componentID the id of this component.
* @param mediaStream the {@link IceMediaStream} instance that would be the
* parent of this component.
* @return Component
*/
public static Component build(int componentID, IceMediaStream mediaStream)
{
return new Component(componentID, mediaStream);
}
}

View File

@ -903,4 +903,18 @@ public class IceMediaStream
{
return remotePassword;
}
/**
* Use builder pattern to provide an immutable IceMediaStream instance.
*
* @param name the name of the media stream
* @param parentAgent the agent that is handling the session that this
* media stream is a part of
* @return IceMediaStream
*/
public static IceMediaStream build(Agent parentAgent, String name)
{
return new IceMediaStream(parentAgent, name);
}
}

View File

@ -119,4 +119,24 @@ public class RawMessage
{
return localAddress;
}
/**
* Use builder pattern to allow creation of immutable RawMessage instances,
* from outside the current package.
*
* @param messageBytes the message itself.
* @param messageLength the number of bytes currently stored in the
* <tt>messageBytes</tt> array.
* @param remoteAddress the address where the message came from.
* @param localAddress the <tt>TransportAddress</tt> that the message was
* received on.
* @return RawMessage instance
*/
public static RawMessage build(byte[] messageBytes, int messageLength,
TransportAddress remoteAddress, TransportAddress localAddress)
{
return new RawMessage(messageBytes, messageLength, remoteAddress,
localAddress);
}
}