Skip to content

Commit 948896a

Browse files
authored
Move Validators classes to its own package. (#2523)
1 parent 5efbe5f commit 948896a

14 files changed

+65
-35
lines changed

firebase-perf/src/main/java/com/google/firebase/perf/FirebasePerformance.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
import com.google.firebase.perf.config.ConfigResolver;
3232
import com.google.firebase.perf.config.RemoteConfigManager;
3333
import com.google.firebase.perf.internal.GaugeManager;
34-
import com.google.firebase.perf.internal.PerfMetricValidator;
3534
import com.google.firebase.perf.logging.AndroidLogger;
3635
import com.google.firebase.perf.metrics.HttpMetric;
3736
import com.google.firebase.perf.metrics.Trace;
37+
import com.google.firebase.perf.metrics.validator.PerfMetricValidator;
3838
import com.google.firebase.perf.transport.TransportManager;
3939
import com.google.firebase.perf.util.Constants;
4040
import com.google.firebase.perf.util.ImmutableBundle;

firebase-perf/src/main/java/com/google/firebase/perf/metrics/HttpMetric.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
import com.google.firebase.perf.FirebasePerformanceAttributable;
2121
import com.google.firebase.perf.config.ConfigResolver;
2222
import com.google.firebase.perf.impl.NetworkRequestMetricBuilder;
23-
import com.google.firebase.perf.internal.PerfMetricValidator;
2423
import com.google.firebase.perf.logging.AndroidLogger;
24+
import com.google.firebase.perf.metrics.validator.PerfMetricValidator;
2525
import com.google.firebase.perf.transport.TransportManager;
2626
import com.google.firebase.perf.util.Constants;
2727
import com.google.firebase.perf.util.Timer;

firebase-perf/src/main/java/com/google/firebase/perf/metrics/Trace.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
import com.google.firebase.perf.internal.AppStateMonitor;
2626
import com.google.firebase.perf.internal.AppStateUpdateHandler;
2727
import com.google.firebase.perf.internal.GaugeManager;
28-
import com.google.firebase.perf.internal.PerfMetricValidator;
2928
import com.google.firebase.perf.internal.PerfSession;
3029
import com.google.firebase.perf.internal.SessionAwareObject;
3130
import com.google.firebase.perf.internal.SessionManager;
3231
import com.google.firebase.perf.logging.AndroidLogger;
32+
import com.google.firebase.perf.metrics.validator.PerfMetricValidator;
3333
import com.google.firebase.perf.transport.TransportManager;
3434
import com.google.firebase.perf.util.Clock;
3535
import com.google.firebase.perf.util.Constants;

firebase-perf/src/main/java/com/google/firebase/perf/internal/FirebasePerfApplicationInfoValidator.java renamed to firebase-perf/src/main/java/com/google/firebase/perf/metrics/validator/FirebasePerfApplicationInfoValidator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// Copyright 2020 Google LLC
1+
// Copyright 2021 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
5-
//
65
// You may obtain a copy of the License at
6+
//
77
// http://www.apache.org/licenses/LICENSE-2.0
88
//
99
// Unless required by applicable law or agreed to in writing, software
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package com.google.firebase.perf.internal;
15+
package com.google.firebase.perf.metrics.validator;
1616

1717
import com.google.firebase.perf.logging.AndroidLogger;
1818
import com.google.firebase.perf.v1.ApplicationInfo;

firebase-perf/src/main/java/com/google/firebase/perf/internal/FirebasePerfGaugeMetricValidator.java renamed to firebase-perf/src/main/java/com/google/firebase/perf/metrics/validator/FirebasePerfGaugeMetricValidator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// Copyright 2020 Google LLC
1+
// Copyright 2021 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
5-
//
65
// You may obtain a copy of the License at
6+
//
77
// http://www.apache.org/licenses/LICENSE-2.0
88
//
99
// Unless required by applicable law or agreed to in writing, software
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package com.google.firebase.perf.internal;
15+
package com.google.firebase.perf.metrics.validator;
1616

1717
import com.google.firebase.perf.v1.GaugeMetric;
1818
import com.google.firebase.perf.v1.PerfMetric;

firebase-perf/src/main/java/com/google/firebase/perf/internal/FirebasePerfNetworkValidator.java renamed to firebase-perf/src/main/java/com/google/firebase/perf/metrics/validator/FirebasePerfNetworkValidator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// Copyright 2020 Google LLC
1+
// Copyright 2021 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
5-
//
65
// You may obtain a copy of the License at
6+
//
77
// http://www.apache.org/licenses/LICENSE-2.0
88
//
99
// Unless required by applicable law or agreed to in writing, software
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package com.google.firebase.perf.internal;
15+
package com.google.firebase.perf.metrics.validator;
1616

1717
import android.content.Context;
1818
import androidx.annotation.NonNull;

firebase-perf/src/main/java/com/google/firebase/perf/internal/FirebasePerfTraceValidator.java renamed to firebase-perf/src/main/java/com/google/firebase/perf/metrics/validator/FirebasePerfTraceValidator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// Copyright 2020 Google LLC
1+
// Copyright 2021 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
5-
//
65
// You may obtain a copy of the License at
6+
//
77
// http://www.apache.org/licenses/LICENSE-2.0
88
//
99
// Unless required by applicable law or agreed to in writing, software
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package com.google.firebase.perf.internal;
15+
package com.google.firebase.perf.metrics.validator;
1616

1717
import androidx.annotation.NonNull;
1818
import androidx.annotation.Nullable;

firebase-perf/src/main/java/com/google/firebase/perf/internal/PerfMetricValidator.java renamed to firebase-perf/src/main/java/com/google/firebase/perf/metrics/validator/PerfMetricValidator.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// Copyright 2020 Google LLC
1+
// Copyright 2021 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
5-
//
65
// You may obtain a copy of the License at
6+
//
77
// http://www.apache.org/licenses/LICENSE-2.0
88
//
99
// Unless required by applicable law or agreed to in writing, software
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package com.google.firebase.perf.internal;
15+
package com.google.firebase.perf.metrics.validator;
1616

1717
import android.content.Context;
1818
import androidx.annotation.NonNull;
@@ -83,6 +83,7 @@ public static boolean isValid(@NonNull PerfMetric perfMetric, @NonNull Context c
8383
* @return null if the string can be used as Trace name, if not, an error string explaining why it
8484
* can't be used.
8585
*/
86+
@Nullable
8687
public static String validateTraceName(@Nullable String str) {
8788
if (str == null) {
8889
return "Trace name must not be null";
@@ -112,6 +113,7 @@ public static String validateTraceName(@Nullable String str) {
112113
* @return null if the string can be used as Counter name, if not, an error string explaining why
113114
* it can't be used.
114115
*/
116+
@Nullable
115117
public static String validateMetricName(@Nullable String str) {
116118
if (str == null) {
117119
return "Metric name must not be null";
@@ -137,6 +139,7 @@ public static String validateMetricName(@Nullable String str) {
137139
* @return null if the entry can be used as an Attribute, if not, an error string explaining why
138140
* it can't be used.
139141
*/
142+
@Nullable
140143
public static String validateAttribute(@NonNull Map.Entry<String, String> attribute) {
141144
String key = attribute.getKey();
142145
String value = attribute.getValue();
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
/** @hide */
16+
/** @hide */
17+
package com.google.firebase.perf.metrics.validator;
18+

firebase-perf/src/main/java/com/google/firebase/perf/transport/TransportManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
import com.google.firebase.perf.config.ConfigResolver;
3535
import com.google.firebase.perf.internal.AppStateMonitor;
3636
import com.google.firebase.perf.internal.AppStateMonitor.AppStateCallback;
37-
import com.google.firebase.perf.internal.PerfMetricValidator;
3837
import com.google.firebase.perf.internal.SessionManager;
3938
import com.google.firebase.perf.logging.AndroidLogger;
39+
import com.google.firebase.perf.metrics.validator.PerfMetricValidator;
4040
import com.google.firebase.perf.util.Constants;
4141
import com.google.firebase.perf.util.Constants.CounterNames;
4242
import com.google.firebase.perf.v1.AndroidApplicationInfo;

firebase-perf/src/test/java/com/google/firebase/perf/internal/FirebasePerfApplicationInfoValidatorTest.java renamed to firebase-perf/src/test/java/com/google/firebase/perf/metrics/validator/FirebasePerfApplicationInfoValidatorTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// Copyright 2020 Google LLC
1+
// Copyright 2021 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
5-
//
65
// You may obtain a copy of the License at
6+
//
77
// http://www.apache.org/licenses/LICENSE-2.0
88
//
99
// Unless required by applicable law or agreed to in writing, software
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package com.google.firebase.perf.internal;
15+
package com.google.firebase.perf.metrics.validator;
1616

1717
import static com.google.common.truth.Truth.assertThat;
1818

@@ -23,7 +23,10 @@
2323
import org.junit.runner.RunWith;
2424
import org.robolectric.RobolectricTestRunner;
2525

26-
/** Unit tests for {@link FirebasePerfApplicationInfoValidator}. */
26+
/**
27+
* Unit tests for {@link
28+
* com.google.firebase.perf.metrics.validator.FirebasePerfApplicationInfoValidator}.
29+
*/
2730
@RunWith(RobolectricTestRunner.class)
2831
public class FirebasePerfApplicationInfoValidatorTest {
2932
@Test

firebase-perf/src/test/java/com/google/firebase/perf/internal/FirebasePerfGaugeManagerValidatorTest.java renamed to firebase-perf/src/test/java/com/google/firebase/perf/metrics/validator/FirebasePerfGaugeManagerValidatorTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// Copyright 2020 Google LLC
1+
// Copyright 2021 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
5-
//
65
// You may obtain a copy of the License at
6+
//
77
// http://www.apache.org/licenses/LICENSE-2.0
88
//
99
// Unless required by applicable law or agreed to in writing, software
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package com.google.firebase.perf.internal;
15+
package com.google.firebase.perf.metrics.validator;
1616

1717
import static com.google.common.truth.Truth.assertThat;
1818

@@ -27,7 +27,10 @@
2727
import org.junit.runner.RunWith;
2828
import org.robolectric.RobolectricTestRunner;
2929

30-
/** Unit tests for {@link com.google.firebase.perf.internal.FirebasePerfGaugeMetricValidator}. */
30+
/**
31+
* Unit tests for {@link
32+
* com.google.firebase.perf.metrics.validator.FirebasePerfGaugeMetricValidator}.
33+
*/
3134
@RunWith(RobolectricTestRunner.class)
3235
public final class FirebasePerfGaugeManagerValidatorTest {
3336

firebase-perf/src/test/java/com/google/firebase/perf/internal/FirebasePerfNetworkValidatorTest.java renamed to firebase-perf/src/test/java/com/google/firebase/perf/metrics/validator/FirebasePerfNetworkValidatorTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// Copyright 2020 Google LLC
1+
// Copyright 2021 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
5-
//
65
// You may obtain a copy of the License at
6+
//
77
// http://www.apache.org/licenses/LICENSE-2.0
88
//
99
// Unless required by applicable law or agreed to in writing, software
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package com.google.firebase.perf.internal;
15+
package com.google.firebase.perf.metrics.validator;
1616

1717
import static com.google.common.truth.Truth.assertThat;
1818
import static org.junit.Assert.assertFalse;
@@ -29,7 +29,9 @@
2929
import org.robolectric.RobolectricTestRunner;
3030
import org.robolectric.RuntimeEnvironment;
3131

32-
/** Unit tests for {@link FirebasePerfNetworkValidator}. */
32+
/**
33+
* Unit tests for {@link com.google.firebase.perf.metrics.validator.FirebasePerfNetworkValidator}.
34+
*/
3335
@RunWith(RobolectricTestRunner.class)
3436
public class FirebasePerfNetworkValidatorTest extends FirebasePerformanceTestBase {
3537
private final FirebasePerfNetworkValidator validator =

firebase-perf/src/test/java/com/google/firebase/perf/internal/FirebasePerfTraceValidatorTest.java renamed to firebase-perf/src/test/java/com/google/firebase/perf/metrics/validator/FirebasePerfTraceValidatorTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// Copyright 2020 Google LLC
1+
// Copyright 2021 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
5-
//
65
// You may obtain a copy of the License at
6+
//
77
// http://www.apache.org/licenses/LICENSE-2.0
88
//
99
// Unless required by applicable law or agreed to in writing, software
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package com.google.firebase.perf.internal;
15+
package com.google.firebase.perf.metrics.validator;
1616

1717
import static com.google.common.truth.Truth.assertThat;
1818
import static org.mockito.Mockito.doAnswer;
@@ -21,6 +21,7 @@
2121
import static org.mockito.MockitoAnnotations.initMocks;
2222

2323
import com.google.firebase.perf.FirebasePerformanceTestBase;
24+
import com.google.firebase.perf.internal.AppStateMonitor;
2425
import com.google.firebase.perf.metrics.Trace;
2526
import com.google.firebase.perf.transport.TransportManager;
2627
import com.google.firebase.perf.util.Clock;
@@ -38,7 +39,7 @@
3839
import org.mockito.stubbing.Answer;
3940
import org.robolectric.RobolectricTestRunner;
4041

41-
/** Unit tests for {@link FirebasePerfTraceValidator}. */
42+
/** Unit tests for {@link com.google.firebase.perf.metrics.validator.FirebasePerfTraceValidator}. */
4243
@RunWith(RobolectricTestRunner.class)
4344
public class FirebasePerfTraceValidatorTest extends FirebasePerformanceTestBase {
4445

0 commit comments

Comments
 (0)