• 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 MapFieldSchemas {
12   private static final MapFieldSchema FULL_SCHEMA = loadSchemaForFullRuntime();
13   private static final MapFieldSchema LITE_SCHEMA = new MapFieldSchemaLite();
14 
full()15   static MapFieldSchema full() {
16     return FULL_SCHEMA;
17   }
18 
lite()19   static MapFieldSchema lite() {
20     return LITE_SCHEMA;
21   }
22 
loadSchemaForFullRuntime()23   private static MapFieldSchema loadSchemaForFullRuntime() {
24     if (Protobuf.assumeLiteRuntime) {
25       return null;
26     }
27     try {
28       Class<?> clazz = Class.forName("com.google.protobuf.MapFieldSchemaFull");
29       return (MapFieldSchema) clazz.getDeclaredConstructor().newInstance();
30     } catch (Exception e) {
31       return null;
32     }
33   }
34 
MapFieldSchemas()35   private MapFieldSchemas() {}
36 }
37