Java源码示例:org.eclipse.xtext.common.types.JvmIntAnnotationValue
示例1
private JvmAnnotationValue createIntAnnotationValue(Object value) {
JvmIntAnnotationValue annotationValue = TypesFactory.eINSTANCE.createJvmIntAnnotationValue();
if (value != null) {
@SuppressWarnings("unchecked")
InternalEList<Object> values = (InternalEList<Object>)(InternalEList<?>)annotationValue.getValues();
if (value instanceof Object[]) {
for (Object element : (Object[])value) {
if (element instanceof Integer) {
values.addUnique(element);
} else if (element != null) {
values.addUnique(((Number)element).intValue());
}
}
} else if (value instanceof Integer) {
values.addUnique(value);
} else if (value instanceof Number) {
values.addUnique(((Number)value).intValue());
}
}
return annotationValue;
}
示例2
@Test
public void testIntAnnotationValue_01() throws Exception {
JvmIntAnnotationValue value = (JvmIntAnnotationValue) getAnnotationValue("intValue", true);
assertEquals(1, value.getValues().size());
Integer integer = value.getValues().get(0);
assertEquals(34, integer.intValue());
}
示例3
@Test
public void testIntAnnotationValue_02() throws Exception {
JvmIntAnnotationValue value = (JvmIntAnnotationValue) getMethodParameterAnnotationValue("intValue", true);
assertEquals(1, value.getValues().size());
Integer integer = value.getValues().get(0);
assertEquals(34, integer.intValue());
}
示例4
@Test
public void testIntAnnotationValue_03() throws Exception {
JvmIntAnnotationValue value = (JvmIntAnnotationValue) getConstructorParameterAnnotationValue("intValue", true);
assertEquals(1, value.getValues().size());
Integer integer = value.getValues().get(0);
assertEquals(34, integer.intValue());
}
示例5
@Test
public void testDefaultIntAnnotationValue_01() throws Exception {
JvmIntAnnotationValue value = (JvmIntAnnotationValue) getDefaultAnnotationValue("intValue");
assertEquals(1, value.getValues().size());
Integer integer = value.getValues().get(0);
assertEquals(34, integer.intValue());
}
示例6
@Test
public void testIntAnnotationValue_01() throws Exception {
JvmIntAnnotationValue value = (JvmIntAnnotationValue) getAnnotationValue("intValue", true);
assertEquals(1, value.getValues().size());
Integer integer = value.getValues().get(0);
assertEquals(34, integer.intValue());
}
示例7
@Test
public void testIntAnnotationValue_02() throws Exception {
JvmIntAnnotationValue value = (JvmIntAnnotationValue) getMethodParameterAnnotationValue("intValue", true);
assertEquals(1, value.getValues().size());
Integer integer = value.getValues().get(0);
assertEquals(34, integer.intValue());
}
示例8
@Test
public void testIntAnnotationValue_03() throws Exception {
JvmIntAnnotationValue value = (JvmIntAnnotationValue) getConstructorParameterAnnotationValue("intValue", true);
assertEquals(1, value.getValues().size());
Integer integer = value.getValues().get(0);
assertEquals(34, integer.intValue());
}
示例9
@Test
public void testDefaultIntAnnotationValue_01() throws Exception {
JvmIntAnnotationValue value = (JvmIntAnnotationValue) getDefaultAnnotationValue("intValue");
assertEquals(1, value.getValues().size());
Integer integer = value.getValues().get(0);
assertEquals(34, integer.intValue());
}
示例10
@Test
public void testIntAnnotationValue_01() throws Exception {
JvmIntAnnotationValue value = (JvmIntAnnotationValue) getAnnotationValue("intValue", true);
assertEquals(1, value.getValues().size());
Integer integer = value.getValues().get(0);
assertEquals(34, integer.intValue());
}
示例11
@Test
public void testIntAnnotationValue_02() throws Exception {
JvmIntAnnotationValue value = (JvmIntAnnotationValue) getMethodParameterAnnotationValue("intValue", true);
assertEquals(1, value.getValues().size());
Integer integer = value.getValues().get(0);
assertEquals(34, integer.intValue());
}
示例12
@Test
public void testIntAnnotationValue_03() throws Exception {
JvmIntAnnotationValue value = (JvmIntAnnotationValue) getConstructorParameterAnnotationValue("intValue", true);
assertEquals(1, value.getValues().size());
Integer integer = value.getValues().get(0);
assertEquals(34, integer.intValue());
}
示例13
@Test
public void testDefaultIntAnnotationValue_01() throws Exception {
JvmIntAnnotationValue value = (JvmIntAnnotationValue) getDefaultAnnotationValue("intValue");
assertEquals(1, value.getValues().size());
Integer integer = value.getValues().get(0);
assertEquals(34, integer.intValue());
}
示例14
/**
* This handles model notifications by calling {@link #updateChildren} to update any cached
* children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void notifyChanged(Notification notification)
{
updateChildren(notification);
switch (notification.getFeatureID(JvmIntAnnotationValue.class))
{
case TypesPackage.JVM_INT_ANNOTATION_VALUE__VALUES:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
}
super.notifyChanged(notification);
}
示例15
protected void _setValue(final JvmIntAnnotationValue it, final short[] value, final String componentType, final boolean mustBeArray) {
final Consumer<Short> _function = (Short v) -> {
EList<Integer> _values = it.getValues();
_values.add(Integer.valueOf(((int) (v).shortValue())));
};
((List<Short>)Conversions.doWrapArray(value)).forEach(_function);
}
示例16
protected void _setValue(final JvmIntAnnotationValue it, final byte[] value, final String componentType, final boolean mustBeArray) {
final Consumer<Byte> _function = (Byte v) -> {
EList<Integer> _values = it.getValues();
_values.add(Integer.valueOf(((int) (v).byteValue())));
};
((List<Byte>)Conversions.doWrapArray(value)).forEach(_function);
}
示例17
protected void _setValue(final JvmIntAnnotationValue it, final char[] value, final String componentType, final boolean mustBeArray) {
final Consumer<Character> _function = (Character v) -> {
EList<Integer> _values = it.getValues();
_values.add(Integer.valueOf(((int) (v).charValue())));
};
((List<Character>)Conversions.doWrapArray(value)).forEach(_function);
}
示例18
protected void _toJavaLiteral(final JvmIntAnnotationValue it, final ITreeAppendable appendable, final GeneratorConfig config) {
final Procedure1<Integer> _function = (Integer it_1) -> {
appendable.append(it_1.toString());
};
this._loopExtensions.<Integer>forEachWithShortcut(appendable, it.getValues(), _function);
}
示例19
public void toJavaLiteral(final JvmAnnotationValue value, final ITreeAppendable appendable, final GeneratorConfig config) {
if (value instanceof JvmAnnotationAnnotationValue) {
_toJavaLiteral((JvmAnnotationAnnotationValue)value, appendable, config);
return;
} else if (value instanceof JvmBooleanAnnotationValue) {
_toJavaLiteral((JvmBooleanAnnotationValue)value, appendable, config);
return;
} else if (value instanceof JvmByteAnnotationValue) {
_toJavaLiteral((JvmByteAnnotationValue)value, appendable, config);
return;
} else if (value instanceof JvmCharAnnotationValue) {
_toJavaLiteral((JvmCharAnnotationValue)value, appendable, config);
return;
} else if (value instanceof JvmCustomAnnotationValue) {
_toJavaLiteral((JvmCustomAnnotationValue)value, appendable, config);
return;
} else if (value instanceof JvmDoubleAnnotationValue) {
_toJavaLiteral((JvmDoubleAnnotationValue)value, appendable, config);
return;
} else if (value instanceof JvmEnumAnnotationValue) {
_toJavaLiteral((JvmEnumAnnotationValue)value, appendable, config);
return;
} else if (value instanceof JvmFloatAnnotationValue) {
_toJavaLiteral((JvmFloatAnnotationValue)value, appendable, config);
return;
} else if (value instanceof JvmIntAnnotationValue) {
_toJavaLiteral((JvmIntAnnotationValue)value, appendable, config);
return;
} else if (value instanceof JvmLongAnnotationValue) {
_toJavaLiteral((JvmLongAnnotationValue)value, appendable, config);
return;
} else if (value instanceof JvmShortAnnotationValue) {
_toJavaLiteral((JvmShortAnnotationValue)value, appendable, config);
return;
} else if (value instanceof JvmStringAnnotationValue) {
_toJavaLiteral((JvmStringAnnotationValue)value, appendable, config);
return;
} else if (value instanceof JvmTypeAnnotationValue) {
_toJavaLiteral((JvmTypeAnnotationValue)value, appendable, config);
return;
} else {
throw new IllegalArgumentException("Unhandled parameter types: " +
Arrays.<Object>asList(value, appendable, config).toString());
}
}
示例20
protected void _setValue(final JvmIntAnnotationValue it, final int[] value, final String componentType, final boolean mustBeArray) {
EList<Integer> _values = it.getValues();
Iterables.<Integer>addAll(_values, ((Iterable<? extends Integer>)Conversions.doWrapArray(value)));
}
示例21
@SuppressWarnings({"checkstyle:returncount", "checkstyle:npathcomplexity", "checkstyle:cyclomaticcomplexity"})
private static String getAnnotationStringValue(JvmAnnotationValue value) {
if (value instanceof JvmAnnotationAnnotationValue) {
return ((JvmAnnotationAnnotationValue) value).getValues().get(0).getAnnotation().getIdentifier();
}
if (value instanceof JvmBooleanAnnotationValue) {
return ((JvmBooleanAnnotationValue) value).getValues().get(0).toString();
}
if (value instanceof JvmByteAnnotationValue) {
return ((JvmByteAnnotationValue) value).getValues().get(0).toString();
}
if (value instanceof JvmCharAnnotationValue) {
return ((JvmCharAnnotationValue) value).getValues().get(0).toString();
}
if (value instanceof JvmCustomAnnotationValue) {
final EObject evalue = ((JvmCustomAnnotationValue) value).getValues().get(0);
if (evalue instanceof XStringLiteral) {
return ((XStringLiteral) evalue).getValue();
}
if (evalue instanceof XNumberLiteral) {
return ((XNumberLiteral) evalue).getValue();
}
if (evalue instanceof XBooleanLiteral) {
return ((XNumberLiteral) evalue).getValue();
}
if (evalue instanceof XTypeLiteral) {
return ((XTypeLiteral) evalue).getType().getIdentifier();
}
}
if (value instanceof JvmDoubleAnnotationValue) {
return ((JvmDoubleAnnotationValue) value).getValues().get(0).toString();
}
if (value instanceof JvmEnumAnnotationValue) {
return ((JvmEnumAnnotationValue) value).getValues().get(0).getSimpleName();
}
if (value instanceof JvmFloatAnnotationValue) {
return ((JvmFloatAnnotationValue) value).getValues().get(0).toString();
}
if (value instanceof JvmIntAnnotationValue) {
return ((JvmIntAnnotationValue) value).getValues().get(0).toString();
}
if (value instanceof JvmLongAnnotationValue) {
return ((JvmLongAnnotationValue) value).getValues().get(0).toString();
}
if (value instanceof JvmShortAnnotationValue) {
return ((JvmShortAnnotationValue) value).getValues().get(0).toString();
}
if (value instanceof JvmStringAnnotationValue) {
return ((JvmStringAnnotationValue) value).getValues().get(0);
}
if (value instanceof JvmTypeAnnotationValue) {
return ((JvmTypeAnnotationValue) value).getValues().get(0).getIdentifier();
}
return null;
}