/thirdparty/breakpad/third_party/protobuf/protobuf/java/src/main/java/com/google/protobuf/MessageOrBuilder.java

http://github.com/tomahawk-player/tomahawk · 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. package com.google.protobuf;
  31. import java.util.Map;
  32. /**
  33. * Base interface for methods common to {@link Message} and
  34. * {@link Message.Builder} to provide type equivalency.
  35. *
  36. * @author jonp@google.com (Jon Perlow)
  37. */
  38. public interface MessageOrBuilder extends MessageLiteOrBuilder {
  39. // (From MessageLite, re-declared here only for return type covariance.)
  40. //@Override (Java 1.6 override semantics, but we must support 1.5)
  41. Message getDefaultInstanceForType();
  42. /**
  43. * Get the message's type's descriptor. This differs from the
  44. * {@code getDescriptor()} method of generated message classes in that
  45. * this method is an abstract method of the {@code Message} interface
  46. * whereas {@code getDescriptor()} is a static method of a specific class.
  47. * They return the same thing.
  48. */
  49. Descriptors.Descriptor getDescriptorForType();
  50. /**
  51. * Returns a collection of all the fields in this message which are set
  52. * and their corresponding values. A singular ("required" or "optional")
  53. * field is set iff hasField() returns true for that field. A "repeated"
  54. * field is set iff getRepeatedFieldSize() is greater than zero. The
  55. * values are exactly what would be returned by calling
  56. * {@link #getField(Descriptors.FieldDescriptor)} for each field. The map
  57. * is guaranteed to be a sorted map, so iterating over it will return fields
  58. * in order by field number.
  59. * <br>
  60. * If this is for a builder, the returned map may or may not reflect future
  61. * changes to the builder. Either way, the returned map is itself
  62. * unmodifiable.
  63. */
  64. Map<Descriptors.FieldDescriptor, Object> getAllFields();
  65. /**
  66. * Returns true if the given field is set. This is exactly equivalent to
  67. * calling the generated "has" accessor method corresponding to the field.
  68. * @throws IllegalArgumentException The field is a repeated field, or
  69. * {@code field.getContainingType() != getDescriptorForType()}.
  70. */
  71. boolean hasField(Descriptors.FieldDescriptor field);
  72. /**
  73. * Obtains the value of the given field, or the default value if it is
  74. * not set. For primitive fields, the boxed primitive value is returned.
  75. * For enum fields, the EnumValueDescriptor for the value is returend. For
  76. * embedded message fields, the sub-message is returned. For repeated
  77. * fields, a java.util.List is returned.
  78. */
  79. Object getField(Descriptors.FieldDescriptor field);
  80. /**
  81. * Gets the number of elements of a repeated field. This is exactly
  82. * equivalent to calling the generated "Count" accessor method corresponding
  83. * to the field.
  84. * @throws IllegalArgumentException The field is not a repeated field, or
  85. * {@code field.getContainingType() != getDescriptorForType()}.
  86. */
  87. int getRepeatedFieldCount(Descriptors.FieldDescriptor field);
  88. /**
  89. * Gets an element of a repeated field. For primitive fields, the boxed
  90. * primitive value is returned. For enum fields, the EnumValueDescriptor
  91. * for the value is returend. For embedded message fields, the sub-message
  92. * is returned.
  93. * @throws IllegalArgumentException The field is not a repeated field, or
  94. * {@code field.getContainingType() != getDescriptorForType()}.
  95. */
  96. Object getRepeatedField(Descriptors.FieldDescriptor field, int index);
  97. /** Get the {@link UnknownFieldSet} for this message. */
  98. UnknownFieldSet getUnknownFields();
  99. }