mirror of
https://github.com/zaaarf/lillero-mapper.git
synced 2024-11-13 00:39:20 +01:00
feat: added support for field type descriptor
This commit is contained in:
parent
8f122b540e
commit
e07a0ac423
3 changed files with 34 additions and 2 deletions
|
@ -53,7 +53,7 @@ public class TinyV2Mapper extends AbstractMapper {
|
|||
case 'f': //fields
|
||||
if(tokens.length == 4)
|
||||
break;
|
||||
this.mappings.get(currentClass).addField(tokens[2], tokens[3]);
|
||||
this.mappings.get(currentClass).addField(tokens[2], tokens[3], tokens[1]);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -68,6 +68,16 @@ public class ClassData {
|
|||
this.fields.put(plain, new FieldData(this, plain, mapped));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a field to the target class.
|
||||
* @param plain the name of the field
|
||||
* @param mapped the mapped name of the field
|
||||
* @param descriptor the plain type descriptor of the field
|
||||
*/
|
||||
public void addField(String plain, String mapped, String descriptor) {
|
||||
this.fields.put(plain, new FieldData(this, plain, mapped, descriptor));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the reverse mappings for this class.
|
||||
* Should always be called only after the given mapper has finished
|
||||
|
|
|
@ -21,7 +21,14 @@ public class FieldData {
|
|||
public final String nameMapped;
|
||||
|
||||
/**
|
||||
* Constructs a new {@link FieldData}.
|
||||
* The field's type descriptor.
|
||||
* Some formats may not specify it; if this was created in one such format,
|
||||
* this is going to be null.
|
||||
*/
|
||||
public final String descriptor;
|
||||
|
||||
/**
|
||||
* Constructs a new {@link FieldData} with unspecified descriptor.
|
||||
* @param parentClass the {@link ClassData} representation of the parent class
|
||||
* @param name the field name
|
||||
* @param nameMapped the mapped field name
|
||||
|
@ -30,5 +37,20 @@ public class FieldData {
|
|||
this.parentClass = parentClass;
|
||||
this.name = name;
|
||||
this.nameMapped = nameMapped;
|
||||
this.descriptor = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@link FieldData} with descriptor.
|
||||
* @param parentClass the {@link ClassData} representation of the parent class
|
||||
* @param name the field name
|
||||
* @param nameMapped the mapped field name
|
||||
* @param descriptor the field's type descriptor
|
||||
*/
|
||||
public FieldData(ClassData parentClass, String name, String nameMapped, String descriptor) {
|
||||
this.parentClass = parentClass;
|
||||
this.name = name;
|
||||
this.nameMapped = nameMapped;
|
||||
this.descriptor = descriptor;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue