com.sun.codemodel.JStringLiteral Java Examples
The following examples show how to use
com.sun.codemodel.JStringLiteral.
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: RamlInterpreterTest.java From springmvc-raml-plugin with Apache License 2.0 | 5 votes |
private void assertPatternValue(JAnnotationUse jAnnotationUse, String expectedPattern) throws Exception { JAnnotationValue jAnnotationValue = jAnnotationUse.getAnnotationMembers().get("pattern"); Field value = jAnnotationValue.getClass().getDeclaredField("value"); value.setAccessible(true); JStringLiteral object = (JStringLiteral) value.get(jAnnotationValue); assertThat(object.str, is(expectedPattern)); }
Example #2
Source File: DefaultTypeUse.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 5 votes |
public JExpression createConstant(Outline outline, XmlString lexical) { if (isCollection()) return null; if (adapter == null) return coreType.createConstant(outline, lexical); // [RESULT] new Adapter().unmarshal(CONSTANT); JExpression cons = coreType.createConstant(outline, lexical); @SuppressWarnings("unchecked") Class<? extends XmlAdapter<?, ?>> atype = (Class<? extends XmlAdapter<?, ?>>) adapter .getAdapterIfKnown(); // try to run the adapter now rather than later. if (cons instanceof JStringLiteral && atype != null) { JStringLiteral scons = (JStringLiteral) cons; @SuppressWarnings("unchecked") XmlAdapter<Object, String> a = (XmlAdapter<Object, String>) ClassFactory .create(atype); try { Object value = a.unmarshal(scons.str); if (value instanceof String) { return JExpr.lit((String) value); } } catch (Exception e) { // assume that we can't eagerly bind this } } return JExpr._new(adapter.getAdapterClass(outline)).invoke("unmarshal") .arg(cons); }
Example #3
Source File: PMMLPlugin.java From jpmml-model with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public JExpression compute(Outline outline){ JExpression expression = computeInit(outline); if((expression instanceof JFieldRef) || (expression instanceof JStringLiteral)){ setField(null); return expression; } return JExpr.ref(getField()); }