Class PublishAnnotatedOperation<D,P extends Publishable>
- java.lang.Object
-
- edu.wpi.grip.core.operations.network.NetworkPublishOperation<D>
-
- edu.wpi.grip.core.operations.network.PublishAnnotatedOperation<D,P>
-
- All Implemented Interfaces:
Operation
- Direct Known Subclasses:
HttpPublishOperation
,NTPublishAnnotatedOperation
public abstract class PublishAnnotatedOperation<D,P extends Publishable> extends NetworkPublishOperation<D>
Publishes data to a specific network protocol. This looks atPublishValue
annotations on accessor methods in a class to generate the data to publish.
-
-
Field Summary
-
Fields inherited from class edu.wpi.grip.core.operations.network.NetworkPublishOperation
dataSocket, dataType, nameSocket
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
PublishAnnotatedOperation(InputSocket.Factory isf, java.lang.Class<D> dataType, java.lang.Class<P> publishType, java.util.function.Function<D,P> converter, MapNetworkPublisherFactory publisherFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanUp()
Allows the step to clean itself up when removed from the pipeline.protected java.util.List<InputSocket<java.lang.Boolean>>
createFlagSockets()
Creates a list of input sockets that control which items to publish.protected void
doPublish()
Publishes the data.protected java.lang.Object
get(java.lang.reflect.Method accessor, java.lang.Object instance)
Helper method for invoking an accessor method on an object.java.lang.Class<D>
getSocketType()
protected java.util.stream.Stream<java.lang.reflect.Method>
valueMethodStream()
Gets a stream of all valid methods annotated withPublishValue
in the class of the data to publish.-
Methods inherited from class edu.wpi.grip.core.operations.network.NetworkPublishOperation
getInputSockets, getOutputSockets, perform
-
-
-
-
Constructor Detail
-
PublishAnnotatedOperation
protected PublishAnnotatedOperation(InputSocket.Factory isf, java.lang.Class<D> dataType, java.lang.Class<P> publishType, java.util.function.Function<D,P> converter, MapNetworkPublisherFactory publisherFactory)
-
-
Method Detail
-
valueMethodStream
protected java.util.stream.Stream<java.lang.reflect.Method> valueMethodStream()
Gets a stream of all valid methods annotated withPublishValue
in the class of the data to publish. The methods are sorted by weight.
-
createFlagSockets
protected java.util.List<InputSocket<java.lang.Boolean>> createFlagSockets()
Description copied from class:NetworkPublishOperation
Creates a list of input sockets that control which items to publish.- Specified by:
createFlagSockets
in classNetworkPublishOperation<D>
-
doPublish
protected void doPublish()
Description copied from class:NetworkPublishOperation
Publishes the data.- Specified by:
doPublish
in classNetworkPublishOperation<D>
-
getSocketType
public java.lang.Class<D> getSocketType()
-
get
protected java.lang.Object get(java.lang.reflect.Method accessor, java.lang.Object instance)
Helper method for invoking an accessor method on an object.- Parameters:
accessor
- the accessor method to invokeinstance
- the object to invoke the accessor on- Returns:
- Value returned by the accessor method, or null if the method could not be invoked.
-
cleanUp
public void cleanUp()
Description copied from interface:Operation
Allows the step to clean itself up when removed from the pipeline. This should only be called byStep.setRemoved()
to ensure correct synchronization.
-
-