Java 类org.eclipse.xtext.xbase.lib.Functions.Function3 实例源码

项目:xtext-extras    文件:LightweightTypeReferenceSerializerTest.java   
@Test
public void testFunctionType4() {
  FunctionTypeReference _newFunctionTypeReference = this.getOwner().newFunctionTypeReference(this.type(Function3.class));
  final Procedure1<FunctionTypeReference> _function = (FunctionTypeReference it) -> {
    it.setReturnType(this.typeRef(Object.class));
    it.addTypeArgument(this.typeRef(Object.class));
    it.addParameterType(this.typeRef(String.class));
    it.addTypeArgument(this.typeRef(String.class));
    ParameterizedTypeReference _typeRef = this.typeRef(List.class);
    final Procedure1<ParameterizedTypeReference> _function_1 = (ParameterizedTypeReference it_1) -> {
      WildcardTypeReference _newWildcardTypeReference = it_1.getOwner().newWildcardTypeReference();
      final Procedure1<WildcardTypeReference> _function_2 = (WildcardTypeReference it_2) -> {
        it_2.setLowerBound(this.typeRef(CharSequence.class));
      };
      WildcardTypeReference _doubleArrow = ObjectExtensions.<WildcardTypeReference>operator_doubleArrow(_newWildcardTypeReference, _function_2);
      it_1.addTypeArgument(_doubleArrow);
    };
    final ParameterizedTypeReference listOfCharSequence = ObjectExtensions.<ParameterizedTypeReference>operator_doubleArrow(_typeRef, _function_1);
    it.addParameterType(listOfCharSequence);
    it.addTypeArgument(listOfCharSequence);
    final ArrayTypeReference arrayOfObject = it.getOwner().newArrayTypeReference(this.typeRef(Object.class));
    it.addParameterType(arrayOfObject);
    it.addTypeArgument(arrayOfObject);
  };
  this.assertInJava(this.assertInXtend(ObjectExtensions.<FunctionTypeReference>operator_doubleArrow(_newFunctionTypeReference, _function), "(java.lang.String, java.util.List<? super java.lang.CharSequence>, java.lang.Object[])=>java.lang.Object"), "org.eclipse.xtext.xbase.lib.Functions$Function3<java.lang.Object, java.lang.String, java.util.List<? super java.lang.CharSequence>, java.lang.Object[]>");
}
项目:xtext-extras    文件:JvmTypesBuilderTest.java   
@Test
public void testInitializeSafely_0() {
  final Runnable _function = () -> {
    final Function3<EObject, String, Procedure1<? super JvmGenericType>, EObject> _function_1 = (EObject expr, String name, Procedure1<? super JvmGenericType> init) -> {
      return this._jvmTypesBuilder.toClass(expr, name, init);
    };
    this.<JvmGenericType>genericTestInitializeSafely(_function_1);
  };
  this.expectErrorLogging(2, _function);
}
项目:xtext-extras    文件:JvmTypesBuilderTest.java   
@Test
public void testInitializeSafely_1() {
  final Runnable _function = () -> {
    final Function3<EObject, String, Procedure1<? super JvmConstructor>, EObject> _function_1 = (EObject expr, String name, Procedure1<? super JvmConstructor> init) -> {
      return this._jvmTypesBuilder.toConstructor(expr, init);
    };
    this.<JvmConstructor>genericTestInitializeSafely(_function_1);
  };
  this.expectErrorLogging(2, _function);
}
项目:xtext-extras    文件:JvmTypesBuilderTest.java   
@Test
public void testInitializeSafely_2() {
  final Runnable _function = () -> {
    final Function3<EObject, String, Procedure1<? super JvmField>, EObject> _function_1 = (EObject expr, String name, Procedure1<? super JvmField> init) -> {
      return this._jvmTypesBuilder.toField(expr, name, null, init);
    };
    this.<JvmField>genericTestInitializeSafely(_function_1);
  };
  this.expectErrorLogging(2, _function);
}
项目:xtext-extras    文件:JvmTypesBuilderTest.java   
@Test
public void testInitializeSafely_3() {
  final Runnable _function = () -> {
    final Function3<EObject, String, Procedure1<? super JvmOperation>, EObject> _function_1 = (EObject expr, String name, Procedure1<? super JvmOperation> init) -> {
      return this._jvmTypesBuilder.toMethod(expr, name, null, init);
    };
    this.<JvmOperation>genericTestInitializeSafely(_function_1);
  };
  this.expectErrorLogging(2, _function);
}
项目:xtext-extras    文件:JvmTypesBuilderTest.java   
@Test
public void testInitializeSafely_4() {
  final Runnable _function = () -> {
    final Function3<EObject, String, Procedure1<? super JvmAnnotationType>, EObject> _function_1 = (EObject expr, String name, Procedure1<? super JvmAnnotationType> init) -> {
      return this._jvmTypesBuilder.toAnnotationType(expr, name, init);
    };
    this.<JvmAnnotationType>genericTestInitializeSafely(_function_1);
  };
  this.expectErrorLogging(2, _function);
}
项目:xtext-extras    文件:JvmTypesBuilderTest.java   
@Test
public void testInitializeSafely_5() {
  final Runnable _function = () -> {
    final Function3<EObject, String, Procedure1<? super JvmEnumerationType>, EObject> _function_1 = (EObject expr, String name, Procedure1<? super JvmEnumerationType> init) -> {
      return this._jvmTypesBuilder.toEnumerationType(expr, name, init);
    };
    this.<JvmEnumerationType>genericTestInitializeSafely(_function_1);
  };
  this.expectErrorLogging(2, _function);
}
项目:xtext-extras    文件:JvmTypesBuilderTest.java   
protected <T extends Object> void genericTestInitializeSafely(final Function3<? super EObject, ? super String, ? super Procedure1<? super T>, ? extends EObject> create) {
  final XNullLiteral expr = XbaseFactory.eINSTANCE.createXNullLiteral();
  final Wrapper<Boolean> initialized = new Wrapper<Boolean>(Boolean.valueOf(false));
  final Procedure1<T> _function = (T it) -> {
    initialized.set(Boolean.valueOf(true));
    throw new RuntimeException();
  };
  final EObject element = create.apply(expr, "foo", _function);
  Assert.assertTrue((initialized.get()).booleanValue());
  Assert.assertNotNull(element);
}
项目:xtext-lib    文件:FunctionExtensions.java   
/**
 * Curries a function that takes three arguments.
 * 
 * @param function
 *            the original function. May not be <code>null</code>.
 * @param argument
 *            the fixed first argument of {@code function}.
 * @return a function that takes two arguments. Never <code>null</code>.
 */
@Pure
public static <P1, P2, P3, RESULT> Function2<P2, P3, RESULT> curry(final Function3<? super P1, ? super P2, ? super P3, ? extends RESULT> function,
        final P1 argument) {
    if (function == null)
        throw new NullPointerException("function");
    return new Function2<P2, P3, RESULT>() {
        @Override
        public RESULT apply(P2 p2, P3 p3) {
            return function.apply(argument, p2, p3);
        }
    };
}
项目:xtext-lib    文件:FunctionExtensions.java   
/**
 * Curries a function that takes four arguments.
 * 
 * @param function
 *            the original function. May not be <code>null</code>.
 * @param argument
 *            the fixed first argument of {@code function}.
 * @return a function that takes three arguments. Never <code>null</code>.
 */
@Pure
public static <P1, P2, P3, P4, RESULT> Function3<P2, P3, P4, RESULT> curry(
        final Function4<? super P1, ? super P2, ? super P3, ? super P4, ? extends RESULT> function, final P1 argument) {
    if (function == null)
        throw new NullPointerException("function");
    return new Function3<P2, P3, P4, RESULT>() {
        @Override
        public RESULT apply(P2 p2, P3 p3, P4 p4) {
            return function.apply(argument, p2, p3, p4);
        }
    };
}
项目:Util    文件:SafeCallExtension.java   
/**
 * Calls some code safely.
 * Never throws an Exception.
 * @return
 * @return onError; if the code fails, otherwise the return value of call().
 */
public static <R, E1, E2, E3> R attempt(
        final Function3<E1, E2, E3, R> code, final E1 p1, final E2 p2,
        final E3 p3, final R onError) {
    try {
        return code.apply(p1, p2, p3);
    } catch (final Throwable t) {
        LOG.log(Level.SEVERE, t.getMessage(), t);
        return onError;
    }
}
项目:Util    文件:SafeCallExtension.java   
/**
 * Calls some code safely.
 * Never throws an Exception.
 * @return
 * @return null if the code fails, otherwise the return value of call().
 */
@Inline("com.blockwithme.util.xtend.SafeCallExtension.attempt($1, $2, $3, null)")
public static <R, E1, E2, E3> R attempt(
        final Function3<E1, E2, E3, R> code, final E1 p1, final E2 p2,
        final E3 p3) {
    return attempt(code, p1, p2, p3, null);
}