- java.lang.Object
-
- org.praxislive.core.Value
-
- org.praxislive.core.ComponentAddress
-
public final class ComponentAddress extends Value
Address of a Component. A component is a slash separated path of IDs, starting with the ID of the Root that the Component is in, eg./rootID/parentID/componentID
. ComponentAddresses are always absolute.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.praxislive.core.Value
Value.Type<T extends Value>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
componentID()
Equivalent to componentID(depth() - 1).String
componentID(int depth)
Get ID at given depth in address.ControlAddress
control(String id)
Get aControlAddress
for a control on this component.int
depth()
Number of ID parts to this addressboolean
equals(Object obj)
Values must override the default equals method.static Optional<ComponentAddress>
from(Value arg)
int
hashCode()
Values must override the default hashcode method.static ArgumentInfo
info()
static boolean
isValidID(String id)
static ComponentAddress
of(String address)
Create an address from the supplied Stringstatic ComponentAddress
of(ComponentAddress address, String path)
Create a ComponentAddress by adding the supplied path to the end of the supplied ComponentAddress.ComponentAddress
parent()
The parent address.static ComponentAddress
parse(String addressString)
Create an address from the supplied StringPortAddress
port(String id)
Get aPortAddress
for a port on this component.ComponentAddress
resolve(String path)
Resolve the provided path or child ID against this address.String
rootID()
Equivalent to componentID(0).String
toString()
Values must override the default method to return a string representation that is immutable.-
Methods inherited from class org.praxislive.core.Value
equivalent, isEmpty, ofObject, type
-
-
-
-
Method Detail
-
depth
public int depth()
Number of ID parts to this address- Returns:
- int Depth (always >=1)
-
componentID
public String componentID(int depth)
Get ID at given depth in address.- Parameters:
depth
-- Returns:
- String ID
-
componentID
public String componentID()
Equivalent to componentID(depth() - 1).- Returns:
- String
-
rootID
public String rootID()
Equivalent to componentID(0).- Returns:
- String
-
parent
public ComponentAddress parent()
The parent address. Returns null if this is a root address (depth == 1).- Returns:
- parent address, or null if root address.
-
resolve
public ComponentAddress resolve(String path)
Resolve the provided path or child ID against this address. The path should be relative and not start with a slash.- Parameters:
path
- relative address to resolve- Returns:
- resolved address
-
control
public ControlAddress control(String id)
Get aControlAddress
for a control on this component.- Parameters:
id
- control id- Returns:
- control address
-
port
public PortAddress port(String id)
Get aPortAddress
for a port on this component.- Parameters:
id
- port id- Returns:
- port address
-
toString
public String toString()
Description copied from class:Value
Values must override the default method to return a string representation that is immutable.
-
hashCode
public int hashCode()
Description copied from class:Value
Values must override the default hashcode method.
-
equals
public boolean equals(Object obj)
Description copied from class:Value
Values must override the default equals method. This method should only returntrue
if the supplied Object is of the same type as the implementing Value. Values of an unknown type should be coerced before calling this method. This method does not have to guarantee thatthis.equals(that) == this.toString().equals(that.toString())
-
parse
public static ComponentAddress parse(String addressString) throws ValueFormatException
Create an address from the supplied String- Parameters:
addressString
-- Returns:
- ComponentAddress
- Throws:
ValueFormatException
-
of
public static ComponentAddress of(String address)
Create an address from the supplied String- Parameters:
address
-- Returns:
- ComponentAddress
- Throws:
IllegalArgumentException
- on invalid string
-
of
public static ComponentAddress of(ComponentAddress address, String path)
Create a ComponentAddress by adding the supplied path to the end of the supplied ComponentAddress.- Parameters:
address
-path
-- Returns:
- ComponentAddress
- Throws:
IllegalArgumentException
-
from
public static Optional<ComponentAddress> from(Value arg)
-
isValidID
public static boolean isValidID(String id)
- Parameters:
id
-- Returns:
-
info
public static ArgumentInfo info()
-
-