X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.utils.datastructures%2Fsrc%2Forg%2Fsimantics%2Futils%2Fdatastructures%2FListAdapter.java;h=40ff697c7048ce64f2553038538974cfb71b10e3;hb=84b52b5e5dc00fd0ddfab398e420b56b379ee867;hp=815620d1b789834aed189b260524fc25ca76ae49;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/ListAdapter.java b/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/ListAdapter.java index 815620d1b..40ff697c7 100644 --- a/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/ListAdapter.java +++ b/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/ListAdapter.java @@ -1,81 +1,81 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.utils.datastructures; - -import java.util.Collection; -import java.util.List; -import java.util.ListIterator; - -public class ListAdapter> - extends CollectionAdapter - implements List { - - public ListAdapter(Converter converter, C collection) { - super(converter, collection); - } - - @Override - public void add(int index, Range element) { - collection.add(index, converter.convertFrom(element)); - } - - @SuppressWarnings("unchecked") - @Override - public boolean addAll(int index, Collection c) { - return collection.addAll(index, new CollectionAdapter>(inverseConverter(converter), (Collection)c)); - } - - @Override - public Range get(int index) { - return converter.convertTo(collection.get(index)); - } - - @SuppressWarnings("unchecked") - @Override - public int indexOf(Object o) { - return collection.indexOf(converter.convertFrom((Range)o)); - } - - @SuppressWarnings("unchecked") - @Override - public int lastIndexOf(Object o) { - return collection.lastIndexOf(converter.convertFrom((Range)o)); - } - - @Override - public ListIterator listIterator() { - return new ListIteratorAdapter> - (converter, collection.listIterator()); - } - - @Override - public ListIterator listIterator(int index) { - return new ListIteratorAdapter> - (converter, collection.listIterator(index)); - } - - @Override - public Range remove(int index) { - return converter.convertTo(collection.remove(index)); - } - - @Override - public Range set(int index, Range element) { - return converter.convertTo(collection.set(index, converter.convertFrom(element))); - } - - @Override - public List subList(int fromIndex, int toIndex) { - return new ListAdapter>(converter, collection.subList(fromIndex, toIndex)); - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.utils.datastructures; + +import java.util.Collection; +import java.util.List; +import java.util.ListIterator; + +public class ListAdapter> + extends CollectionAdapter + implements List { + + public ListAdapter(Converter converter, C collection) { + super(converter, collection); + } + + @Override + public void add(int index, Range element) { + collection.add(index, converter.convertFrom(element)); + } + + @SuppressWarnings("unchecked") + @Override + public boolean addAll(int index, Collection c) { + return collection.addAll(index, new CollectionAdapter>(inverseConverter(converter), (Collection)c)); + } + + @Override + public Range get(int index) { + return converter.convertTo(collection.get(index)); + } + + @SuppressWarnings("unchecked") + @Override + public int indexOf(Object o) { + return collection.indexOf(converter.convertFrom((Range)o)); + } + + @SuppressWarnings("unchecked") + @Override + public int lastIndexOf(Object o) { + return collection.lastIndexOf(converter.convertFrom((Range)o)); + } + + @Override + public ListIterator listIterator() { + return new ListIteratorAdapter> + (converter, collection.listIterator()); + } + + @Override + public ListIterator listIterator(int index) { + return new ListIteratorAdapter> + (converter, collection.listIterator(index)); + } + + @Override + public Range remove(int index) { + return converter.convertTo(collection.remove(index)); + } + + @Override + public Range set(int index, Range element) { + return converter.convertTo(collection.set(index, converter.convertFrom(element))); + } + + @Override + public List subList(int fromIndex, int toIndex) { + return new ListAdapter>(converter, collection.subList(fromIndex, toIndex)); + } + +}