public static Splittable encode(Object obj) { if (obj == null) { return Splittable.NULL; } Type t = findType(obj.getClass()); // Try upcasting if (t == null) { for (Type maybe : Type.values()) { if (maybe.canUpcast(obj)) { t = maybe; break; } } } if (t == null) { throw new UnsupportedOperationException(obj.getClass().getName()); } return t.encode(obj); }
/** * Returns the uninitialized field value for the given primitive type. */ public static Object getUninitializedFieldValue(Class<?> clazz) { Type type = getTypeOrDie(clazz); if (clazz.equals(type.getPrimitiveType())) { return type.getDefaultValue(); } return null; }
public static Splittable encode(Object obj) { if (obj == null) { return Splittable.NULL; } Type t = findType(obj.getClass()); // Try upcasting if (t == null) { for (Type maybe : Type.values()) { if (maybe.canUpcast(obj)) { t = maybe; break; } } } if (t == null) { throw new UnsupportedOperationException(obj.getClass().getName()); } return t.encode(obj); }
public static Splittable encode(Object obj) { if (obj == null) { return Splittable.NULL; } Type t = findType(obj.getClass()); // Try upcasting if (t == null) { for (Type maybe : Type.values()) { if (maybe.canUpcast(obj)) { t = maybe; break; } } } if (t == null) { throw new UnsupportedOperationException(obj.getClass().getName()); } return t.encode(obj); }
public static Splittable encode(Object obj) { if (obj == null) { return Splittable.NULL; } Type t = findType(obj.getClass()); // Try upcasting if (t == null) { for (Type maybe : Type.values()) { if (maybe.canUpcast(obj)) { t = maybe; break; } } } if (t == null) { throw new UnsupportedOperationException(obj.getClass().getName()); } return t.encode(obj); }
/** * Encode a value object when the wire format type is known. This method * should be preferred over {@link #encode(Object)} when possible. */ public static Splittable encode(Class<?> clazz, Object obj) { if (obj == null) { return Splittable.NULL; } return getTypeOrDie(clazz).encode(obj); }
/** * Encode a value object when the wire format type is known. This method * should be preferred over {@link #encode(Object)} when possible. */ public static Splittable encode(Class<?> clazz, Object obj) { if (obj == null) { return Splittable.NULL; } return getTypeOrDie(clazz).encode(obj); }
@SuppressWarnings("unchecked") public static <T> T decode(Class<T> clazz, Splittable split) { if (split == null || split == Splittable.NULL) { return null; } return (T) getTypeOrDie(clazz).decode(clazz, split); }
/** * Returns the uninitialized field value for the given primitive type. */ public static Object getUninitializedFieldValue(Class<?> clazz) { Type type = getTypeOrDie(clazz); if (clazz.equals(type.getPrimitiveType())) { return type.getDefaultValue(); } return null; }
/** * Returns the uninitialized field value for the given primitive type. */ public static Object getUninitializedFieldValue(Class<?> clazz) { Type type = getTypeOrDie(clazz); if (clazz.equals(type.getPrimitiveType())) { return type.getDefaultValue(); } return null; }
/** * Returns the uninitialized field value for the given primitive type. */ public static Object getUninitializedFieldValue(Class<?> clazz) { Type type = getTypeOrDie(clazz); if (clazz.equals(type.getPrimitiveType())) { return type.getDefaultValue(); } return null; }
@SuppressWarnings("unchecked") public static <T> T decode(Class<T> clazz, Splittable split) { if (split == null || split == Splittable.NULL) { return null; } return (T) getTypeOrDie(clazz).decode(clazz, split); }
@SuppressWarnings("unchecked") public static <T> T decode(Class<T> clazz, Splittable split) { if (split == null || split == Splittable.NULL) { return null; } return (T) getTypeOrDie(clazz).decode(clazz, split); }
/** * Encode a value object when the wire format type is known. This method * should be preferred over {@link #encode(Object)} when possible. */ public static Splittable encode(Class<?> clazz, Object obj) { if (obj == null) { return Splittable.NULL; } return getTypeOrDie(clazz).encode(obj); }
@SuppressWarnings("unchecked") public static <T> T decode(Class<T> clazz, Splittable split) { if (split == null || split == Splittable.NULL) { return null; } return (T) getTypeOrDie(clazz).decode(clazz, split); }
/** * Encode a value object when the wire format type is known. This method * should be preferred over {@link #encode(Object)} when possible. */ public static Splittable encode(Class<?> clazz, Object obj) { if (obj == null) { return Splittable.NULL; } return getTypeOrDie(clazz).encode(obj); }