// preserve its field number for backward-forward compat
i++;
continue;
}
final Tag tag = f.getAnnotation(Tag.class);
final int fieldMapping;
final String name;
if(tag == null)
{
// Fields gets assigned mapping tags according to their definition order
if(annotated)
{
throw new RuntimeException("When using annotation-based mapping, " +
"all fields must be annotated with @" + Tag.class.getSimpleName());
}
fieldMapping = ++i;
name = f.getName();
}
else
{
// Fields gets assigned mapping tags according to their annotation
if(!annotated && !fields.isEmpty())
{
throw new RuntimeException("When using annotation-based mapping, " +
"all fields must be annotated with @" + Tag.class.getSimpleName());
}
annotated = true;
fieldMapping = tag.value();
if(fieldMapping < 1)
{
throw new RuntimeException("Invalid field number: " +
fieldMapping + " on " + typeClass);
}
name = tag.alias().isEmpty() ? f.getName() : tag.alias();
}
final Field<T> field = RuntimeFieldFactory.getFieldFactory(
f.getType(), strategy).create(fieldMapping, name, f, strategy);
fields.add(field);