diff --git a/assignment/src/main/java/appointmentplanner/customlist/CustomListToJavaBinding.java b/assignment/src/main/java/appointmentplanner/customlist/CustomListToJavaBinding.java new file mode 100644 index 0000000..dc1e941 --- /dev/null +++ b/assignment/src/main/java/appointmentplanner/customlist/CustomListToJavaBinding.java @@ -0,0 +1,157 @@ +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 implements List { + + private CustomLinkedList list; + + public CustomListToJavaBinding(CustomLinkedList 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 c) { + c.stream().forEach(list::add); + return true; + } + + @Override + public boolean addAll(int index, Collection 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 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 listIterator() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'listIterator'"); + } + + @Override + public ListIterator 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 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[] 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; + } + } + +}