From f25f2557756e49a0f04ac75c9055d14dff73f2b3 Mon Sep 17 00:00:00 2001
From: Luc Maisonobe <luc@orekit.org>
Date: Wed, 24 Dec 2014 11:18:08 +0100
Subject: [PATCH] Added fluent API.

---
 .../java/org/orekit/rugged/los/LOSBuilder.java   | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/orekit/rugged/los/LOSBuilder.java b/src/main/java/org/orekit/rugged/los/LOSBuilder.java
index 434e4820..fd034b44 100644
--- a/src/main/java/org/orekit/rugged/los/LOSBuilder.java
+++ b/src/main/java/org/orekit/rugged/los/LOSBuilder.java
@@ -22,9 +22,15 @@ import java.util.List;
 import org.apache.commons.math3.analysis.differentiation.DerivativeStructure;
 import org.apache.commons.math3.geometry.euclidean.threed.FieldVector3D;
 import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
+import org.orekit.rugged.api.Rugged;
 import org.orekit.time.AbsoluteDate;
 
 /** Builder for lines-of-sight list.
+ * <p>
+ * This class implements the <em>builder pattern</em> to create {@link TimeDependentLOS} instances.
+ * It does so by using a <em>fluent API</em> in order to clarify reading and allow
+ * later extensions with new configuration parameters.
+ * </p>
  * <p>
  * This builder aims at creating lines-of-sight directions which are
  * the result of several transforms applied to an initial list of raw
@@ -33,6 +39,8 @@ import org.orekit.time.AbsoluteDate;
  * to a spacecraft.
  * </p>
  * @see TimeDependentLOS
+ * @see <a href="https://en.wikipedia.org/wiki/Builder_pattern">Builder pattern (wikipedia)</a>
+ * @see <a href="https://en.wikipedia.org/wiki/Fluent_interface">Fluent interface (wikipedia)</a>
  * @author Luc Maisonobe
  */
 public class LOSBuilder {
@@ -57,17 +65,21 @@ public class LOSBuilder {
 
     /** Add a transform to be applied after the already registered transforms.
      * @param transform transform to be applied to the lines-of-sight
+     * @return the builder instance
      */
-    public void addTransform(final TimeIndependentLOSTransform transform) {
+    public LOSBuilder addTransform(final TimeIndependentLOSTransform transform) {
         transforms.add(new TransformAdapter(transform));
+        return this;
     }
 
     /** Add a transform to be applied after the already registered transforms.
      * @param transform transform to be applied to the lines-of-sight
+     * @return the builder instance
      */
-    public void addTransform(final LOSTransform transform) {
+    public LOSBuilder addTransform(final LOSTransform transform) {
         transforms.add(transform);
         timeIndependent = false;
+        return this;
     }
 
     /** Build a lines-of-sight provider.
-- 
GitLab