Class Route.Builder

java.lang.Object
io.jenetics.jpx.Route.Builder
All Implemented Interfaces:
Filter<WayPoint,Route>
Enclosing class:
Route

public static final class Route.Builder extends Object implements Filter<WayPoint,Route>
Builder class for building Route objects.
final Route route = Route.builder() .name("Route 1") .description("Fancy mountain-bike tour.") .addPoint(p -> p.lat(48.2081743).lon(16.3738189).ele(160)) .addPoint(p -> p.lat(48.2081743).lon(16.3738189).ele(161)) .addPoint(p -> p.lat(48.2081743).lon(16.3738189).ele(162)))) .build();
  • Method Details

    • name

      public Route.Builder name(String name)
      Set the route name.
      Parameters:
      name - the route name.
      Returns:
      this Builder for method chaining
    • name

      public Optional<String> name()
      Return the current name value.
      Returns:
      the current name value
      Since:
      1.1
    • cmt

      public Route.Builder cmt(String comment)
      Set the route comment.
      Parameters:
      comment - the route comment
      Returns:
      this Builder for method chaining
    • cmt

      public Optional<String> cmt()
      Return the current comment value.
      Returns:
      the current comment value
      Since:
      1.1
    • desc

      public Route.Builder desc(String description)
      Set the route description.
      Parameters:
      description - the route description
      Returns:
      this Builder for method chaining
    • desc

      public Optional<String> desc()
      Return the current description value.
      Returns:
      the current description value
      Since:
      1.1
    • src

      public Route.Builder src(String source)
      Set the source of the data. Included to give user some idea of reliability and accuracy of data.
      Parameters:
      source - the source of the data
      Returns:
      this Builder for method chaining
    • src

      public Optional<String> src()
      Return the current source value.
      Returns:
      the current source value
      Since:
      1.1
    • links

      public Route.Builder links(List<Link> links)
      Set the links to additional information about the route. The link list may be null.
      Parameters:
      links - the links to additional information about the route
      Returns:
      this Builder for method chaining
      Throws:
      NullPointerException - if one of the links in the list is null
    • addLink

      public Route.Builder addLink(Link link)
      Set the links to external information about the route.
      Parameters:
      link - the links to external information about the route.
      Returns:
      this Builder for method chaining
      Throws:
      NullPointerException - if the given link is null
    • addLink

      public Route.Builder addLink(String href)
      Set the links to external information about the route.
      Parameters:
      href - the links to external information about the route.
      Returns:
      this Builder for method chaining
      Throws:
      NullPointerException - if the given href is null
      IllegalArgumentException - if the given href is not a valid URL
    • links

      public List<Link> links()
      Return the current links. The returned link list is mutable.
      Returns:
      the current links
      Since:
      1.1
    • number

      public Route.Builder number(UInt number)
      Set the GPS route number.
      Parameters:
      number - the GPS route number
      Returns:
      this Builder for method chaining
    • number

      public Route.Builder number(int number)
      Set the GPS route number.
      Parameters:
      number - the GPS route number
      Returns:
      this Builder for method chaining
    • number

      public Optional<UInt> number()
      Return the current number value.
      Returns:
      the current number value
      Since:
      1.1
    • type

      public Route.Builder type(String type)
      Set the type (classification) of the route.
      Parameters:
      type - the type (classification) of the route.
      Returns:
      this Builder for method chaining
    • type

      public Optional<String> type()
      Return the current type value.
      Returns:
      the current type value
      Since:
      1.1
    • extensions

      public Route.Builder extensions(Document extensions)
      Sets the extensions object, which may be null. The root element of the extensions document must be extensions.
      <extensions> ... </extensions>
      Parameters:
      extensions - the document
      Returns:
      this Builder for method chaining
      Throws:
      IllegalArgumentException - if the root element is not the an extensions node
      Since:
      1.5
    • extensions

      Return the current extensions
      Returns:
      the extensions document
      Since:
      1.5
    • points

      public Route.Builder points(List<WayPoint> points)
      Sets the way-points of the route. The way-point list may be null.
      Parameters:
      points - the way-points
      Returns:
      this Builder for method chaining
      Throws:
      NullPointerException - if one of the way-points is null
    • addPoint

      Adds a way-point to the route.
      Parameters:
      point - the way-point which is added to the route
      Returns:
      this Builder for method chaining
      Throws:
      NullPointerException - if the point is null
    • addPoint

      Add a new way-point via the given WayPoint.Builder class.
      Parameters:
      point - the way-point builder
      Returns:
      this Builder for method chaining
    • points

      public List<WayPoint> points()
      Return the current way-points. The returned list is mutable.
      Returns:
      the current, mutable way-point list
      Since:
      1.1
    • filter

      public Route.Builder filter(Predicate<? super WayPoint> predicate)
      Description copied from interface: Filter
      Return a filter consisting of the elements of this filter that matches the given predicate.
      Specified by:
      filter in interface Filter<WayPoint,Route>
      Parameters:
      predicate - a non-interfering, stateless predicate to apply to each element to determine if it should be included
      Returns:
      a new filter
    • map

      public Route.Builder map(Function<? super WayPoint,? extends WayPoint> mapper)
      Description copied from interface: Filter
      Return a filter with the results of applying the given mapper function.
      Specified by:
      map in interface Filter<WayPoint,Route>
      Parameters:
      mapper - a non-interfering, stateless function to apply to each element
      Returns:
      a new filter
    • flatMap

      public Route.Builder flatMap(Function<? super WayPoint,? extends List<WayPoint>> mapper)
      Description copied from interface: Filter
      Return a filter consisting of the results of replacing each element with the contents of the mapped elements.
      Specified by:
      flatMap in interface Filter<WayPoint,Route>
      Parameters:
      mapper - a non-interfering, stateless function to apply to each element which produces a list of new values
      Returns:
      a new filter
    • listMap

      public Route.Builder listMap(Function<? super List<WayPoint>,? extends List<WayPoint>> mapper)
      Description copied from interface: Filter
      Return a filter with the results of the applying given mapper function.
      Specified by:
      listMap in interface Filter<WayPoint,Route>
      Parameters:
      mapper - a non-interfering, stateless function to apply to the existing elements
      Returns:
      a new filter
    • build

      public Route build()
      Create a new Route object with the set values.
      Specified by:
      build in interface Filter<WayPoint,Route>
      Returns:
      a new Route object with the set values