public LegBean reverseLeg(LegV2Bean bean) {

    LegBean leg = new LegBean();

    leg.setStartTime(bean.getStartTime());
    leg.setEndTime(bean.getEndTime());
    leg.setFrom(_factory.reversePoint(bean.getFrom()));
    leg.setTo(_factory.reversePoint(bean.getTo()));
    leg.setDistance(bean.getDistance());
    if (_factory.isStringSet(bean.getMode())) leg.setMode(bean.getMode());

    TransitLegV2Bean transitLegBean = bean.getTransitLeg();
    if (transitLegBean != null) {
      TransitLegBean transitLeg = reverseTransitLeg(transitLegBean);
      leg.setTransitLeg(transitLeg);
    }

    List<StreetLegV2Bean> streetLegBeans = bean.getStreetLegs();
    if (!CollectionsLibrary.isEmpty(streetLegBeans)) {
      List<StreetLegBean> streetLegs = new ArrayList<StreetLegBean>();
      for (StreetLegV2Bean streetLegBean : streetLegBeans) {
        StreetLegBean streetLeg = reverseStreetLeg(streetLegBean);
        streetLegs.add(streetLeg);
      }
      leg.setStreetLegs(streetLegs);
    }

    return leg;
  }
  public LegV2Bean getLeg(LegBean leg) {

    LegV2Bean bean = new LegV2Bean();

    bean.setStartTime(leg.getStartTime());
    bean.setEndTime(leg.getEndTime());
    bean.setFrom(_factory.getPoint(leg.getFrom()));
    bean.setTo(_factory.getPoint(leg.getTo()));
    bean.setDistance(leg.getDistance());
    bean.setMode(leg.getMode());

    TransitLegBean transitLeg = leg.getTransitLeg();
    if (transitLeg != null) {
      TransitLegV2Bean transitLegBean = getTransitLeg(transitLeg);
      bean.setTransitLeg(transitLegBean);
    }

    List<StreetLegBean> streetLegs = leg.getStreetLegs();
    if (!CollectionsLibrary.isEmpty(streetLegs)) {
      List<StreetLegV2Bean> streetLegBeans = new ArrayList<StreetLegV2Bean>();
      for (StreetLegBean streetLeg : streetLegs) {
        StreetLegV2Bean streetLegBean = getStreetLeg(streetLeg);
        streetLegBeans.add(streetLegBean);
      }
      bean.setStreetLegs(streetLegBeans);
    }

    return bean;
  }