package org.opentrafficsim.sim0mq.publisher; import org.djunits.Throw; import org.djutils.immutablecollections.ImmutableSet; import org.djutils.metadata.MetaData; import org.djutils.metadata.ObjectDescriptor; import org.djutils.serialization.SerializationException; import org.opentrafficsim.base.Identifiable; import org.opentrafficsim.core.network.OTSNetwork; import org.sim0mq.Sim0MQException; /** * Common code for id transceivers that use an empty address. *
* Copyright (c) 2020-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
* BSD-style license. See OpenTrafficSim License.
*
Identifiable
*/
abstract ImmutableSet> getSet();
/** {@inheritDoc} */
@Override
public final Object[] get(final Object[] address, final ReturnWrapper returnWrapper)
throws Sim0MQException, SerializationException
{
String bad = verifyMetaData(getAddressFields(), address);
if (bad != null)
{
returnWrapper.nack(bad);
return null;
}
ImmutableSet> set = getSet();
Object[] result = new Object[set.size()];
int nextIndex = 0;
for (Object object : set)
{
result[nextIndex++] = ((Identifiable) object).getId();
}
return result;
}
/**
* Retrieve the network.
* @return OTSNetwork; the network
*/
final OTSNetwork getNetwork()
{
return this.network;
}
}