• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc.  All rights reserved.
3 //
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file or at
6 // https://developers.google.com/open-source/licenses/bsd
7 
8 package com.google.protobuf;
9 
10 @CheckReturnValue
11 final class NewInstanceSchemas {
12   private static final NewInstanceSchema FULL_SCHEMA = loadSchemaForFullRuntime();
13   private static final NewInstanceSchema LITE_SCHEMA = new NewInstanceSchemaLite();
14 
full()15   static NewInstanceSchema full() {
16     return FULL_SCHEMA;
17   }
18 
lite()19   static NewInstanceSchema lite() {
20     return LITE_SCHEMA;
21   }
22 
loadSchemaForFullRuntime()23   private static NewInstanceSchema loadSchemaForFullRuntime() {
24     if (Protobuf.assumeLiteRuntime) {
25       return null;
26     }
27     try {
28       Class<?> clazz = Class.forName("com.google.protobuf.NewInstanceSchemaFull");
29       return (NewInstanceSchema) clazz.getDeclaredConstructor().newInstance();
30     } catch (Exception e) {
31       return null;
32     }
33   }
34 
NewInstanceSchemas()35   private NewInstanceSchemas() {}
36 }
37