Java Code Examples for com.sun.codemodel.internal.JFieldVar#annotate2()

The following examples show how to use com.sun.codemodel.internal.JFieldVar#annotate2() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BeanGenerator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates an attribute wildcard property on a class.
 */
private void generateAttributeWildcard(ClassOutlineImpl cc) {
    String FIELD_NAME = "otherAttributes";
    String METHOD_SEED = model.getNameConverter().toClassName(FIELD_NAME);

    JClass mapType = codeModel.ref(Map.class).narrow(QName.class, String.class);
    JClass mapImpl = codeModel.ref(HashMap.class).narrow(QName.class, String.class);

    // [RESULT]
    // Map<QName,String> m = new HashMap<QName,String>();
    JFieldVar $ref = cc.implClass.field(JMod.PRIVATE,
            mapType, FIELD_NAME, JExpr._new(mapImpl));
    $ref.annotate2(XmlAnyAttributeWriter.class);

    MethodWriter writer = cc.createMethodWriter();

    JMethod $get = writer.declareMethod(mapType, "get" + METHOD_SEED);
    $get.javadoc().append(
            "Gets a map that contains attributes that aren't bound to any typed property on this class.\n\n"
            + "<p>\n"
            + "the map is keyed by the name of the attribute and \n"
            + "the value is the string value of the attribute.\n"
            + "\n"
            + "the map returned by this method is live, and you can add new attribute\n"
            + "by updating the map directly. Because of this design, there's no setter.\n");
    $get.javadoc().addReturn().append("always non-null");

    $get.body()._return($ref);
}
 
Example 2
Source File: BeanGenerator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates an attribute wildcard property on a class.
 */
private void generateAttributeWildcard(ClassOutlineImpl cc) {
    String FIELD_NAME = "otherAttributes";
    String METHOD_SEED = model.getNameConverter().toClassName(FIELD_NAME);

    JClass mapType = codeModel.ref(Map.class).narrow(QName.class, String.class);
    JClass mapImpl = codeModel.ref(HashMap.class).narrow(QName.class, String.class);

    // [RESULT]
    // Map<QName,String> m = new HashMap<QName,String>();
    JFieldVar $ref = cc.implClass.field(JMod.PRIVATE,
            mapType, FIELD_NAME, JExpr._new(mapImpl));
    $ref.annotate2(XmlAnyAttributeWriter.class);

    MethodWriter writer = cc.createMethodWriter();

    JMethod $get = writer.declareMethod(mapType, "get" + METHOD_SEED);
    $get.javadoc().append(
            "Gets a map that contains attributes that aren't bound to any typed property on this class.\n\n"
            + "<p>\n"
            + "the map is keyed by the name of the attribute and \n"
            + "the value is the string value of the attribute.\n"
            + "\n"
            + "the map returned by this method is live, and you can add new attribute\n"
            + "by updating the map directly. Because of this design, there's no setter.\n");
    $get.javadoc().addReturn().append("always non-null");

    $get.body()._return($ref);
}
 
Example 3
Source File: BeanGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates an attribute wildcard property on a class.
 */
private void generateAttributeWildcard(ClassOutlineImpl cc) {
    String FIELD_NAME = "otherAttributes";
    String METHOD_SEED = model.getNameConverter().toClassName(FIELD_NAME);

    JClass mapType = codeModel.ref(Map.class).narrow(QName.class, String.class);
    JClass mapImpl = codeModel.ref(HashMap.class).narrow(QName.class, String.class);

    // [RESULT]
    // Map<QName,String> m = new HashMap<QName,String>();
    JFieldVar $ref = cc.implClass.field(JMod.PRIVATE,
            mapType, FIELD_NAME, JExpr._new(mapImpl));
    $ref.annotate2(XmlAnyAttributeWriter.class);

    MethodWriter writer = cc.createMethodWriter();

    JMethod $get = writer.declareMethod(mapType, "get" + METHOD_SEED);
    $get.javadoc().append(
            "Gets a map that contains attributes that aren't bound to any typed property on this class.\n\n"
            + "<p>\n"
            + "the map is keyed by the name of the attribute and \n"
            + "the value is the string value of the attribute.\n"
            + "\n"
            + "the map returned by this method is live, and you can add new attribute\n"
            + "by updating the map directly. Because of this design, there's no setter.\n");
    $get.javadoc().addReturn().append("always non-null");

    $get.body()._return($ref);
}
 
Example 4
Source File: BeanGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates an attribute wildcard property on a class.
 */
private void generateAttributeWildcard(ClassOutlineImpl cc) {
    String FIELD_NAME = "otherAttributes";
    String METHOD_SEED = model.getNameConverter().toClassName(FIELD_NAME);

    JClass mapType = codeModel.ref(Map.class).narrow(QName.class, String.class);
    JClass mapImpl = codeModel.ref(HashMap.class).narrow(QName.class, String.class);

    // [RESULT]
    // Map<QName,String> m = new HashMap<QName,String>();
    JFieldVar $ref = cc.implClass.field(JMod.PRIVATE,
            mapType, FIELD_NAME, JExpr._new(mapImpl));
    $ref.annotate2(XmlAnyAttributeWriter.class);

    MethodWriter writer = cc.createMethodWriter();

    JMethod $get = writer.declareMethod(mapType, "get" + METHOD_SEED);
    $get.javadoc().append(
            "Gets a map that contains attributes that aren't bound to any typed property on this class.\n\n"
            + "<p>\n"
            + "the map is keyed by the name of the attribute and \n"
            + "the value is the string value of the attribute.\n"
            + "\n"
            + "the map returned by this method is live, and you can add new attribute\n"
            + "by updating the map directly. Because of this design, there's no setter.\n");
    $get.javadoc().addReturn().append("always non-null");

    $get.body()._return($ref);
}
 
Example 5
Source File: BeanGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates an attribute wildcard property on a class.
 */
private void generateAttributeWildcard(ClassOutlineImpl cc) {
    String FIELD_NAME = "otherAttributes";
    String METHOD_SEED = model.getNameConverter().toClassName(FIELD_NAME);

    JClass mapType = codeModel.ref(Map.class).narrow(QName.class, String.class);
    JClass mapImpl = codeModel.ref(HashMap.class).narrow(QName.class, String.class);

    // [RESULT]
    // Map<QName,String> m = new HashMap<QName,String>();
    JFieldVar $ref = cc.implClass.field(JMod.PRIVATE,
            mapType, FIELD_NAME, JExpr._new(mapImpl));
    $ref.annotate2(XmlAnyAttributeWriter.class);

    MethodWriter writer = cc.createMethodWriter();

    JMethod $get = writer.declareMethod(mapType, "get" + METHOD_SEED);
    $get.javadoc().append(
            "Gets a map that contains attributes that aren't bound to any typed property on this class.\n\n"
            + "<p>\n"
            + "the map is keyed by the name of the attribute and \n"
            + "the value is the string value of the attribute.\n"
            + "\n"
            + "the map returned by this method is live, and you can add new attribute\n"
            + "by updating the map directly. Because of this design, there's no setter.\n");
    $get.javadoc().addReturn().append("always non-null");

    $get.body()._return($ref);
}
 
Example 6
Source File: BeanGenerator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates an attribute wildcard property on a class.
 */
private void generateAttributeWildcard(ClassOutlineImpl cc) {
    String FIELD_NAME = "otherAttributes";
    String METHOD_SEED = model.getNameConverter().toClassName(FIELD_NAME);

    JClass mapType = codeModel.ref(Map.class).narrow(QName.class, String.class);
    JClass mapImpl = codeModel.ref(HashMap.class).narrow(QName.class, String.class);

    // [RESULT]
    // Map<QName,String> m = new HashMap<QName,String>();
    JFieldVar $ref = cc.implClass.field(JMod.PRIVATE,
            mapType, FIELD_NAME, JExpr._new(mapImpl));
    $ref.annotate2(XmlAnyAttributeWriter.class);

    MethodWriter writer = cc.createMethodWriter();

    JMethod $get = writer.declareMethod(mapType, "get" + METHOD_SEED);
    $get.javadoc().append(
            "Gets a map that contains attributes that aren't bound to any typed property on this class.\n\n"
            + "<p>\n"
            + "the map is keyed by the name of the attribute and \n"
            + "the value is the string value of the attribute.\n"
            + "\n"
            + "the map returned by this method is live, and you can add new attribute\n"
            + "by updating the map directly. Because of this design, there's no setter.\n");
    $get.javadoc().addReturn().append("always non-null");

    $get.body()._return($ref);
}
 
Example 7
Source File: BeanGenerator.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates an attribute wildcard property on a class.
 */
private void generateAttributeWildcard(ClassOutlineImpl cc) {
    String FIELD_NAME = "otherAttributes";
    String METHOD_SEED = model.getNameConverter().toClassName(FIELD_NAME);

    JClass mapType = codeModel.ref(Map.class).narrow(QName.class, String.class);
    JClass mapImpl = codeModel.ref(HashMap.class).narrow(QName.class, String.class);

    // [RESULT]
    // Map<QName,String> m = new HashMap<QName,String>();
    JFieldVar $ref = cc.implClass.field(JMod.PRIVATE,
            mapType, FIELD_NAME, JExpr._new(mapImpl));
    $ref.annotate2(XmlAnyAttributeWriter.class);

    MethodWriter writer = cc.createMethodWriter();

    JMethod $get = writer.declareMethod(mapType, "get" + METHOD_SEED);
    $get.javadoc().append(
            "Gets a map that contains attributes that aren't bound to any typed property on this class.\n\n"
            + "<p>\n"
            + "the map is keyed by the name of the attribute and \n"
            + "the value is the string value of the attribute.\n"
            + "\n"
            + "the map returned by this method is live, and you can add new attribute\n"
            + "by updating the map directly. Because of this design, there's no setter.\n");
    $get.javadoc().addReturn().append("always non-null");

    $get.body()._return($ref);
}
 
Example 8
Source File: BeanGenerator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates an attribute wildcard property on a class.
 */
private void generateAttributeWildcard(ClassOutlineImpl cc) {
    String FIELD_NAME = "otherAttributes";
    String METHOD_SEED = model.getNameConverter().toClassName(FIELD_NAME);

    JClass mapType = codeModel.ref(Map.class).narrow(QName.class, String.class);
    JClass mapImpl = codeModel.ref(HashMap.class).narrow(QName.class, String.class);

    // [RESULT]
    // Map<QName,String> m = new HashMap<QName,String>();
    JFieldVar $ref = cc.implClass.field(JMod.PRIVATE,
            mapType, FIELD_NAME, JExpr._new(mapImpl));
    $ref.annotate2(XmlAnyAttributeWriter.class);

    MethodWriter writer = cc.createMethodWriter();

    JMethod $get = writer.declareMethod(mapType, "get" + METHOD_SEED);
    $get.javadoc().append(
            "Gets a map that contains attributes that aren't bound to any typed property on this class.\n\n"
            + "<p>\n"
            + "the map is keyed by the name of the attribute and \n"
            + "the value is the string value of the attribute.\n"
            + "\n"
            + "the map returned by this method is live, and you can add new attribute\n"
            + "by updating the map directly. Because of this design, there's no setter.\n");
    $get.javadoc().addReturn().append("always non-null");

    $get.body()._return($ref);
}