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 import java.lang.reflect.Field; 11 12 /** Information for a oneof within a protobuf message. */ 13 // TODO: make this private once all of experimental code is migrated to protobuf. 14 @ExperimentalApi 15 @CheckReturnValue 16 final class OneofInfo { 17 private final int id; 18 private final Field caseField; 19 private final Field valueField; 20 OneofInfo(int id, Field caseField, Field valueField)21 public OneofInfo(int id, Field caseField, Field valueField) { 22 this.id = id; 23 this.caseField = caseField; 24 this.valueField = valueField; 25 } 26 27 /** 28 * Returns the unique identifier of the oneof within the message. This is really just an index 29 * starting at zero. 30 */ getId()31 public int getId() { 32 return id; 33 } 34 35 /** The {@code int} field containing the field number of the currently active member. */ getCaseField()36 public Field getCaseField() { 37 return caseField; 38 } 39 40 /** The {@link Object} field containing the value of the currently active member. */ getValueField()41 public Field getValueField() { 42 return valueField; 43 } 44 } 45