Upstream version 10.38.222.0
[platform/framework/web/crosswalk.git] / src / third_party / cacheinvalidation / src / java / com / google / ipc / invalidation / common / TrickleState.java
1 /*
2  * Copyright 2011 Google Inc.
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.google.ipc.invalidation.common;
17
18 import com.google.protos.ipc.invalidation.ClientProtocol.InvalidationP;
19
20 /**
21  * Enumeration describing whether an invalidation restarts its trickle.
22  *
23  */
24 public enum TrickleState {
25   /** The trickle is restarting; that is, past versions may have been dropped. */
26   RESTART,   
27   /** The trickle is not restarting. */
28   CONTINUE;  
29
30   /** Returns RESTART if {@code isTrickleRestart} is true, CONTINUE otherwise. */
31   public static TrickleState fromBoolean(boolean isTrickleRestart) {
32     return isTrickleRestart ? RESTART : CONTINUE;
33   }
34
35   /** Returns a TrickleState based on the value of {@code invalidation.is_trickle_restart}. */
36   public static TrickleState fromInvalidation(InvalidationP invalidation) {
37     return TrickleState.fromBoolean(invalidation.getIsTrickleRestart());
38   }
39 }