Package com.google.protobuf.Descriptors

Examples of com.google.protobuf.Descriptors.FieldDescriptor


        }
        return keyField;
    }

    protected FieldDescriptor getIdField(GeneratedMessage.Builder template) {
        FieldDescriptor idField = null;
        if (idFieldNumber != null) {
            idField = template.getDescriptorForType().findFieldByNumber(idFieldNumber);
        } else {
            throw new IllegalArgumentException();
        }
View Full Code Here


        @Override
        public NumberedItemCollection<T> create() {
            Codec codec = null;

            FieldDescriptor idField = getIdField(template);

            FieldDescriptor keyField = getKeyField();

            return new NumberedItemCollection(parentNode, codec, template, idField, keyField);
        }
View Full Code Here

        }
        return itemState.hasDeletedAt();
    }

    public static <T extends GeneratedMessage> ItemStateData getItemState(T msg) {
        FieldDescriptor field = findItemStateField(msg.getDescriptorForType());
        if (field == null) {
            return null;
        }
        try {
            return (ItemStateData) msg.getField(field);
View Full Code Here

    public static <T extends GeneratedMessage> T markDeleted(NumberedItemCollection<T> store, T msg)
            throws CloudException {
        Message.Builder builder = ProtobufUtils.newBuilder(msg.getClass());
        builder.mergeFrom(msg);

        FieldDescriptor field = findItemStateField(msg.getDescriptorForType());
        if (field == null) {
            throw new IllegalStateException();
        }

        ItemStateData itemStateData;
View Full Code Here

            this.descriptor = descriptor;
        }

        public synchronized Optional<FieldDescriptor> getItemStateField() {
            if (itemStateField == null) {
                FieldDescriptor found = null;
                for (FieldDescriptor field : descriptor.getFields()) {
                    if (field.getType() != Type.MESSAGE) {
                        continue;
                    }
View Full Code Here

            throw new UnsupportedOperationException();
        }

        @Override
        public NamedItemCollection<T> create() {
            FieldDescriptor idField = getIdField(template);
            if (idField.getType() != Type.STRING) {
                throw new IllegalArgumentException();
            }

            if (keyFieldNumber != null) {
                throw new IllegalArgumentException();
View Full Code Here

        }

        Set<String> allowed = Sets.newHashSet("is_public", "name", "attributes", "is_protected");

        for (Entry<FieldDescriptor, Object> entry : changes.getAllFields().entrySet()) {
            FieldDescriptor field = entry.getKey();
            String key = field.getName();

            if (!allowed.contains(key)) {
                Object existing = i.getData().getField(field);
                if (!Objects.equal(existing, entry.getValue())) {
                    log.warn("Attempt to update blocked field: " + key);
View Full Code Here

  }

  @Override
  protected void setField(Object r, String n, int pos, Object o, Object state) {
    Builder b = (Builder)r;
    FieldDescriptor f = ((FieldDescriptor[])state)[pos];
    switch (f.getType()) {
    case ENUM:
      b.setField(f, ((ProtocolMessageEnum)o).getValueDescriptor());
      break;
    case MESSAGE:
      if (o == null) {
View Full Code Here

  }

  @Override
  protected Object getField(Object record, String name, int pos, Object state) {
    Message m = (Message)record;
    FieldDescriptor f = ((FieldDescriptor[])state)[pos];
    switch (f.getType()) {
    case ENUM:
      Schema s = getSchema(f);
      try {
        Class c = Class.forName(SpecificData.getClassName(s));
        EnumValueDescriptor symbol = (EnumValueDescriptor)m.getField(f);
View Full Code Here

    /** Get the number of elements in a repeated extension. */
    //@Override (Java 1.6 override semantics, but we must support 1.5)
    public final <Type> int getExtensionCount(
        final GeneratedExtension<MessageType, List<Type>> extension) {
      verifyExtensionContainingType(extension);
      final FieldDescriptor descriptor = extension.getDescriptor();
      return extensions.getRepeatedFieldCount(descriptor);
    }
View Full Code Here

TOP

Related Classes of com.google.protobuf.Descriptors.FieldDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.