diff --git a/src/main/java/org/ice4j/ice/Component.java b/src/main/java/org/ice4j/ice/Component.java index 28b2528..879c4bf 100644 --- a/src/main/java/org/ice4j/ice/Component.java +++ b/src/main/java/org/ice4j/ice/Component.java @@ -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); + } + } diff --git a/src/main/java/org/ice4j/ice/IceMediaStream.java b/src/main/java/org/ice4j/ice/IceMediaStream.java index 7510012..5be3a18 100644 --- a/src/main/java/org/ice4j/ice/IceMediaStream.java +++ b/src/main/java/org/ice4j/ice/IceMediaStream.java @@ -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); + } + } diff --git a/src/main/java/org/ice4j/stack/RawMessage.java b/src/main/java/org/ice4j/stack/RawMessage.java index 117e74f..bd3643a 100644 --- a/src/main/java/org/ice4j/stack/RawMessage.java +++ b/src/main/java/org/ice4j/stack/RawMessage.java @@ -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 + * messageBytes array. + * @param remoteAddress the address where the message came from. + * @param localAddress the TransportAddress 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); + } + }