Java Code Examples for org.eclipse.xtext.xbase.lib.Procedures.Procedure3#apply()
The following examples show how to use
org.eclipse.xtext.xbase.lib.Procedures.Procedure3#apply() .
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: ProcedureExtensions.java From xtext-lib with Eclipse Public License 2.0 | 5 votes |
/** * Curries a procedure that takes three arguments. * * @param procedure * the original procedure. May not be <code>null</code>. * @param argument * the fixed first argument of {@code procedure}. * @return a procedure that takes two arguments. Never <code>null</code>. */ @Pure public static <P1, P2, P3> Procedure2<P2, P3> curry(final Procedure3<? super P1, ? super P2, ? super P3> procedure, final P1 argument) { if (procedure == null) throw new NullPointerException("procedure"); return new Procedure2<P2, P3>() { @Override public void apply(P2 p2, P3 p3) { procedure.apply(argument, p2, p3); } }; }
Example 2
Source File: MapExtensions.java From xtext-lib with Eclipse Public License 2.0 | 5 votes |
/** * Applies the given {@code procedure} for each {@link java.util.Map.Entry key value pair} of the given {@code map}. * The procedure takes the key, the value and a loop counter. If the counter would overflow, {@link Integer#MAX_VALUE} * is returned for all subsequent pairs. The first pair is at index zero. * * @param map * the map. May not be <code>null</code>. * @param procedure * the procedure. May not be <code>null</code>. */ public static <K, V> void forEach(Map<K, V> map, Procedure3<? super K, ? super V, ? super Integer> procedure) { if (procedure == null) throw new NullPointerException("procedure"); int i = 0; for (Map.Entry<K, V> entry : map.entrySet()) { procedure.apply(entry.getKey(), entry.getValue(), i); if (i != Integer.MAX_VALUE) i++; } }
Example 3
Source File: AbstractExtraLanguageValidator.java From sarl with Apache License 2.0 | 5 votes |
/** Do a type mapping check. * * @param source the source of the type. * @param type the type to check. * @param errorHandler the error handler. * @return {@code true} if a type mapping is defined. */ protected boolean doTypeMappingCheck(EObject source, JvmType type, Procedure3<? super EObject, ? super JvmType, ? super String> errorHandler) { if (source != null && type != null) { final ExtraLanguageTypeConverter converter = getTypeConverter(); final String qn = type.getQualifiedName(); if (converter != null && !converter.hasConversion(qn)) { if (errorHandler != null) { errorHandler.apply(source, type, qn); } return false; } } return true; }