Skip to content

Package: RepositoryOptimizedTrackFinder

RepositoryOptimizedTrackFinder

nameinstructionbranchcomplexitylinemethod
RepositoryOptimizedTrackFinder(Repository, Optional)
M: 0 C: 32
100%
M: 2 C: 2
50%
M: 2 C: 1
33%
M: 0 C: 3
100%
M: 0 C: 1
100%
RepositoryOptimizedTrackFinder(RepositoryOptimizedTrackFinder, Object)
M: 0 C: 40
100%
M: 2 C: 2
50%
M: 2 C: 1
33%
M: 0 C: 4
100%
M: 0 C: 1
100%
count()
M: 2 C: 17
89%
M: 2 C: 2
50%
M: 2 C: 1
33%
M: 0 C: 1
100%
M: 0 C: 1
100%
lambda$count$0()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
static {...}
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
toString()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * *********************************************************************************************************************
3: *
4: * blueMarine II: Semantic Media Centre
5: * http://tidalwave.it/projects/bluemarine2
6: *
7: * Copyright (C) 2015 - 2021 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *********************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
12: * the License. You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
17: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations under the License.
19: *
20: * *********************************************************************************************************************
21: *
22: * git clone https://bitbucket.org/tidalwave/bluemarine2-src
23: * git clone https://github.com/tidalwave-it/bluemarine2-src
24: *
25: * *********************************************************************************************************************
26: */
27: package it.tidalwave.bluemarine2.model.impl.catalog.finder;
28:
29: import javax.annotation.Nonnegative;
30: import javax.annotation.Nonnull;
31: import java.util.Optional;
32: import org.eclipse.rdf4j.repository.Repository;
33: import lombok.ToString;
34:
35: /***********************************************************************************************************************
36: *
37: * An optimised specialisation of {@link RepositoryTrackFinder} that eventually uses an optional pre-computed value for
38: * the track count.
39: *
40: * @stereotype Finder
41: *
42: * @author Fabrizio Giudici
43: *
44: **********************************************************************************************************************/
45: @ToString
46: public class RepositoryOptimizedTrackFinder extends RepositoryTrackFinder
47: {
48: private static final long serialVersionUID = -4361362680267527615L;
49:
50: @Nonnull
51: private final Optional<Integer> trackCount;
52:
53: public RepositoryOptimizedTrackFinder (@Nonnull final Repository repository,
54: @Nonnull final Optional<Integer> trackCount)
55: {
56: super(repository);
57: this.trackCount = trackCount;
58:• }
59:
60: public RepositoryOptimizedTrackFinder (@Nonnull final RepositoryOptimizedTrackFinder other,
61: @Nonnull final Object override)
62: {
63: super(other, override);
64: final RepositoryOptimizedTrackFinder source = getSource(RepositoryOptimizedTrackFinder.class, other, override);
65: this.trackCount = source.trackCount;
66:• }
67:
68: @Override @Nonnegative
69: public int count()
70: {
71: // in case other parameters are added, remember to check for them
72:• return (recordId.isPresent() && makerId.isEmpty()) ? trackCount.orElseGet(super::count) : super.count();
73: }
74: }