Closed GoogleCodeExporter closed 9 years ago
1)
public class Param {
private String name;
private String inputPart;
public setInput_part(String part) { inputPart = part} ;
//...
}
2)
Create standard Java structure (no loadAs()) and transform the map of values to
your business JavaBean
3)
Write your own Contructor
Original comment by py4fun@gmail.com
on 2 Jul 2012 at 4:50
thank you, py4fun.
I know the former 2 ways, but i don't think they are good ways to solve it. Can
you give me some sample for the third way? because what i want acutally is a
mapping method between the key'name in yaml str and the field's name in
javaBean, like the mapping in Hibernate,JPA or myBatis:
class Param {
@Column(name="column_one")
private String columnOne;
...
}.
or
<property="columnOne" column="column_one">
because i have another problem, if there is a key word named 'default' in a
yaml string, how do i parese it without using the former 2 ways?
yaml string like this:
name: "Test", input_part: "abc", default: "111"
any help will be appreciated!
Original comment by way...@gmail.com
on 3 Jul 2012 at 9:42
By using this clone http://code.google.com/r/alexandermaslov-sny-beancontrol/
you can achieve what you expect like this:
**********************
TypeDescription paramDesc = new TypeDescription(Param.class);
paramDesc.substituteProperty("input_part", String.class, "getInputPart",
"setInputPart");
paramDesc.substituteProperty("default", String.class, "getMore", "setMore");
Yaml yaml = new Yaml();
yaml.addTypeDescription(paramDesc);
Param p = yaml.loadAs("name: \"Test\"\ninput_part: \"abc\"\ndefault: \"some
value\"", Param.class);
**********************
I was planning to add property name mapping, but it's not there yet.
Original comment by alexande...@gmail.com
on 4 Jul 2012 at 6:56
Part of this task has been delivered with the fix for issue 154
Original comment by aso...@gmail.com
on 27 Jul 2012 at 3:08
why isn't Alexander's clone (with property name mappings) merged into the main
snakeyaml project?
Original comment by gdo...@gmail.com
on 24 Mar 2015 at 12:54
First of all - it is work-in-progress. But mostly - luck of time at the moment
to (re)write tests to keep coverage good.
I hope to do it before this August (since we need to migrate the whole thing
somewhere).
Original comment by alexande...@gmail.com
on 25 Mar 2015 at 6:23
Original issue reported on code.google.com by
way...@gmail.com
on 2 Jul 2012 at 2:06