Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2010-2011 Sonatype, Inc. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: /
 
package org.hudsonci.jaxb;
Adds com.thoughtworks.xstream.annotations.XStreamAlias to generated types.

Author(s):
Jason Dillon
Since:
2.1.0
public class XStreamAliasPlugin
    @Override
    public String getOptionName() {
        return "XxstreamAlias";
    }
    @Override
    public String getUsage() {
        return "Adds @XStreamAlias to generated types.";
    }
    @Override
    protected boolean run(final Outline outlinefinal Options optionsthrows Exception {
        assert outline != null;
        assert options != null;
        for (ClassOutline type : outline.getClasses()) {
            QName qname = type.target.getTypeName();
            if (qname != null) {
                addAlias(type.implClassqname);
            }
        }
        for (EnumOutline type : outline.getEnums()) {
            QName qname = type.target.getTypeName();
            if (qname != null) {
                addAlias(type.clazzqname);
            }
        }
        return true;
    }
    private void addAlias(final JDefinedClass typefinal QName qname) {
        assert type != null;
        assert qname != null;
        JAnnotationUse anno = type.annotate(XStreamAlias.class);
        anno.param("value"qname.getLocalPart());
    }
New to GrepCode? Check out our FAQ X