Skip to content

Package: ArrayListFinder

ArrayListFinder

nameinstructionbranchcomplexitylinemethod
ArrayListFinder(ArrayListFinder, Object)
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
ArrayListFinder(Collection)
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
computeResults()
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * #%L
3: * *********************************************************************************************************************
4: *
5: * These Foolish Things - Miscellaneous utilities
6: * http://thesefoolishthings.tidalwave.it - git clone git@bitbucket.org:tidalwave/thesefoolishthings-src.git
7: * %%
8: * Copyright (C) 2009 - 2018 Tidalwave s.a.s. (http://tidalwave.it)
9: * %%
10: * *********************************************************************************************************************
11: *
12: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
13: * the License. You may obtain a copy of the License at
14: *
15: * http://www.apache.org/licenses/LICENSE-2.0
16: *
17: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
18: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
19: * specific language governing permissions and limitations under the License.
20: *
21: * *********************************************************************************************************************
22: *
23: * $Id$
24: *
25: * *********************************************************************************************************************
26: * #L%
27: */
28: package it.tidalwave.util.spi;
29:
30: import javax.annotation.Nonnull;
31: import java.util.ArrayList;
32: import java.util.Collection;
33: import java.util.Collections;
34: import java.util.List;
35: import java.util.concurrent.CopyOnWriteArrayList;
36:
37: /***********************************************************************************************************************
38: *
39: * An implementation of {@link Finder} which holds an immutable list of items.
40: *
41: * @param <T> the type of contained items
42: *
43: * @author Fabrizio Giudici (Fabrizio.Giudici@tidalwave.it)
44: * @version $Id: Class.java,v 631568052e17 2013/02/19 15:45:02 fabrizio $
45: *
46: **********************************************************************************************************************/
47: public class ArrayListFinder<T> extends SimpleFinderSupport<T>
48: {
49: private static final long serialVersionUID = -3529114277448372453L;
50:
51: @Nonnull
52: private final Collection<T> items;
53:
54: public ArrayListFinder (final @Nonnull Collection<T> items)
55: {
56: this.items = Collections.unmodifiableCollection(new ArrayList<>(items));
57: }
58:
59: public ArrayListFinder (final @Nonnull ArrayListFinder<T> other, @Nonnull Object override)
60: {
61: super(other, override);
62: final ArrayListFinder<T> source = getSource(ArrayListFinder.class, other, override);
63: this.items = source.items;
64: }
65:
66: @Override @Nonnull
67: protected List<? extends T> computeResults()
68: {
69: return new CopyOnWriteArrayList<>(items);
70: }
71: }