Class UpdateRequestBuilder
- java.lang.Object
-
- cern.accsoft.steering.jmad.tools.interpolate.UpdateRequestBuilder
-
public class UpdateRequestBuilder extends java.lang.Object
Builder forUpdateRequest
objects.Usage example (for a circular machine):
UpdateRequestBuilder builder = new UpdateRequestBuilder(true); UpdateRequest request = builder.setOptic(YOUR_OPTIC) .setElements(YOUR_ELEMENTS) .setActiveMonitors(H, YOUR_H_MONITORS) .setActiveMonitors(V, YOUR_V_MONITORS) .build();
and later on, when only your active monitors have changed:UpdateRequest request = builder.setActiveMonitors(H, YOUR_H_MONITORS) .setActiveMonitors(V, YOUR_V_MONITORS) .build();
and so forth and so on...This Builder can be reused for multiple update calls and is thread save, as both set-methods and the build method are synchronized. Therefore it is possible to set optic and elements in one thread and use the builder in another one, where the actual update is performed.
-
-
Constructor Summary
Constructors Constructor Description UpdateRequestBuilder(boolean isCirularMachine)
The constructor of a update request builder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UpdateRequest
buildRequest()
UpdateRequestBuilder
fullUpdate(java.util.List<Element> elements, java.util.Map<JMadPlane,java.util.Set<Element>> monitors, Optic optic)
Create a full update request in case the machine elements changed.UpdateRequestBuilder
setActiveMonitors(JMadPlane plane, java.util.Set<Element> monitors)
Set the active monitors for a given plane in the builder.UpdateRequestBuilder
setElements(java.util.List<Element> elements)
Set the elements defining the machine.UpdateRequestBuilder
setOptic(Optic optic)
Set the optic to use in the update request.
-
-
-
Method Detail
-
setOptic
public UpdateRequestBuilder setOptic(Optic optic)
Set the optic to use in the update request.- Parameters:
optic
- the optic to use- Returns:
- the builder
- Throws:
java.lang.IllegalArgumentException
- if null is passed
-
setElements
public UpdateRequestBuilder setElements(java.util.List<Element> elements)
Set the elements defining the machine.- Parameters:
elements
- the list of elements- Returns:
- the builder
- Throws:
java.lang.IllegalArgumentException
- in case the provided elements are null or an empty is passed
-
setActiveMonitors
public UpdateRequestBuilder setActiveMonitors(JMadPlane plane, java.util.Set<Element> monitors)
Set the active monitors for a given plane in the builder.- Parameters:
plane
- theJMadPlane
to set the active monitors formonitors
- the set of monitors to set active- Returns:
- the builder
- Throws:
java.lang.IllegalArgumentException
- if the provided set of monitor elements is null, or does not contain at least two monitors
-
fullUpdate
public UpdateRequestBuilder fullUpdate(java.util.List<Element> elements, java.util.Map<JMadPlane,java.util.Set<Element>> monitors, Optic optic)
Create a full update request in case the machine elements changed.- Parameters:
elements
- the list of elements to usemonitors
- the list of monitors to useoptic
- the optic to use- Returns:
- the builder
- Throws:
java.lang.IllegalArgumentException
- if one of the arguments is illegal
-
buildRequest
public UpdateRequest buildRequest()
- Returns:
- the actual request based on the current state of the builder.
- Throws:
java.lang.IllegalStateException
- in case one of the constraints is not fulfilled
-
-