1 /* 2 * Copyright (C) 2018 The Android Open Source Project 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 17 package com.android.dialer.spam.status; 18 19 import android.support.annotation.IntDef; 20 import com.google.auto.value.AutoValue; 21 import com.google.common.base.Optional; 22 import java.lang.annotation.Retention; 23 import java.lang.annotation.RetentionPolicy; 24 25 /** A value class representing a number's spam status in the global spam list. */ 26 @AutoValue 27 public abstract class GlobalSpamListStatus { 28 29 /** Integers representing the spam status in the global spam list. */ 30 @Retention(RetentionPolicy.SOURCE) 31 @IntDef({Status.NOT_ON_LIST, Status.ON_LIST}) 32 public @interface Status { 33 int NOT_ON_LIST = 1; 34 int ON_LIST = 2; 35 } 36 getStatus()37 public abstract @Status int getStatus(); 38 39 /** 40 * Returns the timestamp (in milliseconds) representing when a number's spam status was put on the 41 * list, or {@code Optional.absent()} if the number is not on the list. 42 */ getTimestampMillis()43 public abstract Optional<Long> getTimestampMillis(); 44 notOnList()45 public static GlobalSpamListStatus notOnList() { 46 return new AutoValue_GlobalSpamListStatus(Status.NOT_ON_LIST, Optional.absent()); 47 } 48 onList(long timestampMillis)49 public static GlobalSpamListStatus onList(long timestampMillis) { 50 return new AutoValue_GlobalSpamListStatus(Status.ON_LIST, Optional.of(timestampMillis)); 51 } 52 } 53