タグに含まれる要素の順序をキャプチャする作業をしていました。すべてのコードは次のとおりです。
League.java:
@Root
@Convert(value = LeagueConverter.class)
public class League 
{
    @Attribute
    private String name;
    @Element(name="headlines", required = false)
    private Headlines headlines;
    @Element(name="scores", required = false)
    private Scores scores;
    @Element(name="standings", required = false)
    private Standing standings;
    @Element(name="statistics", required = false)
    private LeagueStatistics statistics;
    public List<String> order = new ArrayList<String>();
        // get methods for all variables
}
LeagueConverter.java:
public class LeagueConverter implements Converter<League>
{
       @Override
       public League read(InputNode node) throws Exception
       {
               League league = new League();
               InputNode next = node.getNext();
               while( next != null )
               {
                String tag = next.getName();
                if(tag.equalsIgnoreCase("headlines"))
                {
                  league.order.add("headlines");
                }
                else if(tag.equalsIgnoreCase("scores"))
                    {
                          league.order.add("scores");
                    }
                else if(tag.equalsIgnoreCase("statistics"))
                {
                  league.order.add("statistics");
                }
                else if(tag.equalsIgnoreCase("standings"))
                {
                  league.order.add("standings");
                }
                    next = node.getNext();
                }
                return league;
       }
   @Override
   public void write(OutputNode arg0, League arg1) throws Exception 
   {
    throw new UnsupportedOperationException("Not supported yet.");
   }
}
XML の例:
 <android>
    <leagues>
       <league name ="A">
          <Headlines></Headlines>
          <Scores></Scores>
          ...
       </league>
       <league name ="B">...</league>
    </leagues>
 </android>
私はそれをどのように呼び出し、それが動作することを期待しています:(スニペット)
 Android android = null;
 Serializer serial = new Persister(new AnnotationStrategy());
 android = serial.read(Android.class, source);
 Log.i("Number of leagues found ",tsnAndroid.getLeagueCount() + ""); // prints fine
 League nhl = tsnAndroid.getLeagues().get(0); // works fine
 // DOES NOT WORK throws NullPointerEx
 League nhl2 = tsnAndroid.getLeagueByName("A");
 // DOES NOT WORK throws NullPointerEx
 for(String s : nhl.getOrder())
 {
    Log.i("ORDER>>>>>", s);
 }
問題:
android.getLeagueByName()(@Attribute名前で動作)コンバーターを設定すると突然動作が停止するため、次のようにLeague.java設定されません。
@Attribute
private String name; // not being set
ただし、コンバーター宣言をコメントアウトすると、League.java- すべてのリーグには name という属性があり、正常に動作しandroid.getLeagueByName()始めます...
@Convert for League は何らかの形で @Attribute in League に干渉しますか?