public ProtoField(Field protoField) { Preconditions.checkNotNull(protoField); this.protoField = protoField; this.protoTypeRef = ProtoTypeRef.create(protoField.getType()); }
/** * Returns the type of this field selector, i.e. the type of the last field in the field list. */ public TypeRef getType() { return getLastField().getType(); }
@Override public String toString() { return String.format("%s %s", getType(), getFullName()); } }
@Override public String toString() { return String.format("%s %s", getType(), getFullName()); } }
@Override public boolean apply(Field field) { return field.getType().getKind() == FieldDescriptorProto.Type.TYPE_MESSAGE; } };
/** * Returns the type of this field selector, i.e. the type of the last field in the field list. */ public TypeRef getType() { return getLastField().getType(); }
@Override public boolean isMessage() { return protoField.getType().isMessage(); }
@Override public boolean apply(Field field) { return field.getType().getKind() == FieldDescriptorProto.Type.TYPE_MESSAGE; } };
@Override public boolean apply(Field field) { return field.getType().getCardinality() == Cardinality.REPEATED; } };
@Override public String getKind() { return protoField.getType().toString(); }
@Override public boolean apply(Field field) { return field.getType().getCardinality() == Cardinality.REPEATED; } };
@Override public boolean apply(Field field) { return field.getType().isMap(); } };
@Override public boolean apply(Field field) { return field.getType().isCyclic(); } };
@Override public boolean apply(Field field) { return field.getType().isMap(); } };
@Override public boolean isMap() { return protoField.getType().isMap(); }
@Override public boolean isRequired() { return protoField.getType().getCardinality().equals(Cardinality.REQUIRED); }
@Override public String getTypeFullName() { return protoField.getType().getMessageType().getFullName(); }
@Override public TypeModel getMapKeyType() { return create(getProtoType().getMapKeyField().getType()); }
private boolean subCyclic(MessageType message) { if (message.isCyclic()) { return true; } for (Field subMessageField : message.getMessageFields()) { if (subCyclic(subMessageField.getType().getMessageType())) { return true; } } return false; } }
private boolean subCyclic(MessageType message) { if (message.isCyclic()) { return true; } for (Field subMessageField : message.getMessageFields()) { if (subCyclic(subMessageField.getType().getMessageType())) { return true; } } return false; } }