/** * Returns true if the specified field is optional. * * @param field to check * @return true if optional */ public static boolean isOptionalField(@NotNull Field field) { ResourceField rf = field.getAnnotation(ResourceField.class); ListField lf = field.getAnnotation(ListField.class); PrimaryKey pk = field.getAnnotation(PrimaryKey.class); return (rf != null && rf.value()) || (lf != null && lf.optional()) || (pk != null); }