/thirdparty/breakpad/third_party/protobuf/protobuf/java/src/main/java/com/google/protobuf/MessageOrBuilder.java
Java | 110 lines | 12 code | 11 blank | 87 comment | 0 complexity | 614c6ede0056ed9cebb8793d1cd74b98 MD5 | raw file
1// Protocol Buffers - Google's data interchange format 2// Copyright 2008 Google Inc. All rights reserved. 3// http://code.google.com/p/protobuf/ 4// 5// Redistribution and use in source and binary forms, with or without 6// modification, are permitted provided that the following conditions are 7// met: 8// 9// * Redistributions of source code must retain the above copyright 10// notice, this list of conditions and the following disclaimer. 11// * Redistributions in binary form must reproduce the above 12// copyright notice, this list of conditions and the following disclaimer 13// in the documentation and/or other materials provided with the 14// distribution. 15// * Neither the name of Google Inc. nor the names of its 16// contributors may be used to endorse or promote products derived from 17// this software without specific prior written permission. 18// 19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 31package com.google.protobuf; 32 33import java.util.Map; 34 35/** 36 * Base interface for methods common to {@link Message} and 37 * {@link Message.Builder} to provide type equivalency. 38 * 39 * @author jonp@google.com (Jon Perlow) 40 */ 41public interface MessageOrBuilder extends MessageLiteOrBuilder { 42 43 // (From MessageLite, re-declared here only for return type covariance.) 44 //@Override (Java 1.6 override semantics, but we must support 1.5) 45 Message getDefaultInstanceForType(); 46 47 /** 48 * Get the message's type's descriptor. This differs from the 49 * {@code getDescriptor()} method of generated message classes in that 50 * this method is an abstract method of the {@code Message} interface 51 * whereas {@code getDescriptor()} is a static method of a specific class. 52 * They return the same thing. 53 */ 54 Descriptors.Descriptor getDescriptorForType(); 55 56 /** 57 * Returns a collection of all the fields in this message which are set 58 * and their corresponding values. A singular ("required" or "optional") 59 * field is set iff hasField() returns true for that field. A "repeated" 60 * field is set iff getRepeatedFieldSize() is greater than zero. The 61 * values are exactly what would be returned by calling 62 * {@link #getField(Descriptors.FieldDescriptor)} for each field. The map 63 * is guaranteed to be a sorted map, so iterating over it will return fields 64 * in order by field number. 65 * <br> 66 * If this is for a builder, the returned map may or may not reflect future 67 * changes to the builder. Either way, the returned map is itself 68 * unmodifiable. 69 */ 70 Map<Descriptors.FieldDescriptor, Object> getAllFields(); 71 72 /** 73 * Returns true if the given field is set. This is exactly equivalent to 74 * calling the generated "has" accessor method corresponding to the field. 75 * @throws IllegalArgumentException The field is a repeated field, or 76 * {@code field.getContainingType() != getDescriptorForType()}. 77 */ 78 boolean hasField(Descriptors.FieldDescriptor field); 79 80 /** 81 * Obtains the value of the given field, or the default value if it is 82 * not set. For primitive fields, the boxed primitive value is returned. 83 * For enum fields, the EnumValueDescriptor for the value is returend. For 84 * embedded message fields, the sub-message is returned. For repeated 85 * fields, a java.util.List is returned. 86 */ 87 Object getField(Descriptors.FieldDescriptor field); 88 89 /** 90 * Gets the number of elements of a repeated field. This is exactly 91 * equivalent to calling the generated "Count" accessor method corresponding 92 * to the field. 93 * @throws IllegalArgumentException The field is not a repeated field, or 94 * {@code field.getContainingType() != getDescriptorForType()}. 95 */ 96 int getRepeatedFieldCount(Descriptors.FieldDescriptor field); 97 98 /** 99 * Gets an element of a repeated field. For primitive fields, the boxed 100 * primitive value is returned. For enum fields, the EnumValueDescriptor 101 * for the value is returend. For embedded message fields, the sub-message 102 * is returned. 103 * @throws IllegalArgumentException The field is not a repeated field, or 104 * {@code field.getContainingType() != getDescriptorForType()}. 105 */ 106 Object getRepeatedField(Descriptors.FieldDescriptor field, int index); 107 108 /** Get the {@link UnknownFieldSet} for this message. */ 109 UnknownFieldSet getUnknownFields(); 110}