public final class GroupDescriptor extends Descriptor
GroupDescriptor
has
at least 2 members.Modifier and Type | Class and Description |
---|---|
static class |
GroupDescriptor.Type
Type of a group.
|
Modifier and Type | Field and Description |
---|---|
static GroupDescriptor.Type |
ORDERED_TYPE
The ordered group type.
|
static String |
ORDERED_TYPE_ID
The identifier of the ordered group type.
|
static GroupDescriptor.Type |
RANDOM_TYPE
The random group type.
|
static String |
RANDOM_TYPE_ID
The identifier of the random group type.
|
Constructor and Description |
---|
GroupDescriptor(GroupDescriptor.Type type,
Descriptor[] members)
Constructs a new
GroupDescriptor . |
Modifier and Type | Method and Description |
---|---|
Descriptor[] |
getMembers()
Returns the members of this group.
|
TargetDescriptor |
getTargetByCRC(int crc)
Returns the
TargetDescriptor that matches the specified
CRC-32 checksum. |
int |
getTargetCount()
Counts the total number of target descriptors in/under this descriptor.
|
GroupDescriptor.Type |
getType()
Returns the type of this group.
|
static GroupDescriptor.Type |
getType(String identifier)
Gets a group type by identifier.
|
boolean |
isGroup()
Checks if this descriptor denotes a group of descriptors.
|
Iterator |
iterateTargets()
Iterates over all leaves, the target descriptors.
|
Iterator<TargetDescriptor> |
iterator() |
String |
toString()
Presents this object as a text string.
|
public static final String RANDOM_TYPE_ID
public static final String ORDERED_TYPE_ID
public static final GroupDescriptor.Type RANDOM_TYPE
public static final GroupDescriptor.Type ORDERED_TYPE
public GroupDescriptor(GroupDescriptor.Type type, Descriptor[] members) throws IllegalArgumentException
GroupDescriptor
. The members to be
included must be passed. The array of members cannot contain any
null
elements. It may contain duplicates, though.
Since XINS 1.1.0, the array of members cannot be empty, but needs to contain at least 2 descriptors.
type
- the type of group, cannot be null
.members
- list of members of the group, cannot be null
.IllegalArgumentException
- if type == null
|| members == null
|| members.length < 2
|| members[n] == null
(where 0 <= n < members.length
).public String toString()
public static GroupDescriptor.Type getType(String identifier) throws IllegalArgumentException
identifier
- the identifier for the group, cannot be null
.null
if there
is no matching type.IllegalArgumentException
- if identifier == null
.public boolean isGroup()
isGroup
in class Descriptor
true
, since this descriptor denotes a group.public Iterator iterateTargets()
The returned Iterator
will not support
Iterator.remove()
. The iterator will only return
TargetDescriptor
instances, no instances of other classes and
no null
values.
Also, this iterator is guaranteed to return getTargetCount()
instances of class TargetDescriptor
.
iterateTargets
in class Descriptor
null
.public Iterator<TargetDescriptor> iterator()
public int getTargetCount()
getTargetCount
in class Descriptor
public GroupDescriptor.Type getType()
null
.public Descriptor[] getMembers()
null
.public TargetDescriptor getTargetByCRC(int crc)
TargetDescriptor
that matches the specified
CRC-32 checksum.getTargetByCRC
in class Descriptor
crc
- the CRC-32 checksum.TargetDescriptor
that matches the specified checksum, or
null
, if none could be found in this descriptor.See http://www.xins.org/.