Skip to content

Commit 0916719

Browse files
author
jmhofer
committed
added copyright text to Timestamped class, added timestamp operation, reusing mapping
1 parent 520ab9f commit 0916719

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* Copyright 2013 Netflix, 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 rx.operators;
17+
18+
import rx.Observable;
19+
import rx.Observer;
20+
import rx.Subscription;
21+
import rx.util.Timestamped;
22+
import rx.util.functions.Func1;
23+
24+
public final class OperationTimestamp {
25+
26+
/**
27+
* Accepts a sequence and adds timestamps to each item in it.
28+
*
29+
* @param sequence
30+
* the input sequence.
31+
* @param <T>
32+
* the type of the input sequence.
33+
* @return a sequence of timestamped values created by adding timestamps to each item in the input sequence.
34+
*/
35+
public static <T> Func1<Observer<Timestamped<T>>, Subscription> timestamp(Observable<T> sequence) {
36+
return OperationMap.map(sequence, new Func1<T, Timestamped<T>>() {
37+
@Override
38+
public Timestamped<T> call(T value) {
39+
return new Timestamped<T>(System.currentTimeMillis(), value);
40+
}
41+
});
42+
}
43+
}

rxjava-core/src/main/java/rx/util/Timestamped.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* Copyright 2013 Netflix, 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+
*/
116
package rx.util;
217

318
/**

0 commit comments

Comments
 (0)