Skip to content

Commit e085de2

Browse files
author
zhouj
committed
[update] 更改onjava包路径
1 parent ade1d5e commit e085de2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+204
-95
lines changed
File renamed without changes.

onjava/BasicSupplier.java renamed to onjava/onjava/BasicSupplier.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
// Visit http://OnJava8.com for more book information.
55
// Supplier from a class with a zero-argument constructor
66
package onjava;
7-
import java.util.function.*;
7+
88
import java.lang.reflect.InvocationTargetException;
9+
import java.util.function.Supplier;
910

1011
public class BasicSupplier<T> implements Supplier<T> {
1112
private Class<T> type;

onjava/CollectionMethodDifferences.java renamed to onjava/onjava/CollectionMethodDifferences.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44
// Visit http://OnJava8.com for more book information.
55
// {java onjava.CollectionMethodDifferences}
66
package onjava;
7-
import java.lang.reflect.*;
7+
8+
import java.lang.reflect.Method;
89
import java.util.*;
9-
import java.util.stream.*;
10+
import java.util.stream.Collectors;
1011

1112
public class CollectionMethodDifferences {
1213
static Set<String> methodSet(Class<?> type) {
1314
return Arrays.stream(type.getMethods())
14-
.map(Method::getName)
15-
.collect(Collectors.toCollection(TreeSet::new));
15+
.map(Method::getName)
16+
.collect(Collectors.toCollection(TreeSet::new));
1617
}
18+
1719
static void interfaces(Class<?> type) {
1820
System.out.print("Interfaces in " +
1921
type.getSimpleName() + ": ");
File renamed without changes.

onjava/Count.java renamed to onjava/onjava/Count.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,26 @@
44
// Visit http://OnJava8.com for more book information.
55
// Generate incremental values of different types
66
package onjava;
7-
import java.util.*;
8-
import java.util.function.*;
9-
import static onjava.ConvertTo.*;
7+
8+
import java.util.Arrays;
9+
import java.util.function.DoubleSupplier;
10+
import java.util.function.IntSupplier;
11+
import java.util.function.LongSupplier;
12+
import java.util.function.Supplier;
13+
14+
import static onjava.ConvertTo.primitive;
1015

1116
public interface Count {
1217
class Boolean
13-
implements Supplier<java.lang.Boolean> {
18+
implements Supplier<java.lang.Boolean> {
1419
private boolean b = true;
15-
@Override public java.lang.Boolean get() {
20+
21+
@Override
22+
public java.lang.Boolean get() {
1623
b = !b;
1724
return java.lang.Boolean.valueOf(b);
1825
}
26+
1927
public java.lang.Boolean get(int n) {
2028
return get();
2129
}

onjava/CountMap.java renamed to onjava/onjava/CountMap.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
// Unlimited-length Map containing sample data
66
// {java onjava.CountMap}
77
package onjava;
8+
89
import java.util.*;
9-
import java.util.stream.*;
10+
import java.util.stream.Collectors;
11+
import java.util.stream.IntStream;
1012

1113
public class CountMap
1214
extends AbstractMap<Integer,String> {

onjava/CountingIntegerList.java renamed to onjava/onjava/CountingIntegerList.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,24 @@
55
// List of any length, containing sample data
66
// {java onjava.CountingIntegerList}
77
package onjava;
8-
import java.util.*;
8+
9+
import java.util.AbstractList;
10+
import java.util.List;
911

1012
public class CountingIntegerList
11-
extends AbstractList<Integer> {
13+
extends AbstractList<Integer> {
1214
private int size;
13-
public CountingIntegerList() { size = 0; }
15+
16+
public CountingIntegerList() {
17+
size = 0;
18+
}
19+
1420
public CountingIntegerList(int size) {
1521
this.size = size < 0 ? 0 : size;
1622
}
17-
@Override public Integer get(int index) {
23+
24+
@Override
25+
public Integer get(int index) {
1826
return index;
1927
}
2028
@Override public int size() { return size; }
File renamed without changes.
File renamed without changes.

onjava/FillMap.java renamed to onjava/onjava/FillMap.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://OnJava8.com for more book information.
55
package onjava;
6-
import java.util.*;
7-
import java.util.function.*;
8-
import java.util.stream.*;
6+
7+
import java.util.Map;
8+
import java.util.function.Supplier;
9+
import java.util.stream.Collectors;
10+
import java.util.stream.Stream;
911

1012
public class FillMap {
11-
public static <K, V> Map<K,V>
12-
basic(Supplier<Pair<K,V>> pairGen, int size) {
13+
public static <K, V> Map<K, V>
14+
basic(Supplier<Pair<K, V>> pairGen, int size) {
1315
return Stream.generate(pairGen)
14-
.limit(size)
15-
.collect(Collectors
16-
.toMap(Pair::key, Pair::value));
16+
.limit(size)
17+
.collect(Collectors
18+
.toMap(Pair::key, Pair::value));
1719
}
18-
public static <K, V> Map<K,V>
20+
21+
public static <K, V> Map<K, V>
1922
basic(Supplier<K> keyGen,
2023
Supplier<V> valueGen, int size) {
2124
return Stream.generate(

0 commit comments

Comments
 (0)