1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
23 import java.util.UUID;
27 * TODO: Consider including Attachment like java.nio.CompletionHandler
31 public class OCObserver<T> implements Comparable<OCObserver<T>> {
32 private static UUID observerId = UUID.randomUUID();
36 * The OC service calls this at intervals n until the expired callback occurs.
39 public void onChanged(T data) {}
42 * Called if a failure occurred. No more events will occur after this is callback.
44 * @param throwable - The error that caused this callback sequence to fail.
46 public void onFailed(Throwable throwable) {}
49 public int compareTo(OCObserver<T> another) {
50 return observerId.compareTo(another.getObserverId());
55 * @return observerId associated with this OCObserver object.
57 UUID getObserverId() {