001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.commons.collections.primitives.adapters;
018
019 import java.io.Serializable;
020 import java.util.List;
021
022 import org.apache.commons.collections.primitives.LongList;
023
024 /**
025 * Adapts a {@link Number}-valued {@link List List}
026 * to the {@link LongList LongList} interface.
027 * <p />
028 * This implementation delegates most methods
029 * to the provided {@link List List}
030 * implementation in the "obvious" way.
031 *
032 * @since Commons Primitives 1.0
033 * @version $Revision: 480462 $ $Date: 2006-11-29 09:15:00 +0100 (Wed, 29 Nov 2006) $
034 * @author Rodney Waldhoff
035 */
036 public class ListLongList extends AbstractListLongList implements Serializable {
037
038 /**
039 * Create an {@link LongList LongList} wrapping
040 * the specified {@link List List}. When
041 * the given <i>list</i> is <code>null</code>,
042 * returns <code>null</code>.
043 *
044 * @param list the (possibly <code>null</code>)
045 * {@link List List} to wrap
046 * @return a {@link LongList LongList} wrapping the given
047 * <i>list</i>, or <code>null</code> when <i>list</i> is
048 * <code>null</code>.
049 */
050 public static LongList wrap(List list) {
051 if(null == list) {
052 return null;
053 } else if(list instanceof Serializable) {
054 return new ListLongList(list);
055 } else {
056 return new NonSerializableListLongList(list);
057 }
058 }
059
060 /**
061 * Creates an {@link LongList LongList} wrapping
062 * the specified {@link List List}.
063 * @see #wrap
064 */
065 public ListLongList(List list) {
066 _list = list;
067 }
068
069 protected List getList() {
070 return _list;
071 }
072
073 private List _list = null;
074
075 }