Java Code Examples for io.protostuff.compiler.model.Field#toString()

The following examples show how to use io.protostuff.compiler.model.Field#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MessageFieldUtil.java    From protostuff-compiler with Apache License 2.0 6 votes vote down vote up
/**
 * Returns map field value type name.
 */
public static String getMapFieldValueType(Field field) {
    FieldType type = field.getType();
    if (!(type instanceof Message)) {
        throw new IllegalArgumentException(field.toString());
    }
    Message entryType = (Message) type;
    Type valueType = entryType.getField(MAP_ENTRY_VALUE).getType();
    String v;
    if (valueType instanceof ScalarFieldType) {
        ScalarFieldType scalarValueType = (ScalarFieldType) valueType;
        v = ScalarFieldTypeUtil.getWrapperType(scalarValueType);
    } else {
        UserType userType = (UserType) valueType;
        v = UserTypeUtil.getCanonicalName(userType);
    }
    return v;
}
 
Example 2
Source File: MessageFieldUtil.java    From protostuff-compiler with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a field value setter name for proto repeated enum field.
 */
public static String getRepeatedEnumValueSetterName(Field field) {
    if (field.isRepeated()) {
        return SETTER_PREFIX + Formatter.toPascalCase(field.getName()) + VALUE;
    }
    throw new IllegalArgumentException(field.toString());
}
 
Example 3
Source File: MessageFieldUtil.java    From protostuff-compiler with Apache License 2.0 5 votes vote down vote up
/**
 * Returns "putAll" method name for map field.
 */
public static String getMapFieldAddAllName(Field field) {
    if (field.isMap()) {
        return "putAll" + Formatter.toPascalCase(field.getName());
    }
    throw new IllegalArgumentException(field.toString());
}
 
Example 4
Source File: MessageFieldUtil.java    From protostuff-compiler with Apache License 2.0 5 votes vote down vote up
/**
 * Returns map field "put" method name.
 */
public static String getMapFieldAdderName(Field field) {
    if (field.isMap()) {
        return PUT_PREFIX + Formatter.toPascalCase(field.getName());
    }
    throw new IllegalArgumentException(field.toString());
}
 
Example 5
Source File: MessageFieldUtil.java    From protostuff-compiler with Apache License 2.0 5 votes vote down vote up
/**
 * Returns map field getter for particular key method name.
 */
public static String mapGetByKeyMethodName(Field field) {
    if (field.isMap()) {
        return GETTER_PREFIX + Formatter.toPascalCase(field.getName());
    }
    throw new IllegalArgumentException(field.toString());
}
 
Example 6
Source File: MessageFieldUtil.java    From protostuff-compiler with Apache License 2.0 5 votes vote down vote up
/**
 * Returns map field setter name.
 */
public static String getMapSetterName(Field field) {
    if (field.isMap()) {
        return SETTER_PREFIX + Formatter.toPascalCase(field.getName()) + MAP_SUFFIX;
    }
    throw new IllegalArgumentException(field.toString());
}
 
Example 7
Source File: MessageFieldUtil.java    From protostuff-compiler with Apache License 2.0 5 votes vote down vote up
/**
 * Returns map field getter name.
 */
public static String getMapGetterName(Field field) {
    if (field.isMap()) {
        return GETTER_PREFIX + Formatter.toPascalCase(field.getName()) + MAP_SUFFIX;
    }
    throw new IllegalArgumentException(field.toString());
}
 
Example 8
Source File: MessageFieldUtil.java    From protostuff-compiler with Apache License 2.0 5 votes vote down vote up
/**
 * Returns map field key type name.
 */
public static String getMapFieldKeyType(Field field) {
    FieldType type = field.getType();
    if (!(type instanceof Message)) {
        throw new IllegalArgumentException(field.toString());
    }
    Message entryType = (Message) type;
    ScalarFieldType keyType = (ScalarFieldType) entryType.getField(MAP_ENTRY_KEY).getType();
    return ScalarFieldTypeUtil.getWrapperType(keyType);
}
 
Example 9
Source File: MessageFieldUtil.java    From protostuff-compiler with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a field getter by index name for proto repeated field.
 */
public static String repeatedGetByIndexMethodName(Field field) {
    if (field.isRepeated()) {
        return GETTER_PREFIX + Formatter.toPascalCase(field.getName());
    }
    throw new IllegalArgumentException(field.toString());
}
 
Example 10
Source File: MessageFieldUtil.java    From protostuff-compiler with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a element count getter name for proto repeated field.
 */
public static String repeatedGetCountMethodName(Field field) {
    if (field.isRepeated()) {
        return GETTER_PREFIX + Formatter.toPascalCase(field.getName()) + "Count";
    }
    throw new IllegalArgumentException(field.toString());
}
 
Example 11
Source File: MessageFieldUtil.java    From protostuff-compiler with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a java field type for proto field.
 */
public static String getFieldType(Field field) {
    FieldType type = field.getType();
    if (type instanceof ScalarFieldType) {
        ScalarFieldType scalarFieldType = (ScalarFieldType) type;
        return ScalarFieldTypeUtil.getPrimitiveType(scalarFieldType);
    }
    if (type instanceof UserType) {
        UserType userType = (UserType) type;
        return UserTypeUtil.getCanonicalName(userType);
    }
    throw new IllegalArgumentException(field.toString());
}
 
Example 12
Source File: MessageFieldUtil.java    From protostuff-compiler with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a field setter name for proto repeated field.
 */
public static String getRepeatedFieldSetterName(Field field) {
    if (field.isRepeated()) {
        return SETTER_PREFIX + Formatter.toPascalCase(field.getName());
    }
    throw new IllegalArgumentException(field.toString());
}
 
Example 13
Source File: MessageFieldUtil.java    From protostuff-compiler with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a field converter class name for proto repeated enum field.
 */
public static String getRepeatedEnumConverterName(Field field) {
    if (field.isRepeated()) {
        return "__" + Formatter.toCamelCase(field.getName()) + "Converter";
    }
    throw new IllegalArgumentException(field.toString());
}
 
Example 14
Source File: MessageFieldUtil.java    From protostuff-compiler with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a field value getter by index name for proto repeated enum field.
 */
public static String javaRepeatedEnumValueGetterByIndexName(Field field) {
    if (field.isRepeated()) {
        return GETTER_PREFIX + Formatter.toPascalCase(field.getName()) + VALUE;
    }
    throw new IllegalArgumentException(field.toString());
}
 
Example 15
Source File: MessageFieldUtil.java    From protostuff-compiler with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a field value getter name for proto repeated enum field.
 */
public static String getRepeatedEnumFieldValueGetterName(Field field) {
    if (field.isRepeated()) {
        return GETTER_PREFIX + Formatter.toPascalCase(field.getName()) + "ValueList";
    }
    throw new IllegalArgumentException(field.toString());
}
 
Example 16
Source File: MessageFieldUtil.java    From protostuff-compiler with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a java field getter name for proto repeated field.
 */
public static String getRepeatedFieldGetterName(Field field) {
    if (field.isRepeated()) {
        return GETTER_PREFIX + Formatter.toPascalCase(field.getName()) + GETTER_REPEATED_SUFFIX;
    }
    throw new IllegalArgumentException(field.toString());
}
 
Example 17
Source File: MessageFieldUtil.java    From protostuff-compiler with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a java wrapper field type for proto scalar field.
 */
public static String getWrapperFieldType(Field field) {
    FieldType type = field.getType();
    if (type instanceof ScalarFieldType) {
        ScalarFieldType scalarFieldType = (ScalarFieldType) type;
        return ScalarFieldTypeUtil.getWrapperType(scalarFieldType);
    }
    if (type instanceof UserType) {
        UserType userType = (UserType) type;
        return UserTypeUtil.getCanonicalName(userType);
    }
    throw new IllegalArgumentException(field.toString());
}
 
Example 18
Source File: MessageFieldUtil.java    From protostuff-compiler with Apache License 2.0 5 votes vote down vote up
/**
 * Returns an iterable wrapper for proto repeated field.
 */
public static String getIterableFieldType(Field field) {
    FieldType type = field.getType();
    if (type instanceof ScalarFieldType) {
        ScalarFieldType scalarFieldType = (ScalarFieldType) type;
        return ITERABLE + "<" + ScalarFieldTypeUtil.getWrapperType(scalarFieldType) + ">";
    }
    if (type instanceof UserType) {
        UserType userType = (UserType) type;
        return ITERABLE + "<" + UserTypeUtil.getCanonicalName(userType) + ">";
    }
    throw new IllegalArgumentException(field.toString());
}
 
Example 19
Source File: MessageFieldUtil.java    From protostuff-compiler with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a java field type for proto repeated field.
 */
public static String getRepeatedFieldType(Field field) {
    FieldType type = field.getType();
    if (type instanceof ScalarFieldType) {
        ScalarFieldType scalarFieldType = (ScalarFieldType) type;
        return LIST + "<" + ScalarFieldTypeUtil.getWrapperType(scalarFieldType) + ">";
    }
    if (type instanceof UserType) {
        UserType userType = (UserType) type;
        return LIST + "<" + UserTypeUtil.getCanonicalName(userType) + ">";
    }
    throw new IllegalArgumentException(field.toString());
}