Mercurial > hg > Members > kono > jpf-core
annotate src/main/gov/nasa/jpf/util/PrintStreamable.java @ 19:9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
From now on, we are free to use default methods and lambdas.
added convenience Loggable and PrintStreamable interfaces that mix in the
respective fat interfaces via default methods, so that we don't have to burn
inheritance of respective target classes (they only have to provide getLogger()
and getPrintStream() methods)
added a abstract LoggablePeer so that model classes can implement Loggable with
intercepted/native logging if they provide a respective concrete peer.
added some more default interface method tests
author | Peter Mehlitz <pcmehlitz@gmail.com> |
---|---|
date | Wed, 01 Apr 2015 12:14:15 -0700 |
parents | |
children |
rev | line source |
---|---|
19
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
1 /* |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
2 * Copyright (C) 2015, United States Government, as represented by the |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
3 * Administrator of the National Aeronautics and Space Administration. |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
4 * All rights reserved. |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
5 * |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
6 * The Java Pathfinder core (jpf-core) platform is licensed under the |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
7 * Apache License, Version 2.0 (the "License"); you may not use this file except |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
8 * in compliance with the License. You may obtain a copy of the License at |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
9 * |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
10 * http://www.apache.org/licenses/LICENSE-2.0. |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
11 * |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
12 * Unless required by applicable law or agreed to in writing, software |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
13 * distributed under the License is distributed on an "AS IS" BASIS, |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
15 * See the License for the specific language governing permissions and |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
16 * limitations under the License. |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
17 */ |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
18 package gov.nasa.jpf.util; |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
19 |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
20 import java.io.PrintStream; |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
21 |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
22 /** |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
23 * convenience interface to mix in PrintStream interface |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
24 */ |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
25 public interface PrintStreamable { |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
26 |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
27 // the primitive method used by the defaults |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
28 PrintStream getPrintStream(); |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
29 |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
30 default void println() { |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
31 getPrintStream().println(); |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
32 } |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
33 |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
34 default void print(boolean a){ |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
35 getPrintStream().print(a); |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
36 } |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
37 default void print(int a){ |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
38 getPrintStream().print(a); |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
39 } |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
40 default void print(double a){ |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
41 getPrintStream().print(a); |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
42 } |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
43 default void print(String s) { |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
44 getPrintStream().print(s); |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
45 } |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
46 default void print(Object o) { |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
47 getPrintStream().print(o.toString()); |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
48 } |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
49 |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
50 default void println(boolean a){ |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
51 getPrintStream().println(a); |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
52 } |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
53 default void println(int a){ |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
54 getPrintStream().println(a); |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
55 } |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
56 default void println(double a){ |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
57 getPrintStream().println(a); |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
58 } |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
59 default void println(String s) { |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
60 getPrintStream().println(s); |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
61 } |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
62 default void println(Object o) { |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
63 getPrintStream().println(o.toString()); |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
64 } |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
65 |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
66 default void printf (String format, Object... args) { |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
67 getPrintStream().printf(format, args); |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
68 } |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
69 |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
70 //... and many more |
9fea3d8da9aa
!!! NOTE: this marks the beginning of Java 8 dependency for jpf-core compilation.
Peter Mehlitz <pcmehlitz@gmail.com>
parents:
diff
changeset
|
71 } |