View Javadoc
1   /*
2    * Copyright (C) 2018 Alberto Irurueta Carro (alberto@irurueta.com)
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *         http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package com.irurueta.navigation.indoor;
17  
18  import java.io.Serializable;
19  import java.util.ArrayList;
20  import java.util.List;
21  
22  /**
23   * Contains readings from several radio sources for an unknown location
24   * to be determined.
25   *
26   * @param <S> a {@link RadioSource} type.
27   * @param <R> a {@link RssiReading} type.
28   */
29  public class Fingerprint<S extends RadioSource, R extends Reading<S>> implements Serializable {
30  
31      /**
32       * Non-located ranging and RSSI readings.
33       */
34      protected ArrayList<R> readings = new ArrayList<>();
35  
36      /**
37       * Constructor.
38       */
39      public Fingerprint() {
40      }
41  
42      /**
43       * Constructor.
44       *
45       * @param readings non-located readings.
46       * @throws IllegalArgumentException if provided readings is null.
47       */
48      public Fingerprint(final List<R> readings) {
49          if (readings == null) {
50              throw new IllegalArgumentException();
51          }
52          this.readings = new ArrayList<>(readings);
53      }
54  
55      /**
56       * Gets non-located ranging readings.
57       *
58       * @return non-located ranging readings.
59       */
60      public List<R> getReadings() {
61          return readings;
62      }
63  
64      /**
65       * Sets non-located ranging readings.
66       *
67       * @param readings non-located ranging readings.
68       * @throws IllegalArgumentException if provided readings is null.
69       */
70      public void setReadings(final List<R> readings) {
71          if (readings == null) {
72              throw new IllegalArgumentException();
73          }
74          this.readings = new ArrayList<>(readings);
75      }
76  }