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


Java Conversions类代码示例

本文整理汇总了Java中org.eclipse.xtext.xbase.lib.Conversions的典型用法代码示例。如果您正苦于以下问题:Java Conversions类的具体用法?Java Conversions怎么用?Java Conversions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Conversions类属于org.eclipse.xtext.xbase.lib包,在下文中一共展示了Conversions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: map

import org.eclipse.xtext.xbase.lib.Conversions; //导入依赖的package包/类
public static List<Ddl2Bean.Klass> map(final Table table) {
  Column[] _columns = table.getColumns();
  final Function1<Column, Ddl2Bean.Klass> _function = (Column column) -> {
    Ddl2Bean.Klass _xblockexpression = null;
    {
      String _type = column.getType();
      String type = Ddl2Bean.fieldType(_type);
      String columnName = column.getName();
      String _name = column.getName();
      String[] _split = _name.split("_");
      final Function1<String, String> _function_1 = (String it) -> {
        return StringExtensions.toFirstUpper(it);
      };
      List<String> _map = ListExtensions.<String, String>map(((List<String>)Conversions.doWrapArray(_split)), _function_1);
      String _join = IterableExtensions.join(_map);
      String name = StringExtensions.toFirstLower(_join);
      String comment = column.getDescription();
      _xblockexpression = new Ddl2Bean.Klass(type, name, columnName, comment);
    }
    return _xblockexpression;
  };
  return ListExtensions.<Column, Ddl2Bean.Klass>map(((List<Column>)Conversions.doWrapArray(_columns)), _function);
}
 
开发者ID:East196,项目名称:maker,代码行数:24,代码来源:Ddl2Bean.java

示例2: _generateArguments

import org.eclipse.xtext.xbase.lib.Conversions; //导入依赖的package包/类
private List<ParameterValueMapping> _generateArguments(final TAbstractMessages tMessage, final Operation operation, final Lifeline lifeline) {
  List<ParameterValueMapping> _xblockexpression = null;
  {
    final List<ParameterValueMapping> result = CollectionLiterals.<ParameterValueMapping>newArrayList();
    EList<Parameter> _parameters = operation.getParameters();
    boolean _isEmpty = _parameters.isEmpty();
    boolean _equals = (_isEmpty == false);
    if (_equals) {
      EList<Parameter> _parameters_1 = operation.getParameters();
      int _length = ((Object[])Conversions.unwrapArray(_parameters_1, Object.class)).length;
      int _minus = (_length - 1);
      IntegerRange _upTo = new IntegerRange(0, _minus);
      for (final Integer i : _upTo) {
        EList<Parameter> _parameters_2 = operation.getParameters();
        Parameter _get = _parameters_2.get((i).intValue());
        EList<TParameter> _arguments = tMessage.getArguments();
        TParameter _get_1 = _arguments.get((i).intValue());
        ParameterValueMapping _createParameterValueMapping = this.createParameterValueMapping(_get, _get_1, lifeline);
        result.add(_createParameterValueMapping);
      }
    }
    _xblockexpression = result;
  }
  return _xblockexpression;
}
 
开发者ID:mjorod,项目名称:textram,代码行数:26,代码来源:MessageViewsGenerator.java

示例3: _privk3_step

import org.eclipse.xtext.xbase.lib.Conversions; //导入依赖的package包/类
protected static void _privk3_step(final StateAspectStateAspectProperties _self_, final State _self, final String inputString) {
  try {
    final Function1<Transition, Boolean> _function = (Transition t) -> {
      return Boolean.valueOf(inputString.startsWith(t.getInput()));
    };
    final Iterable<Transition> validTransitions = IterableExtensions.<Transition>filter(_self.getOutgoingTransitions(), _function);
    boolean _isEmpty = IterableExtensions.isEmpty(validTransitions);
    if (_isEmpty) {
      throw new Exception("No Transition");
    }
    int _size = IterableExtensions.size(validTransitions);
    boolean _greaterThan = (_size > 1);
    if (_greaterThan) {
      throw new Exception("Non Determinism");
    }
    TransitionAspect.fire(((Transition[])Conversions.unwrapArray(validTransitions, Transition.class))[0]);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:gemoc-studio,代码行数:21,代码来源:StateAspect.java

示例4: findType

import org.eclipse.xtext.xbase.lib.Conversions; //导入依赖的package包/类
@Override
public NameEnvironmentAnswer findType(final char[][] compoundTypeName) {
  try {
    final Function1<char[], String> _function = (char[] it) -> {
      return String.valueOf(it);
    };
    String _join = IterableExtensions.join(ListExtensions.<char[], String>map(((List<char[]>)Conversions.doWrapArray(compoundTypeName)), _function), "/");
    final String fileName = (_join + ".class");
    boolean _containsKey = this.cache.containsKey(fileName);
    if (_containsKey) {
      return this.cache.get(fileName);
    }
    final URL url = this.classLoader.getResource(fileName);
    if ((url == null)) {
      this.cache.put(fileName, null);
      return null;
    }
    final ClassFileReader reader = ClassFileReader.read(url.openStream(), fileName);
    final NameEnvironmentAnswer result = new NameEnvironmentAnswer(reader, null);
    this.cache.put(fileName, result);
    return result;
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:26,代码来源:InMemoryJavaCompiler.java

示例5: convertArrayToList

import org.eclipse.xtext.xbase.lib.Conversions; //导入依赖的package包/类
private void convertArrayToList(final LightweightTypeReference left, final ITreeAppendable appendable, XExpression context,
		final Later expression) {
	if (!(context.eContainer() instanceof XCastedExpression)) {
		if (context.eContainer() instanceof XAbstractFeatureCall) {
			appendable.append("((");
		} else {
			appendable.append("(");
		}
		appendable.append(left);
		appendable.append(")");
	}
	appendable.append(Conversions.class);
	appendable.append(".doWrapArray(");
	expression.exec(appendable);
	if (!(context.eContainer() instanceof XCastedExpression)) {
		if (context.eContainer() instanceof XAbstractFeatureCall) {
			appendable.append("))");
		} else {
			appendable.append(")");
		}
	} else {
		appendable.append(")");
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:25,代码来源:TypeConvertingCompiler.java

示例6: _doEvaluate

import org.eclipse.xtext.xbase.lib.Conversions; //导入依赖的package包/类
protected Object _doEvaluate(XListLiteral literal, IEvaluationContext context, CancelIndicator indicator) {
	IResolvedTypes resolveTypes = typeResolver.resolveTypes(literal);
	LightweightTypeReference type = resolveTypes.getActualType(literal);
	List<Object> list = newArrayList();
	for(XExpression element: literal.getElements()) {
		if (indicator.isCanceled())
			throw new InterpreterCanceledException();
		list.add(internalEvaluate(element, context, indicator));
	}
	if(type != null && type.isArray()) {
		try {
			LightweightTypeReference componentType = type.getComponentType();
			return Conversions.unwrapArray(list, getJavaType(componentType.getType()));
		} catch (ClassNotFoundException e) {
		}
	}
	return Collections.unmodifiableList(list);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:19,代码来源:XbaseInterpreter.java

示例7: resolvesIdentifiablesTo

import org.eclipse.xtext.xbase.lib.Conversions; //导入依赖的package包/类
@Override
public void resolvesIdentifiablesTo(final String expression, final String... types) {
  try {
    final String expressionWithQualifiedNames = expression.replace("$$", "org::eclipse::xtext::xbase::lib::");
    final XExpression xExpression = this.expression(expressionWithQualifiedNames, false);
    final IResolvedTypes resolvedTypes = this.getTypeResolver().resolveTypes(xExpression);
    final List<JvmIdentifiableElement> identifiables = this.findIdentifiables(xExpression);
    Assert.assertFalse(identifiables.isEmpty());
    Assert.assertEquals(((List<String>)Conversions.doWrapArray(types)).size(), identifiables.size());
    final Procedure2<JvmIdentifiableElement, Integer> _function = (JvmIdentifiableElement identifiable, Integer index) -> {
      final LightweightTypeReference type = resolvedTypes.getActualType(identifiable);
      Assert.assertNotNull(type);
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("failed for identifiable at ");
      _builder.append(index);
      Assert.assertEquals(_builder.toString(), types[(index).intValue()], type.getSimpleName());
    };
    IterableExtensions.<JvmIdentifiableElement>forEach(identifiables, _function);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:23,代码来源:BatchIdentifiableTypeTest.java

示例8: resolvesConstructorCallsTo

import org.eclipse.xtext.xbase.lib.Conversions; //导入依赖的package包/类
@Override
public void resolvesConstructorCallsTo(final String expression, final String... types) {
  final String expressionWithQualifiedNames = expression.replace("$$", "org::eclipse::xtext::xbase::lib::");
  final List<XConstructorCall> featureCalls = this.findConstructorCalls(expressionWithQualifiedNames);
  Assert.assertFalse(featureCalls.isEmpty());
  Assert.assertEquals(((List<String>)Conversions.doWrapArray(types)).size(), featureCalls.size());
  final IResolvedTypes resolvedTypes = this.getTypeResolver().resolveTypes(IterableExtensions.<XConstructorCall>head(featureCalls));
  final Procedure2<XConstructorCall, Integer> _function = (XConstructorCall featureCall, Integer index) -> {
    final LightweightTypeReference type = resolvedTypes.getActualType(featureCall);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("failed for constructor call at ");
    _builder.append(index);
    Assert.assertEquals(_builder.toString(), types[(index).intValue()], type.getSimpleName());
  };
  IterableExtensions.<XConstructorCall>forEach(featureCalls, _function);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:BatchConstructorCallTypeTest.java

示例9: resolvesFeatureCallsTo

import org.eclipse.xtext.xbase.lib.Conversions; //导入依赖的package包/类
@Override
public void resolvesFeatureCallsTo(final String expression, final String... types) {
  final String expressionWithQualifiedNames = expression.replace("$$", "org::eclipse::xtext::xbase::lib::");
  final List<XAbstractFeatureCall> featureCalls = this.findFeatureCalls(expressionWithQualifiedNames);
  final IResolvedTypes resolvedTypes = this.getTypeResolver().resolveTypes(IterableExtensions.<XAbstractFeatureCall>head(featureCalls));
  final Iterable<XAbstractFeatureCall> actualFeatureCalls = this.filterTypeLiteralsAndPackageFragments(featureCalls);
  Assert.assertFalse(IterableExtensions.isEmpty(actualFeatureCalls));
  Assert.assertEquals(("" + actualFeatureCalls), ((List<String>)Conversions.doWrapArray(types)).size(), IterableExtensions.size(actualFeatureCalls));
  final Procedure2<XAbstractFeatureCall, Integer> _function = (XAbstractFeatureCall featureCall, Integer index) -> {
    final LightweightTypeReference type = resolvedTypes.getActualType(featureCall);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("failed for feature call at ");
    _builder.append(index);
    Assert.assertEquals(_builder.toString(), types[(index).intValue()], type.getSimpleName());
  };
  IterableExtensions.<XAbstractFeatureCall>forEach(actualFeatureCalls, _function);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:18,代码来源:BatchFeatureCallTypeTest.java

示例10: hasTypeArguments

import org.eclipse.xtext.xbase.lib.Conversions; //导入依赖的package包/类
@Override
protected void hasTypeArguments(final XExpression expression, final String... typeArguments) {
  final List<LightweightTypeReference> actualTypeArguments = this.resolvedTypes.getActualTypeArguments(expression);
  Assert.assertEquals(((List<String>)Conversions.doWrapArray(typeArguments)).size(), actualTypeArguments.size());
  final Procedure2<String, Integer> _function = (String typeArgument, Integer i) -> {
    StringConcatenation _builder = new StringConcatenation();
    String _join = IterableExtensions.join(((Iterable<?>)Conversions.doWrapArray(typeArguments)), ", ");
    _builder.append(_join);
    _builder.append(" vs ");
    final Function1<LightweightTypeReference, String> _function_1 = (LightweightTypeReference it) -> {
      return it.getSimpleName();
    };
    String _join_1 = IterableExtensions.join(ListExtensions.<LightweightTypeReference, String>map(actualTypeArguments, _function_1), ", ");
    _builder.append(_join_1);
    Assert.assertEquals(_builder.toString(), typeArgument, actualTypeArguments.get((i).intValue()).getSimpleName());
  };
  IterableExtensions.<String>forEach(((Iterable<String>)Conversions.doWrapArray(typeArguments)), _function);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:19,代码来源:BatchTypeArgumentTest.java

示例11: testAnnotation_1

import org.eclipse.xtext.xbase.lib.Conversions; //导入依赖的package包/类
@Test
public void testAnnotation_1() {
  try {
    final XExpression expression = this.expression("42", false);
    final Procedure1<JvmAnnotationType> _function = (JvmAnnotationType it) -> {
      EList<JvmMember> _members = it.getMembers();
      final Procedure1<JvmOperation> _function_1 = (JvmOperation it_1) -> {
        this.builder.setBody(it_1, expression);
      };
      JvmOperation _method = this.builder.toMethod(expression, "theTruth", this.references.getTypeForName(int.class, expression), _function_1);
      this.builder.<JvmOperation>operator_add(_members, _method);
    };
    final JvmAnnotationType clazz = this.builder.toAnnotationType(expression, "my.test.Foo", _function);
    final Class<?> compiledClass = this.compile(expression.eResource(), clazz);
    Assert.assertTrue(compiledClass.isAnnotation());
    final Method method = IterableExtensions.<Method>head(((Iterable<Method>)Conversions.doWrapArray(compiledClass.getMethods())));
    Assert.assertEquals("theTruth", method.getName());
    Assert.assertEquals(Integer.valueOf(42), method.getDefaultValue());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:23,代码来源:JvmModelGeneratorTest.java

示例12: testNestedAnnotationType

import org.eclipse.xtext.xbase.lib.Conversions; //导入依赖的package包/类
@Test
public void testNestedAnnotationType() {
  try {
    final XExpression expression = this.expression("42");
    final JvmGenericType outerClass = this.builder.toClass(expression, "my.outer.Clazz");
    EList<JvmMember> _members = outerClass.getMembers();
    final Procedure1<JvmAnnotationType> _function = (JvmAnnotationType it) -> {
      EList<JvmMember> _members_1 = it.getMembers();
      final Procedure1<JvmOperation> _function_1 = (JvmOperation it_1) -> {
        this.builder.setBody(it_1, expression);
      };
      JvmOperation _method = this.builder.toMethod(expression, "theTruth", this.references.getTypeForName(int.class, expression), _function_1);
      this.builder.<JvmOperation>operator_add(_members_1, _method);
    };
    JvmAnnotationType _annotationType = this.builder.toAnnotationType(expression, "MyAnnotation", _function);
    this.builder.<JvmAnnotationType>operator_add(_members, _annotationType);
    final Class<?> compiled = IterableExtensions.<Class<?>>head(((Iterable<Class<?>>)Conversions.doWrapArray(this.compile(expression.eResource(), outerClass).getDeclaredClasses())));
    Assert.assertEquals("my.outer.Clazz.MyAnnotation", compiled.getCanonicalName());
    Assert.assertEquals(Integer.valueOf(42), IterableExtensions.<Method>head(((Iterable<Method>)Conversions.doWrapArray(compiled.getDeclaredMethods()))).getDefaultValue());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:24,代码来源:JvmModelGeneratorTest.java

示例13: callRoutine1

import org.eclipse.xtext.xbase.lib.Conversions; //导入依赖的package包/类
public void callRoutine1(final Male person, final FamilyRegister familiesRegister, final Member member, @Extension final RoutinesFacade _routinesFacade) {
  EList<Family> collectionFamilies = familiesRegister.getFamilies();
  int _size = collectionFamilies.size();
  final List<String> familiesNames = new ArrayList<String>(_size);
  for (final Family f : collectionFamilies) {
    familiesNames.add(f.getLastName());
  }
  final String selectMsg = "Please select the family to which the person belongs.";
  final int selected = this.userInteracting.selectFromMessage(UserInteractionType.MODAL, selectMsg, ((String[])Conversions.unwrapArray(familiesNames, String.class)));
  final Family selectedFamily = collectionFamilies.get(selected);
  selectedFamily.setLastName(person.getFullName().split(" ")[1]);
  List<String> collectionRoles = new ArrayList<String>();
  Iterables.<String>addAll(collectionRoles, Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("Father", "Son")));
  final String selectMsgRoles = "Please select whether the person is a father or a son.";
  final List<String> _converted_collectionRoles = (List<String>)collectionRoles;
  final int selectedRole = this.userInteracting.selectFromMessage(UserInteractionType.MODAL, selectMsgRoles, ((String[])Conversions.unwrapArray(_converted_collectionRoles, String.class)));
  if ((selectedRole == 0)) {
    selectedFamily.setFather(member);
  } else {
    selectedFamily.getSons().add(member);
  }
  _routinesFacade.addCorr(person, selectedFamily);
}
 
开发者ID:vitruv-tools,项目名称:Vitruv,代码行数:24,代码来源:CreateMaleMemberOfFamilyRoutine.java

示例14: callRoutine1

import org.eclipse.xtext.xbase.lib.Conversions; //导入依赖的package包/类
public void callRoutine1(final Female person, final FamilyRegister familyRegister, final Member member, @Extension final RoutinesFacade _routinesFacade) {
  EList<Family> collectionFamilies = familyRegister.getFamilies();
  int _size = collectionFamilies.size();
  final List<String> familiesNames = new ArrayList<String>(_size);
  for (final Family f : collectionFamilies) {
    familiesNames.add(f.getLastName());
  }
  final String selectMsg = "Please select the family to which the person belongs.";
  final int selected = this.userInteracting.selectFromMessage(UserInteractionType.MODAL, selectMsg, ((String[])Conversions.unwrapArray(familiesNames, String.class)));
  final Family selectedFamily = collectionFamilies.get(selected);
  selectedFamily.setLastName(person.getFullName().split(" ")[1]);
  List<String> collectionRoles = new ArrayList<String>();
  Iterables.<String>addAll(collectionRoles, Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("Mother", "Daughter")));
  final String selectMsgRoles = "Please select whether the person is a mother or a daughter.";
  final List<String> _converted_collectionRoles = (List<String>)collectionRoles;
  final int selectedRole = this.userInteracting.selectFromMessage(UserInteractionType.MODAL, selectMsgRoles, ((String[])Conversions.unwrapArray(_converted_collectionRoles, String.class)));
  if ((selectedRole == 0)) {
    selectedFamily.setMother(member);
  } else {
    selectedFamily.getDaughters().add(member);
  }
  _routinesFacade.addCorr(person, selectedFamily);
}
 
开发者ID:vitruv-tools,项目名称:Vitruv,代码行数:24,代码来源:CreateFemaleMemberOfFamilyRoutine.java

示例15: createCopy

import org.eclipse.xtext.xbase.lib.Conversions; //导入依赖的package包/类
private static SerializableEObjectDescription createCopy(final IEObjectDescription desc) {
  if ((desc instanceof SerializableEObjectDescriptionProvider)) {
    return ((SerializableEObjectDescriptionProvider)desc).toSerializableEObjectDescription();
  }
  SerializableEObjectDescription _serializableEObjectDescription = new SerializableEObjectDescription();
  final Procedure1<SerializableEObjectDescription> _function = (SerializableEObjectDescription it) -> {
    it.setEClass(desc.getEClass());
    it.setEObjectURI(desc.getEObjectURI());
    it.qualifiedName = desc.getQualifiedName();
    int _size = ((List<String>)Conversions.doWrapArray(desc.getUserDataKeys())).size();
    HashMap<String, String> _hashMap = new HashMap<String, String>(_size);
    it.userData = _hashMap;
    String[] _userDataKeys = desc.getUserDataKeys();
    for (final String key : _userDataKeys) {
      it.userData.put(key, desc.getUserData(key));
    }
  };
  return ObjectExtensions.<SerializableEObjectDescription>operator_doubleArrow(_serializableEObjectDescription, _function);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:SerializableResourceDescription.java


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