net.binis.codegen.spring.collection.ObservableList Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of code-generator-spring Show documentation
Show all versions of code-generator-spring Show documentation
Spring extension for Binis Code Generation
package net.binis.codegen.spring.collection;
/*-
* #%L
* code-generator-spring
* %%
* Copyright (C) 2021 - 2024 Binis Belev
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.function.UnaryOperator;
public class ObservableList implements List {
private final List list;
private final UnaryOperator onValueAdd;
public ObservableList(List list, UnaryOperator onValueAdd) {
this.list = list;
this.onValueAdd = onValueAdd;
}
@Override
public int size() {
return list.size();
}
@Override
public boolean isEmpty() {
return list.isEmpty();
}
@Override
public boolean contains(Object o) {
return list.contains(o);
}
@Override
public Iterator iterator() {
return list.iterator();
}
@Override
public Object[] toArray() {
return list.toArray();
}
@Override
public boolean add(T o) {
return list.add(onValueAdd.apply(o));
}
@Override
public boolean remove(Object o) {
return list.remove(o);
}
@SuppressWarnings("unchecked")
@Override
public boolean addAll(Collection c) {
return list.addAll(c);
}
@SuppressWarnings("unchecked")
@Override
public boolean addAll(int index, Collection c) {
return list.addAll(index, c);
}
@Override
public void clear() {
list.clear();
}
@Override
public T get(int index) {
return list.get(index);
}
@Override
public T set(int index, T element) {
return list.set(index, onValueAdd.apply(element));
}
@Override
public void add(int index, T element) {
list.add(index, onValueAdd.apply(element));
}
@Override
public T remove(int index) {
return list.remove(index);
}
@Override
public int indexOf(Object o) {
return list.indexOf(o);
}
@Override
public int lastIndexOf(Object o) {
return list.lastIndexOf(o);
}
@Override
public ListIterator listIterator() {
return list.listIterator();
}
@Override
public ListIterator listIterator(int index) {
return list.listIterator(index);
}
@Override
public List subList(int fromIndex, int toIndex) {
return list.subList(fromIndex, toIndex);
}
@Override
public boolean retainAll(Collection c) {
return list.retainAll(c);
}
@Override
public boolean removeAll(Collection c) {
return list.removeAll(c);
}
@Override
public boolean containsAll(Collection c) {
return list.containsAll(c);
}
@Override
public V[] toArray(V[] a) {
return list.toArray(a);
}
}