33import java .io .*;
44import java .net .URL ;
55import java .nio .charset .Charset ;
6+ import java .util .Objects ;
67
78import com .squareup .protoparser .ProtoFile ;
89import com .squareup .protoparser .ProtoParser ;
@@ -40,27 +41,27 @@ public ProtobufSchemaLoader() { }
4041 */
4142
4243 public ProtobufSchema load (URL url ) throws IOException {
43- return loadNative (url ).forFirstType ();
44+ return loadNative (Objects . requireNonNull ( url ) ).forFirstType ();
4445 }
4546
4647 /**
4748 * @param rootTypeName Name of message type in schema definition that is
4849 * the root value to read/write
4950 */
5051 public ProtobufSchema load (URL url , String rootTypeName ) throws IOException {
51- return loadNative (url ).forType (rootTypeName );
52+ return loadNative (Objects . requireNonNull ( url ) ).forType (rootTypeName );
5253 }
5354
5455 public ProtobufSchema load (File f ) throws IOException {
55- return loadNative (f ).forFirstType ();
56+ return loadNative (Objects . requireNonNull ( f ) ).forFirstType ();
5657 }
5758
5859 /**
5960 * @param rootTypeName Name of message type in schema definition that is
6061 * the root value to read/write
6162 */
6263 public ProtobufSchema load (File f , String rootTypeName ) throws IOException {
63- return loadNative (f ).forType (rootTypeName );
64+ return loadNative (Objects . requireNonNull ( f ) ).forType (rootTypeName );
6465 }
6566
6667 /**
@@ -69,15 +70,15 @@ public ProtobufSchema load(File f, String rootTypeName) throws IOException {
6970 * Note that given {@link InputStream} will be closed before method returns.
7071 */
7172 public ProtobufSchema load (InputStream in ) throws IOException {
72- return loadNative (in , true ).forFirstType ();
73+ return loadNative (Objects . requireNonNull ( in ) , true ).forFirstType ();
7374 }
7475
7576 /**
7677 * @param rootTypeName Name of message type in schema definition that is
7778 * the root value to read/write
7879 */
7980 public ProtobufSchema load (InputStream in , String rootTypeName ) throws IOException {
80- return loadNative (in , true ).forType (rootTypeName );
81+ return loadNative (Objects . requireNonNull ( in ) , true ).forType (rootTypeName );
8182 }
8283
8384 /**
@@ -86,15 +87,15 @@ public ProtobufSchema load(InputStream in, String rootTypeName) throws IOExcepti
8687 * Note that given {@link Reader} will be closed before method returns.
8788 */
8889 public ProtobufSchema load (Reader r ) throws IOException {
89- return loadNative (r , true ).forFirstType ();
90+ return loadNative (Objects . requireNonNull ( r ) , true ).forFirstType ();
9091 }
9192
9293 /**
9394 * @param rootTypeName Name of message type in schema definition that is
9495 * the root value to read/write
9596 */
9697 public ProtobufSchema load (Reader r , String rootTypeName ) throws IOException {
97- return loadNative (r , true ).forType (rootTypeName );
98+ return loadNative (Objects . requireNonNull ( r ) , true ).forType (rootTypeName );
9899 }
99100
100101 /**
@@ -120,22 +121,27 @@ public ProtobufSchema parse(String schemaAsString, String rootTypeName) throws I
120121 */
121122
122123 public NativeProtobufSchema loadNative (File f ) throws IOException {
124+ Objects .requireNonNull (f );
123125 return NativeProtobufSchema .construct (_loadNative (f ));
124126 }
125127
126128 public NativeProtobufSchema loadNative (URL url ) throws IOException {
129+ Objects .requireNonNull (url );
127130 return NativeProtobufSchema .construct (_loadNative (url ));
128131 }
129132
130133 public NativeProtobufSchema parseNative (String schema ) throws IOException {
134+ Objects .requireNonNull (schema );
131135 return NativeProtobufSchema .construct (_loadNative (schema ));
132136 }
133137
134138 public NativeProtobufSchema loadNative (InputStream in , boolean close ) throws IOException {
139+ Objects .requireNonNull (in );
135140 return NativeProtobufSchema .construct (_loadNative (in , close ));
136141 }
137142
138143 protected NativeProtobufSchema loadNative (Reader r , boolean close ) throws IOException {
144+ Objects .requireNonNull (r );
139145 return NativeProtobufSchema .construct (_loadNative (r , close ));
140146 }
141147
0 commit comments