当前位置: 首页>>代码示例>>Java>>正文


Java JEnumConstant.arg方法代码示例

本文整理汇总了Java中com.sun.codemodel.JEnumConstant.arg方法的典型用法代码示例。如果您正苦于以下问题:Java JEnumConstant.arg方法的具体用法?Java JEnumConstant.arg怎么用?Java JEnumConstant.arg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.codemodel.JEnumConstant的用法示例。


在下文中一共展示了JEnumConstant.arg方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addEnumConstants

import com.sun.codemodel.JEnumConstant; //导入方法依赖的package包/类
private void addEnumConstants(JsonNode node, JDefinedClass _enum, JsonNode customNames, JType type) {
    Collection<String> existingConstantNames = new ArrayList<String>();
    for (int i = 0; i < node.size(); i++) {
        JsonNode value = node.path(i);

        if (!value.isNull()) {
            String constantName = getConstantName(value.asText(), customNames.path(i).asText());
            constantName = makeUnique(constantName, existingConstantNames);
            existingConstantNames.add(constantName);

            JEnumConstant constant = _enum.enumConstant(constantName);
            constant.arg(DefaultRule.getDefaultValue(type, value));
            ruleFactory.getAnnotator().enumConstant(constant, value.asText());
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:EnumRule.java

示例2: buildEnumClass

import com.sun.codemodel.JEnumConstant; //导入方法依赖的package包/类
private JDefinedClass buildEnumClass(String enumName, List<String> values) throws JClassAlreadyExistsException {
    if (pkg.isDefined(enumName)) {
        return pkg._getClass(enumName);
    }
    JDefinedClass valueEnum = pkg._enum(enumName);

    JFieldVar valField = valueEnum.field(JMod.PRIVATE | JMod.FINAL, String.class, "value");
    JMethod ctor = valueEnum.constructor(JMod.PRIVATE);
    JVar param = ctor.param(String.class, "val");
    ctor.body().assign(valField, param);

    JMethod toString = valueEnum.method(JMod.PUBLIC, String.class, "toString");
    toString.annotate(Override.class);
    toString.body()._return(valField);

    for (String value : values) {
        JEnumConstant sortCnst = valueEnum.enumConstant(value.toUpperCase().replace(' ', '_'));
        sortCnst.arg(JExpr.lit(value));
    }
    return valueEnum;
}
 
开发者ID:mbst,项目名称:glycerin,代码行数:22,代码来源:FeedQueryGenerator.java

示例3: parseEnumMember

import com.sun.codemodel.JEnumConstant; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private void parseEnumMember(Element root, ParsingContext context) {
	JDefinedClass enumClass = (JDefinedClass) context.getCmNode();
	
	JEnumConstant enumConstant = enumClass.enumConstant(
			NameUtils.camelToUpper(enumClass.name()) + '_' + root.getAttributeValue("name").toUpperCase()
	);
	long value = Long.parseLong(root.getAttributeValue("value"));
	enumConstant.arg(JExpr.lit(value));
	System.out.println("--> " + enumConstant.getName() + " (" + value + ")");
}
 
开发者ID:gstreamer-java,项目名称:gir2java,代码行数:12,代码来源:GirParser.java

示例4: withEnum

import com.sun.codemodel.JEnumConstant; //导入方法依赖的package包/类
public <T> EnumBuilder withEnum(T name, Class<T> type) {
	pojoCreationCheck();
	String cleaned = NamingHelper.cleanNameForJavaEnum(name.toString());
	if (!doesEnumContainField(type, cleaned)) {
		withValueField(type);
		ENUM_CACHE.put(cleaned, true);
		logger.debug("Adding field: " + name + " to " + this.pojo.name());
		if (StringUtils.hasText(cleaned)) {
			JEnumConstant enumConstant = this.pojo.enumConstant(cleaned);
			if (type.equals(Integer.class)) {
				enumConstant.arg(JExpr.lit((Integer)name));
			} else if (type.equals(Boolean.class)) {
				enumConstant.arg(JExpr.lit((Boolean)name));
			} else if (type.equals(Double.class)) {
				enumConstant.arg(JExpr.lit((Double)name));
			} else if (type.equals(Float.class)) {
				enumConstant.arg(JExpr.lit((Float)name));
			} else if (type.equals(Long.class)) {
				enumConstant.arg(JExpr.lit((Long)name));
			} else {
				enumConstant.arg(JExpr.lit(name.toString()));
				enumConstant.annotate(JsonProperty.class).param("value", name.toString());
			}
		}
	}
	return this;
}
 
开发者ID:phoenixnap,项目名称:springmvc-raml-plugin,代码行数:28,代码来源:EnumBuilder.java

示例5: getSymbolObj

import com.sun.codemodel.JEnumConstant; //导入方法依赖的package包/类
public JExpression getSymbolObj(String symbol){
	JEnumConstant obj = enums.get(symbol);
	if(obj == null){
		obj = clazz.enumConstant(symbol.toUpperCase());
		String pseudo = g.getPseudonym(symbol);
		if(pseudo != null){
			obj.arg(JExpr.lit(pseudo));
		}
		enums.put(symbol, obj);
	}
	return obj;
}
 
开发者ID:tbepler,项目名称:LRPaGe,代码行数:13,代码来源:SymbolsGenerator.java

示例6: getParamTypeEnum

import com.sun.codemodel.JEnumConstant; //导入方法依赖的package包/类
private JClass getParamTypeEnum(Filter filter) throws JClassAlreadyExistsException {
    String enumName = camel(filter.getName(), true) + "Option";
    if (pkg.isDefined(enumName)) {
        return pkg._getClass(enumName);
    }
    List<Option> options = filter.getOption();
    if (options.size() == 1) {/*turn into '*Only' method?*/}
    if (options.size() == 2) {
        if (ImmutableSet.of("true","false").equals(
                ImmutableSet.of(options.get(0).getValue().toLowerCase(),
                    options.get(1).getValue().toLowerCase()
                )
            )) {
            return model.ref(Boolean.class);
        }
    }
    
    
    JDefinedClass valueEnum = pkg._enum(enumName);
    
    JFieldVar valField = valueEnum.field(JMod.PRIVATE|JMod.FINAL, String.class, "value");
    JMethod ctor = valueEnum.constructor(JMod.PRIVATE);
    JVar param = ctor.param(String.class, "val");
    ctor.body().assign(valField, param);
    
    JMethod toString = valueEnum.method(JMod.PUBLIC, String.class, "toString");
    toString.annotate(Override.class);
    toString.body()._return(valField);
    
    for (Option option : options) {
        String optionName = option.getValue().toUpperCase().replace(' ', '_');
        JEnumConstant optionCst = valueEnum.enumConstant(optionName);
        optionCst.arg(JExpr.lit(option.getValue()));
    }
    return valueEnum;
}
 
开发者ID:mbst,项目名称:glycerin,代码行数:37,代码来源:FeedQueryGenerator.java

示例7: addEnumConstants

import com.sun.codemodel.JEnumConstant; //导入方法依赖的package包/类
private void addEnumConstants(JsonNode node, JDefinedClass _enum) {
    for (Iterator<JsonNode> values = node.elements(); values.hasNext();) {
        JsonNode value = values.next();

        if (!value.isNull()) {
            JEnumConstant constant = _enum.enumConstant(getConstantName(value.asText()));
            constant.arg(JExpr.lit(value.asText()));
        }
    }
}
 
开发者ID:fge,项目名称:jsonschema2pojo,代码行数:11,代码来源:EnumRule.java


注:本文中的com.sun.codemodel.JEnumConstant.arg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。