Java Code Examples for com.google.protobuf.Descriptors.FieldDescriptor.JavaType#BOOLEAN

The following examples show how to use com.google.protobuf.Descriptors.FieldDescriptor.JavaType#BOOLEAN . 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: Comparisons.java    From fdb-record-layer with Apache License 2.0 6 votes vote down vote up
private static Descriptors.FieldDescriptor.JavaType getJavaType(@Nonnull Object o) {
    if (o instanceof Boolean) {
        return JavaType.BOOLEAN;
    } else if (o instanceof ByteString || o instanceof byte[]) {
        return JavaType.BYTE_STRING;
    } else if (o instanceof Double) {
        return JavaType.DOUBLE;
    } else if (o instanceof Float) {
        return JavaType.FLOAT;
    } else if (o instanceof Long) {
        return JavaType.LONG;
    } else if (o instanceof Integer) {
        return JavaType.INT;
    } else if (o instanceof String) {
        return JavaType.STRING;
    } else if (o instanceof Internal.EnumLite) {
        return JavaType.ENUM;
    } else {
        throw new RecordCoreException(o.getClass() + " is an invalid type for a comparand");
    }
}
 
Example 2
Source File: ProtocolBuffersConverter.java    From BIMserver with GNU Affero General Public License v3.0 6 votes vote down vote up
protected Class<?> getJavaType(FieldDescriptor fieldDescriptor) {
	if (fieldDescriptor.getJavaType() == JavaType.BOOLEAN) {
		return Boolean.class;
	} else if (fieldDescriptor.getJavaType() == JavaType.BYTE_STRING) {
		return DataHandler.class;
	} else if (fieldDescriptor.getJavaType() == JavaType.DOUBLE) {
		return Double.class;
	} else if (fieldDescriptor.getJavaType() == JavaType.FLOAT) {
		return Float.class;
	} else if (fieldDescriptor.getJavaType() == JavaType.INT) {
		return Integer.class;
	} else if (fieldDescriptor.getJavaType() == JavaType.LONG) {
		return Long.class;
	} else if (fieldDescriptor.getJavaType() == JavaType.STRING) {
		return String.class;
	} else if (fieldDescriptor.getJavaType() == JavaType.ENUM) {
		try {
			return Class.forName("org.bimserver.interfaces.objects." + fieldDescriptor.getEnumType().getName());
		} catch (ClassNotFoundException e) {
			LOGGER.error("", e);
		}
	}
	return null;
}
 
Example 3
Source File: ProtocolBuffersConverter.java    From BIMserver with GNU Affero General Public License v3.0 6 votes vote down vote up
protected Class<?> getJavaPrimitiveType(FieldDescriptor fieldDescriptor) {
	if (fieldDescriptor.getJavaType() == JavaType.BOOLEAN) {
		return boolean.class;
	} else if (fieldDescriptor.getJavaType() == JavaType.BYTE_STRING) {
		return DataHandler.class;
	} else if (fieldDescriptor.getJavaType() == JavaType.DOUBLE) {
		return double.class;
	} else if (fieldDescriptor.getJavaType() == JavaType.FLOAT) {
		return float.class;
	} else if (fieldDescriptor.getJavaType() == JavaType.INT) {
		return int.class;
	} else if (fieldDescriptor.getJavaType() == JavaType.LONG) {
		return long.class;
	} else if (fieldDescriptor.getJavaType() == JavaType.STRING) {
		return String.class;
	} else if (fieldDescriptor.getJavaType() == JavaType.ENUM) {
		try {
			return Class.forName("org.bimserver.interfaces.objects." + fieldDescriptor.getEnumType().getName());
		} catch (ClassNotFoundException e) {
			LOGGER.error("", e);
		}
	}
	return null;
}