Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
659 B
73
Indexable
private static Object createObject(Car car) {
    List<Object> objects = new ArrayList<>();

    long   id   = car.id;
    String name = car.getName();

    if (car.carList == null) {
      objects = null;
    }
    else {
      objects = createPojazdList(car.carList);
    }
    
    System.out.println(objects);


    return new Object(id, name, objects);
  }

  private static List<Object> createObjectList(List<Car> carList) {
    List<Object> object = new ArrayList<>();
    if (carList.isEmpty()) {
      return null;
    }

    for (Car car : carList) {
      object.add(createObjectList(car));
    }
    return object;
  }