feat: remove list to java binding
This commit is contained in:
@@ -16,7 +16,6 @@ import appointmentplanner.api.LocalDayPlan;
|
|||||||
import appointmentplanner.api.TimePreference;
|
import appointmentplanner.api.TimePreference;
|
||||||
import appointmentplanner.api.TimeSlot;
|
import appointmentplanner.api.TimeSlot;
|
||||||
import appointmentplanner.customlist.CustomLinkedListImpl;
|
import appointmentplanner.customlist.CustomLinkedListImpl;
|
||||||
import appointmentplanner.customlist.CustomListToJavaBinding;
|
|
||||||
import appointmentplanner.customlist.api.CustomLinkedList;
|
import appointmentplanner.customlist.api.CustomLinkedList;
|
||||||
|
|
||||||
public class LocalDayPlanImpl implements LocalDayPlan {
|
public class LocalDayPlanImpl implements LocalDayPlan {
|
||||||
@@ -81,13 +80,12 @@ public class LocalDayPlanImpl implements LocalDayPlan {
|
|||||||
removedRequests.add(appointment.request());
|
removedRequests.add(appointment.request());
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CustomListToJavaBinding<>(removedRequests);
|
return removedRequests.toArrayList();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Appointment> appointments() {
|
public List<Appointment> appointments() {
|
||||||
return new CustomListToJavaBinding<Appointment>(timeline);
|
return timeline.toArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -120,13 +118,12 @@ public class LocalDayPlanImpl implements LocalDayPlan {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TimeSlot> findGapsFitting(Duration duration) {
|
public List<TimeSlot> findGapsFitting(Duration duration) {
|
||||||
return new CustomListToJavaBinding<>(
|
return traverseGapsFitting(duration, new CustomLinkedListImpl<>(), null, timeline.iterator()).toArrayList();
|
||||||
traverseGapsFitting(duration, new CustomLinkedListImpl<>(), null, timeline.iterator()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Appointment> findAppointments(Predicate<Appointment> filter) {
|
public List<Appointment> findAppointments(Predicate<Appointment> filter) {
|
||||||
return new CustomListToJavaBinding<>(timeline.find(filter));
|
return timeline.find(filter).toArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,157 +0,0 @@
|
|||||||
package appointmentplanner.customlist;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ListIterator;
|
|
||||||
|
|
||||||
import appointmentplanner.customlist.api.*;
|
|
||||||
|
|
||||||
public class CustomListToJavaBinding<T> implements List<T> {
|
|
||||||
|
|
||||||
private CustomLinkedList<T> list;
|
|
||||||
|
|
||||||
public CustomListToJavaBinding(CustomLinkedList<T> list) {
|
|
||||||
this.list = list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean add(T arg0) {
|
|
||||||
list.add(arg0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void add(int arg0, T arg1) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Cannot add to exact index in linked list");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean addAll(Collection<? extends T> c) {
|
|
||||||
c.stream().forEach(list::add);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean addAll(int index, Collection<? extends T> c) {
|
|
||||||
throw new UnsupportedOperationException("Cannot add to exact index in linked list");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'clear'");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean containsAll(Collection<?> c) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'containsAll'");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T get(int index) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'get'");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int indexOf(Object o) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'indexOf'");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return list.size() == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterator<T> iterator() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'iterator'");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int lastIndexOf(Object o) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'lastIndexOf'");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ListIterator<T> listIterator() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'listIterator'");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ListIterator<T> listIterator(int index) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'listIterator'");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean remove(Object o) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'remove'");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T remove(int index) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'remove'");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean removeAll(Collection<?> c) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'removeAll'");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean retainAll(Collection<?> c) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'retainAll'");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T set(int arg0, T arg1) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'set'");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int size() {
|
|
||||||
return list.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<T> subList(int fromIndex, int toIndex) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'subList'");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object[] toArray() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'toArray'");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> T[] toArray(T[] arg0) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'toArray'");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean contains(Object o) {
|
|
||||||
try {
|
|
||||||
T bal = (T) o;
|
|
||||||
return list.contains(bal);
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user