public class CommunicationLinkCollection extends ExtensibleObjectCollection
CommunicationSystem
.
While transceivers, transponders and links are not technically transmitter or receivers themselves;
they can be passed directly to any of the methods in this class and it will retrieve the necessary
link end for the desired roll.Modifier | Constructor and Description |
---|---|
|
CommunicationLinkCollection()
Creates a default instance.
|
protected |
CommunicationLinkCollection(CommunicationLinkCollection existingCollection,
CopyContext context)
Creates an instance containing the objects provided.
|
Modifier and Type | Method and Description |
---|---|
ExtensibleObject |
add(IServiceProvider transmitter,
IServiceProvider receiver)
Creates a new link from the provided transmitter and receiver and adds it to the collection.
|
ExtensibleObject |
add(IServiceProvider transmitter,
IServiceProvider receiver,
AtmosphericRefractionModel refractionModel)
Creates a new link from the provided transmitter and receiver and adds it to the collection.
|
ExtensibleObject |
add(String name,
IServiceProvider transmitter,
IServiceProvider receiver)
Creates a new link from the provided name, transmitter, and receiver and adds it to the collection.
|
ExtensibleObject |
add(String name,
IServiceProvider transmitter,
IServiceProvider receiver,
AtmosphericRefractionModel refractionModel)
Creates a new link from the provided name, transmitter, and receiver and adds it to the collection.
|
ArrayList<ExtensibleObject> |
addChain(IServiceProvider... chain)
Adds multiple links to the collection at once, assuming that each item in the list
either receives or transmits from the previous item.
|
ArrayList<ExtensibleObject> |
addChain(Iterable<? extends IServiceProvider> chain)
Adds multiple links to the collection at once, assuming that each item in the list
either receives or transmits from the previous item.
|
protected boolean |
checkForSameDefinition(CommunicationLinkCollection other)
Checks to determine if another instance has the same definition as this instance and
returns
true if it does. |
protected boolean |
checkForSameDefinition(ExtensibleObjectCollection other)
Checks to determine if another instance has the same definition as this instance and
returns
true if it does. |
Object |
clone(CopyContext context)
Clones this object using the specified context.
|
protected int |
computeCurrentDefinitionHashCode()
Computes a hash code based on the current properties of this object.
|
void |
enumerateDependencies(DependencyEnumerator enumerator)
Enumerates the dependencies of this object by calling
DependencyEnumerator#enumerate(T) for each object that this object directly depends upon. |
Iterable<ExtensibleObject> |
find(IServiceProvider linkEnd)
Finds all links in the collection that contains the provided link end
in either the transmitter or receiver role.
|
Iterable<ExtensibleObject> |
find(IServiceProvider transmitter,
IServiceProvider receiver)
Finds all links with the specified transmitter and receiver pair.
|
Iterable<ExtensibleObject> |
find(IServiceProvider linkEnd,
LinkRole role)
Finds all links in the collection that contain the provided link end
in the specified role.
|
Iterable<ExtensibleObject> |
find(String linkName)
Finds a link in the collection by name.
|
ExtensibleObject |
findFirst(IServiceProvider linkEnd)
Finds the first link in the collection that contains the provided link end
in either the transmitter or receiver role.
|
ExtensibleObject |
findFirst(IServiceProvider transmitter,
IServiceProvider receiver)
Finds the first link with the specified transmitter and receiver pair.
|
ExtensibleObject |
findFirst(IServiceProvider linkEnd,
LinkRole role)
Finds the first link in the collection that contains the provided link end
in the specified role.
|
ExtensibleObject |
findFirst(String linkName)
Finds the first instance of the named link.
|
protected void |
freezeAggregatedObjects()
Called by
DefinitionalObjectCollection.freeze() to also freeze any objects that are considered to be a part of this object. |
AccessConstraintCollection |
getDefaultAccessConstraints()
Gets the default access constraints list.
|
ReferenceFrame |
getDefaultInertialFrame()
Gets the default inertial frame in which the light path is modeled
for new
LinkSpeedOfLight instances created by the collection. |
List<SignalPropagationModel> |
getDefaultPropagationModels()
Gets the default propagation models list.
|
void |
setDefaultInertialFrame(ReferenceFrame value)
Sets the default inertial frame in which the light path is modeled
for new
LinkSpeedOfLight instances created by the collection. |
checkForSameDefinition
addRange, clearItems, freeze, getDefinitionHashCode, getIsFrozen, insertItem, isSameDefinition, removeItem, setItem, throwIfFrozen
add, add, addAll, addAll, clear, contains, containsAll, get, getItems, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
equals, hashCode, replaceAll, sort, spliterator
parallelStream, removeIf, stream
public CommunicationLinkCollection()
The DefaultInertialFrame
(get
/ set
) is set to the Earth's inertial frame and
DefaultPropagationModels
(get
) are the same defaults defined by the WirelessLinkExtension
.
The DefaultAccessConstraints
(get
) collection contains a
CentralBodyObstructionConstraint
, using the
Earth as the CentralBody
(get
/ set
) by default.
protected CommunicationLinkCollection(@Nonnull CommunicationLinkCollection existingCollection, @Nonnull CopyContext context)
existingCollection
- The existing collection used to populate this collection initially.context
- The context to use to perform the copy.public Object clone(CopyContext context)
This method should be implemented to call a copy constructor on the class of the
object being cloned. The copy constructor should take the CopyContext
as a parameter
in addition to the existing instance to copy. The copy constructor should first call
CopyContext.addObjectMapping(T, T)
to identify the newly constructed instance
as a copy of the existing instance. It should then copy all fields, using
CopyContext.updateReference(T)
to copy any reference fields.
A typical implementation of ICloneWithContext
:
public static class MyClass implements ICloneWithContext {
public MyClass(MyClass existingInstance, CopyContext context) {
context.addObjectMapping(existingInstance, this);
someReference = context.updateReference(existingInstance.someReference);
}
@Override
public final Object clone(CopyContext context) {
return new MyClass(this, context);
}
private Object someReference;
}
In general, all fields that are reference types should be copied with a call to
CopyContext.updateReference(T)
. There are a couple of exceptions:
If one of these exceptions applies, the CopyContext
should be given an opportunity
to update the reference before the reference is copied explicitly. Use
CopyContext.updateReference(T)
to update the reference. If CopyContext.updateReference(T)
returns
the original object, indicating that the context does not have a replacement registered,
then copy the object manually by invoking a Clone method, a copy constructor, or by manually
constructing a new instance and copying the values.
alwaysCopy = context.updateReference(existingInstance.alwaysCopy);
if (existingInstance.alwaysCopy != null && alwaysCopy == existingInstance.alwaysCopy) {
alwaysCopy = (AlwaysCopy) existingInstance.alwaysCopy.clone(context);
}
If you are implementing an evaluator (a class that implements IEvaluator
), the
IEvaluator.updateEvaluatorReferences(agi.foundation.infrastructure.CopyContext)
method shares some responsibilities with the
copy context constructor. Code duplication can be avoided by doing the following:
CopyContext.updateReference(T)
. You should still call CopyContext.updateReference(T)
on any references to
non-evaluators.
IEvaluator.updateEvaluatorReferences(agi.foundation.infrastructure.CopyContext)
as the last line in the constructor and pass it the
same CopyContext
passed to the constructor.
IEvaluator.updateEvaluatorReferences(agi.foundation.infrastructure.CopyContext)
as normal. See the reference documentation for
IEvaluator.updateEvaluatorReferences(agi.foundation.infrastructure.CopyContext)
for more information on implementing that method.
public MyClass(MyClass existingInstance, CopyContext context) {
super(existingInstance, context);
someReference = context.updateReference(existingInstance.someReference);
evaluatorReference = existingInstance.evaluatorReference;
updateEvaluatorReferences(context);
}
@Override
public void updateEvaluatorReferences(CopyContext context) {
evaluatorReference = context.updateReference(evaluatorReference);
}
@Override
public Object clone(CopyContext context) {
return new MyClass(this, context);
}
private Object someReference;
private IEvaluator evaluatorReference;
clone
in interface ICloneWithContext
clone
in class ExtensibleObjectCollection
context
- The context to use to perform the copy.protected final boolean checkForSameDefinition(ExtensibleObjectCollection other)
true
if it does. Derived classes MUST override this method and check
all new fields introduced by the derived class for definitional equivalence. It is NOT necessary
to check base class fields because the base class will already have done that. When overriding this method,
you should NOT call the base implementation because it will return false
for all derived-class instances.
Derived classes should check the type of other
to preserve the symmetric nature of IEquatableDefinition.isSameDefinition(java.lang.Object)
.checkForSameDefinition
in class ExtensibleObjectCollection
other
- The other instance to compare to this one.true
if the two objects are defined equivalently; otherwise false
.protected boolean checkForSameDefinition(CommunicationLinkCollection other)
true
if it does. Derived classes MUST override this method and check
all new fields introduced by the derived class for definitional equivalence. It is NOT necessary
to check base class fields because the base class will already have done that. When overriding this method,
you should NOT call the base implementation because it will return false
for all derived-class instances.
Derived classes should check the type of other
to preserve the symmetric nature of IEquatableDefinition.isSameDefinition(java.lang.Object)
.other
- The other instance to compare to this one.true
if the two objects are defined equivalently; otherwise false
.protected int computeCurrentDefinitionHashCode()
CommunicationLinkCollection.checkForSameDefinition(agi.foundation.infrastructure.ExtensibleObjectCollection)
method.computeCurrentDefinitionHashCode
in class ExtensibleObjectCollection
public void enumerateDependencies(DependencyEnumerator enumerator)
DependencyEnumerator#enumerate(T)
for each object that this object directly depends upon.
Derived classes which contain additional dependencies MUST override this method, call the base
implementation, and enumerate dependencies introduced by the derived class.enumerateDependencies
in interface IEnumerateDependencies
enumerateDependencies
in class DefinitionalObjectCollection<ExtensibleObject>
enumerator
- The enumerator that is informed of the dependencies of this object.protected void freezeAggregatedObjects()
DefinitionalObjectCollection.freeze()
to also freeze any objects that are considered to be a part of this object.
Derived classes which contain additional aggregated objects MUST override this method, call the base
implementation, and freeze aggregated objects introduced by the derived class. The objects that need to be
frozen in this method are frequently created in this object's constructor and are not settable via
properties.freezeAggregatedObjects
in class DefinitionalObjectCollection<ExtensibleObject>
public final ReferenceFrame getDefaultInertialFrame()
LinkSpeedOfLight
instances created by the collection.public final void setDefaultInertialFrame(ReferenceFrame value)
LinkSpeedOfLight
instances created by the collection.@Nonnull public final List<SignalPropagationModel> getDefaultPropagationModels()
The propagation models used by default are the same defaults defined by the WirelessLinkExtension
.
@Nonnull public final AccessConstraintCollection getDefaultAccessConstraints()
CentralBodyObstructionConstraint
, using the
Earth as a central body by default. The CentralBodyObstruction constraint causes the wireless link to be
unavailable when the signal's path intersects the Earth's ellipsoid.@Nonnull public final ExtensibleObject add(IServiceProvider transmitter, IServiceProvider receiver)
transmitter
- The transmitter on the link.receiver
- The receiver on the link.@Nonnull public final ExtensibleObject add(String name, IServiceProvider transmitter, IServiceProvider receiver)
name
- The name of the link.transmitter
- The transmitter on the link.receiver
- The receiver on the link.PropertyInvalidException
- Thrown if DefaultInertialFrame
(get
/ set
) is null
.@Nonnull public final ExtensibleObject add(IServiceProvider transmitter, IServiceProvider receiver, AtmosphericRefractionModel refractionModel)
transmitter
- The transmitter on the link.receiver
- The receiver on the link.refractionModel
- The model used to model atmospheric refraction.PropertyInvalidException
- Thrown if DefaultInertialFrame
(get
/ set
) is null
.@Nonnull public final ExtensibleObject add(String name, IServiceProvider transmitter, IServiceProvider receiver, AtmosphericRefractionModel refractionModel)
name
- The name of the link.transmitter
- The transmitter on the link.receiver
- The receiver on the link.refractionModel
- The model used to model atmospheric refraction.PropertyInvalidException
- Thrown if DefaultInertialFrame
(get
/ set
) is null
.@Nonnull public final ArrayList<ExtensibleObject> addChain(IServiceProvider... chain)
chain
- The elements of the chain to add to the collection, in order.ArgumentNullException
- Thrown when chain is null.ArgumentException
- Thrown when the chain has fewer than two elements.@Nonnull public final ArrayList<ExtensibleObject> addChain(@Nonnull Iterable<? extends IServiceProvider> chain)
chain
- The elements of the chain to add to the collection, in order.ArgumentNullException
- Thrown when chain is null.ArgumentException
- Thrown when the chain has fewer than two elements.@Nonnull public final Iterable<ExtensibleObject> find(String linkName)
linkName
- The name of the link to find.@Nullable public final ExtensibleObject findFirst(String linkName)
linkName
- The name of the link to find.null
if the named link is not present.@Nonnull public final Iterable<ExtensibleObject> find(IServiceProvider transmitter, IServiceProvider receiver)
transmitter
- The transmitter to search for.receiver
- The receiver to search for.@Nullable public final ExtensibleObject findFirst(IServiceProvider transmitter, IServiceProvider receiver)
transmitter
- The transmitter to search for.receiver
- The receiver to search for.@Nonnull public final Iterable<ExtensibleObject> find(IServiceProvider linkEnd, @Nonnull LinkRole role)
linkEnd
- The receiver or transmitter to search for.role
- The role specifying whether it's a receiver or transmitter.@Nullable public final ExtensibleObject findFirst(IServiceProvider linkEnd, @Nonnull LinkRole role)
linkEnd
- The receiver or transmitter to search for.role
- The role specifying whether it's a receiver or transmitter.@Nonnull public final Iterable<ExtensibleObject> find(IServiceProvider linkEnd)
linkEnd
- The receiver or transmitter to search for.@Nullable public final ExtensibleObject findFirst(IServiceProvider linkEnd)
linkEnd
- The receiver or transmitter to search for.