Open GoogleCodeExporter opened 9 years ago
Apologies for the issue type, it should be Enhancement, but I couldn't find
where to set it.
Original comment by josef.ba...@gmail.com
on 22 Nov 2012 at 12:29
Feel free to deliver the implementation.
Original comment by py4fun@gmail.com
on 22 Nov 2012 at 4:12
[deleted comment]
Attached including junit test cases. :)
Original comment by josef.ba...@gmail.com
on 22 Nov 2012 at 5:35
Attachments:
1) please implement loadAllAs() because loadAll() methods do not cast
2) the whole idea behind loadAs() methods that you do not need to create your
own Constructor at all. Look at the examples:
Yaml beanLoader = new Yaml();
ListFieldBean parsed = beanLoader.loadAs(output, ListFieldBean.class);
What should happen if users give different Classes for the Constructor and for
the loadAllAs() ?
Original comment by py4fun@gmail.com
on 22 Nov 2012 at 7:35
[deleted comment]
Well the overloaded loadAll() is essentially a different method, just
overloaded with the same name. We can change it to loadAllAs() no problem. I
just followed the same pattern used by JPA (EntityManager.createQuery()
http://docs.oracle.com/javaee/6/api/javax/persistence/EntityManager.html#createQ
uery(java.lang.String, java.lang.Class))
The new loadAll(..., Class<T> type) methods do work without the Constructor.
(Its included in the test case but its redundant, because the code does exactly
the same as the loadAs(..., Class<T> type).
> What should happen if users give different Classes for the Constructor and
for the loadAllAs() ?
This is just a convenience typesafe method for when you have a list of YAML
objects all of the same type in a file. The same thing that happens now to
loadAs() if different constructor classes are given should happen.
Original comment by josef.ba...@gmail.com
on 22 Nov 2012 at 7:45
[deleted comment]
Indeed, I have removed the custom Constructor, but the tests are still green.
The tests may have 2 purposes:
1) they prove that the contact works
2) they show how to use the API (without redundant code)
Can you please provide a patch (or a clone) which delivers both ?
Please do not forget to check the coverage ('mvn site', and look at the
generated coverage report -
file:///.../snakeyaml/target/site/cobertura/index.html). At the moment, the
introduction of a new method in BaseConstructor reduces the coverage for the
existing method.
Original comment by py4fun@gmail.com
on 23 Nov 2012 at 10:12
OK, will try to refine it a little more as you're suggesting when I get some
time.
Original comment by josef.ba...@gmail.com
on 27 Nov 2012 at 11:05
Please make the time to merge this improvement.
Original issue reported on code.google.com by
josef.ba...@gmail.com
on 22 Nov 2012 at 12:27