com.sun.codemodel.JClass.staticInvoke()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(79)

本文整理了Java中com.sun.codemodel.JClass.staticInvoke()方法的一些代码示例,展示了JClass.staticInvoke()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JClass.staticInvoke()方法的具体详情如下:
包路径:com.sun.codemodel.JClass
类名称:JClass
方法名:staticInvoke

JClass.staticInvoke介绍

[英]Generates a static method invocation.
[中]生成静态方法调用。

代码示例

代码示例来源:origin: joelittlejohn/jsonschema2pojo

JInvocation invokeCreate = fieldType.owner().ref(URI.class).staticInvoke("create");
return invokeCreate.arg(JExpr.lit(node.asText()));

代码示例来源:origin: joelittlejohn/jsonschema2pojo

JInvocation invokeAsList = fieldType.owner().ref(Arrays.class).staticInvoke("asList");
for (JsonNode defaultValue : node) {
  invokeAsList.arg(getDefaultValue(listGenericType, defaultValue));

代码示例来源:origin: joelittlejohn/jsonschema2pojo

JInvocation invokeAsList = fieldType.owner().ref(Arrays.class).staticInvoke("asList");
for (JsonNode defaultValue : node) {
  invokeAsList.arg(getDefaultValue(setGenericType, defaultValue));

代码示例来源:origin: joelittlejohn/jsonschema2pojo

private JMethod addGetter(JDefinedClass c, JFieldVar field, String jsonPropertyName, JsonNode node, boolean isRequired, boolean usesOptional) {
  JType type = getReturnType(c, field, isRequired, usesOptional);
  JMethod getter = c.method(JMod.PUBLIC, type, getGetterName(jsonPropertyName, field.type(), node));
  JBlock body = getter.body();
  if ((ruleFactory.getGenerationConfig().isUseOptionalForGetters() || usesOptional) && !isRequired
      && field.type().isReference()) {
    body._return(c.owner().ref("java.util.Optional").staticInvoke("ofNullable").arg(field));
  } else {
    body._return(field);
  }
  return getter;
}

代码示例来源:origin: joelittlejohn/jsonschema2pojo

if ("double".equals(fieldVar.type().name())) {
    JClass doubleClass = jclass.owner().ref(Double.class);
    fieldEquals = doubleClass.staticInvoke("doubleToLongBits").arg(thisFieldRef).eq(
        doubleClass.staticInvoke("doubleToLongBits").arg(otherFieldRef));
  } else if ("float".equals(fieldVar.type().name())) {
    JClass floatClass = jclass.owner().ref(Float.class);
    fieldEquals = floatClass.staticInvoke("floatToIntBits").arg(thisFieldRef).eq(
        floatClass.staticInvoke("floatToIntBits").arg(otherFieldRef));
  } else {
    fieldEquals = thisFieldRef.eq(otherFieldRef);
  fieldEquals = jclass.owner().ref(Arrays.class).staticInvoke("equals").arg(thisFieldRef).arg(otherFieldRef);
} else {
  fieldEquals = thisFieldRef.eq(otherFieldRef).cor(

代码示例来源:origin: joelittlejohn/jsonschema2pojo

} else if ("double".equals(fieldVar.type().name())) {
    JClass doubleClass = jclass.owner().ref(Double.class);
    JExpression longField = doubleClass.staticInvoke("doubleToLongBits").arg(fieldRef);
    fieldHash = JExpr.cast(jclass.owner().INT,
        longField.xor(longField.shrz(JExpr.lit(32))));
  } else if ("float".equals(fieldVar.type().name())) {
    fieldHash = jclass.owner().ref(Float.class).staticInvoke("floatToIntBits").arg(fieldRef);
  } else {
    fieldHash = JExpr.cast(jclass.owner().INT, fieldRef);
  fieldHash = jclass.owner().ref(Arrays.class).staticInvoke("hashCode").arg(fieldRef);
} else {
  fieldHash = JOp.cond(fieldRef.eq(JExpr._null()), JExpr.lit(0), fieldRef.invoke("hashCode"));

代码示例来源:origin: apache/drill

sub.assign(
 oiArray.component(JExpr.lit(i)),
 oih.staticInvoke("getDrillObjectInspector")
  .arg(mode.staticInvoke("valueOf").arg(JExpr.lit(argTypes[i].getMode().getNumber())))
  .arg(mt.staticInvoke("valueOf").arg(JExpr.lit(argTypes[i].getMinorType().getNumber())))
  .arg((((PrimitiveObjectInspector) returnOI).getPrimitiveCategory() ==
    PrimitiveObjectInspector.PrimitiveCategory.STRING) ? JExpr.lit(true) : JExpr.lit(false)));

代码示例来源:origin: joelittlejohn/jsonschema2pojo

.invoke("append").arg(JExpr.lit('@'))
.invoke("append").arg(
    jclass.owner().ref(Integer.class).staticInvoke("toHexString").arg(
        jclass.owner().ref(System.class).staticInvoke("identityHashCode").arg(JExpr._this())))
.invoke("append").arg(JExpr.lit('[')));
        JExpr.refthis(fieldVar.name()).eq(JExpr._null()),
        JExpr.lit("<null>"),
        jclass.owner().ref(Arrays.class).staticInvoke("toString")
            .arg(JExpr.refthis(fieldVar.name()))
            .invoke("replace").arg(JExpr.lit('[')).arg(JExpr.lit('{'))

代码示例来源:origin: org.brightify.torch/torch-compiler

@Override
protected JExpression marshallValue(EntityDescriptionGenerator.ToRawEntityHolder holder,
                  PropertyMirror propertyMirror) {
  JExpression getValue = super.marshallValue(holder, propertyMirror);
  return CodeModelTypes.SERIALIZER.staticInvoke("serialize").arg(getValue);
}

代码示例来源:origin: org.jvnet.hyperjaxb3/hyperjaxb3-ejb-plugin

@Override
public JExpression unwrapCondifiton(JExpression source) {
  final JExpression isElement = codeModel.ref(JAXBContextUtils.class)
      .staticInvoke("isMarshallable").arg(contextPath).arg(source);
  return isElement;
}

代码示例来源:origin: org.jvnet.jaxbvalidation/jaxbvalidation-core

public JExpression countLength(final JCodeModel codeModel, final JExpression value) {
 final JClass unicodeUtil = codeModel.ref(UnicodeUtil.class);
 return JOp.plus(
   unicodeUtil.staticInvoke("countLength").arg(value.invoke("getNamespaceURI")),
   unicodeUtil.staticInvoke("countLength").arg(value.invoke("getLocalPart")));
}

代码示例来源:origin: io.konig/konig-schemagen

private void durationValue(JCodeModel model, URI predicate, Map<URI, JVar> properties, boolean isFunctional,
    JVar pojoVar, JVar jsonParser, JCase caseBlock) {
  JClass durationType = model.ref(Duration.class);
  JExpression value = durationType.staticInvoke("parse").arg(jsonParser.invoke("getValueAsString"));
  fieldValue(model, predicate, properties, isFunctional, pojoVar, jsonParser, caseBlock, value);
}

代码示例来源:origin: e-biz/androidkickstartr

JInvocation createFromResource = arrayAdapter.staticInvoke("createFromResource"). //

代码示例来源:origin: org.metatype.sxc/sxc-core

private JVar createVar( Class<?> cls, Class parser) {
  JClass jcls = (JClass) model._ref(parser);
  
  return method.body().decl(model._ref(cls), "value", 
               jcls.staticInvoke("valueOf").arg(JExpr.direct("_attValue")));
}

代码示例来源:origin: stackoverflow.com

JCodeModel model = new JCodeModel();
JClass mapper = model.directClass("com.another.Mapper");
JClass factory = model.directClass("com.another.MapperSingleton");
JDefinedClass dc = model._class("com.example.Something");
JMethod method = dc.method(JMod.PUBLIC | JMod.STATIC, mapper, "testMethod");
method.body()._return(factory.staticInvoke("getMapperInstance"));
model.build(destinationDirectory);

代码示例来源:origin: org.jvnet.hyperjaxb3/hyperjaxb3-ejb-plugin

@Override
protected JExpression unwrap(JExpression source) {
  return codeModel.ref(JAXBElementUtils.class).staticInvoke("getValue")
      .arg(
          JExpr.cast(codeModel.ref(JAXBElement.class).narrow(
              type.toType(outline.parent(), Aspect.EXPOSED)
                  .boxify()), source));
}

代码示例来源:origin: org.brightify.torch/torch-compiler

@Override
protected JExpression fromRawEntity(EntityDescriptionGenerator.CreateFromRawEntityHolder holder,
                  PropertyMirror propertyMirror) {
  JExpression getBlob = holder.rawEntity.invoke("getBlob").arg(JExpr.lit(propertyMirror.getSafeName()));
  JExpression propertyTypeClass = CodeModelTypes.ref(propertyMirror).dotclass();
  return CodeModelTypes.SERIALIZER.staticInvoke("deserialize").arg(getBlob).arg(propertyTypeClass);
}

代码示例来源:origin: org.jvnet.hyperjaxb3/hyperjaxb3-ejb-plugin

@Override
protected JExpression wrap(JExpression source) {
  final JExpression core = getCore();
  return codeModel.ref(JAXBElementUtils.class).staticInvoke("wrap").arg(
      core).arg(source).arg(
      elementType.toType(outline.parent(), Aspect.EXPOSED).boxify()
          .dotclass());
}

代码示例来源:origin: johncarl81/transfuse

@Override
public JStatement buildFieldSet(boolean cast, ASTField field, TypedExpression expression, TypedExpression containerExpression) {
  //InjectionUtil.getInstance().setField(Class targetClass, Object target, String field, Object value)
  return generationUtil.ref(InjectionUtil.class).staticInvoke(InjectionUtil.SET_FIELD_METHOD)
      .arg(generationUtil.ref(containerExpression.getType()).dotclass())
      .arg(containerExpression.getExpression())
      .arg(field.getName())
      .arg(expression.getExpression());
}

代码示例来源:origin: org.jsonschema2pojo/jsonschema2pojo-core

private JMethod addGetter(JDefinedClass c, JFieldVar field, String jsonPropertyName, JsonNode node, boolean isRequired, boolean usesOptional) {
  JType type = getReturnType(c, field, isRequired, usesOptional);
  JMethod getter = c.method(JMod.PUBLIC, type, getGetterName(jsonPropertyName, field.type(), node));
  JBlock body = getter.body();
  if ((ruleFactory.getGenerationConfig().isUseOptionalForGetters() || usesOptional) && !isRequired
      && field.type().isReference()) {
    body._return(c.owner().ref("java.util.Optional").staticInvoke("ofNullable").arg(field));
  } else {
    body._return(field);
  }
  return getter;
}

相关文章