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


Java Procedures类代码示例

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


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

示例1: toGetter

import org.eclipse.xtext.xbase.lib.Procedures; //导入依赖的package包/类
/**
 * Creates a getter method for the given property name and the field name.
 * 
 * Example: <code>
 * public String getPropertyName() {
 *   return this.fieldName;
 * }
 * </code>
 * 
 * @return a getter method for a JavaBeans property, <code>null</code> if sourceElement or name are <code>null</code>.
 */
/* @Nullable */
public JvmOperation toGetter(/* @Nullable */ final EObject sourceElement, /* @Nullable */ final String propertyName, /* @Nullable */ final String fieldName, /* @Nullable */ JvmTypeReference typeRef) {
	if(sourceElement == null || propertyName == null || fieldName == null) 
		return null;
	JvmOperation result = typesFactory.createJvmOperation();
	result.setVisibility(JvmVisibility.PUBLIC);
	String prefix = (isPrimitiveBoolean(typeRef) ? "is" : "get");
	result.setSimpleName(prefix + Strings.toFirstUpper(propertyName));
	result.setReturnType(cloneWithProxies(typeRef));
	setBody(result, new Procedures.Procedure1<ITreeAppendable>() {
		@Override
		public void apply(/* @Nullable */ ITreeAppendable p) {
			if(p != null) {
				p = p.trace(sourceElement);
				p.append("return this.");
				p.append(javaKeywords.isJavaKeyword(fieldName) ? fieldName+"_" : fieldName);
				p.append(";");
			}
		}
	});
	return associate(sourceElement, result);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:34,代码来源:JvmTypesBuilder.java

示例2: toSetter

import org.eclipse.xtext.xbase.lib.Procedures; //导入依赖的package包/类
/**
 * Creates a setter method for the given properties name with the standard implementation assigning the passed
 * parameter to a similarly named field.
 * 
 * Example: <code>
 * public void setFoo(String foo) {
 *   this.foo = foo;
 * }
 * </code>
 *
 * @return a setter method for a JavaBeans property with the given name, <code>null</code> if sourceElement or name are <code>null</code>.
 */
/* @Nullable */ 
public JvmOperation toSetter(/* @Nullable */ final EObject sourceElement, /* @Nullable */ final String propertyName, /* @Nullable */ final String fieldName, /* @Nullable */ JvmTypeReference typeRef) {
	if(sourceElement == null || propertyName == null || fieldName == null) 
		return null;
	JvmOperation result = typesFactory.createJvmOperation();
	result.setVisibility(JvmVisibility.PUBLIC);
	result.setReturnType(references.getTypeForName(Void.TYPE,sourceElement));
	result.setSimpleName("set" + Strings.toFirstUpper(propertyName));
	result.getParameters().add(toParameter(sourceElement, propertyName, typeRef));
	setBody(result, new Procedures.Procedure1<ITreeAppendable>() {
		@Override
		public void apply(/* @Nullable */ ITreeAppendable p) {
			if(p != null) {
				p = p.trace(sourceElement);
				p.append("this.");
				p.append(javaKeywords.isJavaKeyword(fieldName) ? fieldName+"_" : fieldName);
				p.append(" = ");
				p.append(javaKeywords.isJavaKeyword(propertyName) ? propertyName+"_" : propertyName);
				p.append(";");
			}
		}
	});
	return associate(sourceElement, result);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:37,代码来源:JvmTypesBuilder.java

示例3: buildUri

import org.eclipse.xtext.xbase.lib.Procedures; //导入依赖的package包/类
public static String buildUri(final boolean procedure, final int functionParamCount) {
  final int paramCount = Math.min(6, functionParamCount);
  if (procedure) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("java:/Objects/");
    String _canonicalName = Procedures.class.getCanonicalName();
    _builder.append(_canonicalName);
    _builder.append("#");
    String _canonicalName_1 = Procedures.class.getCanonicalName();
    _builder.append(_canonicalName_1);
    _builder.append("$Procedure");
    _builder.append(paramCount);
    return _builder.toString();
  }
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("java:/Objects/");
  String _canonicalName_2 = Functions.class.getCanonicalName();
  _builder_1.append(_canonicalName_2);
  _builder_1.append("#");
  String _canonicalName_3 = Functions.class.getCanonicalName();
  _builder_1.append(_canonicalName_3);
  _builder_1.append("$Function");
  _builder_1.append(paramCount);
  return _builder_1.toString();
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:26,代码来源:XFunctionTypeRefs.java

示例4: asRunnable

import org.eclipse.xtext.xbase.lib.Procedures; //导入依赖的package包/类
public Runnable asRunnable(final Procedures.Procedure0 procedure) {
	return new Runnable() {
		@Override
		public void run() {
			procedure.apply();
		}
	};
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:9,代码来源:ClosureClient.java

示例5: asProcedure

import org.eclipse.xtext.xbase.lib.Procedures; //导入依赖的package包/类
public Procedures.Procedure0 asProcedure(final Runnable runnable) {
	return new Procedures.Procedure0() {
		@Override
		public void apply() {
			runnable.run();
		}
	};
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:9,代码来源:ClosureClient.java

示例6: isFunctionAndProcedureAvailable

import org.eclipse.xtext.xbase.lib.Procedures; //导入依赖的package包/类
public boolean isFunctionAndProcedureAvailable(ITypeReferenceOwner owner) {
	JvmType type = typeReferences.findDeclaredType(Procedures.Procedure1.class, owner.getContextResourceSet());
	if (type == null) {
		return false;
	}
	if (type instanceof JvmTypeParameterDeclarator) {
		return !((JvmTypeParameterDeclarator) type).getTypeParameters().isEmpty();
	}
	return false;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:11,代码来源:FunctionTypes.java

示例7: loadFunctionClass

import org.eclipse.xtext.xbase.lib.Procedures; //导入依赖的package包/类
private Class<?> loadFunctionClass(String simpleFunctionName, boolean procedure) {
	try {
		if (!procedure) {
			return Functions.class.getClassLoader().loadClass(
					Functions.class.getCanonicalName() + "$" + simpleFunctionName);
		} else {
			return Procedures.class.getClassLoader().loadClass(
					Procedures.class.getCanonicalName() + "$" + simpleFunctionName);
		}
	} catch (ClassNotFoundException e) {
		throw new WrappedException(e);
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:14,代码来源:FunctionTypes.java

示例8: getFunctionTypeKind

import org.eclipse.xtext.xbase.lib.Procedures; //导入依赖的package包/类
public FunctionTypeKind getFunctionTypeKind(ParameterizedTypeReference typeReference) {
	JvmType type = typeReference.getType();
	if (type.eClass() == TypesPackage.Literals.JVM_GENERIC_TYPE) {
		JvmDeclaredType outerType = ((JvmGenericType) type).getDeclaringType();
		if (outerType != null) {
			if (Procedures.class.getName().equals(outerType.getIdentifier())) {
				return FunctionTypeKind.PROCEDURE;
			}
			if (Functions.class.getName().equals(outerType.getIdentifier())) {
				return FunctionTypeKind.FUNCTION;
			}
		}
	}
	return FunctionTypeKind.NONE;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:16,代码来源:FunctionTypes.java

示例9: setCompilationStrategy

import org.eclipse.xtext.xbase.lib.Procedures; //导入依赖的package包/类
protected void setCompilationStrategy(/* @Nullable */ JvmMember member, /* @Nullable */ Procedures.Procedure1<ITreeAppendable> strategy) {
	if(member == null || strategy == null)
		return;
	CompilationStrategyAdapter adapter = new CompilationStrategyAdapter();
	adapter.setCompilationStrategy(strategy);
	member.eAdapters().add(adapter);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:8,代码来源:JvmTypesBuilder.java

示例10: useProcedureForCharSequence

import org.eclipse.xtext.xbase.lib.Procedures; //导入依赖的package包/类
/**
 * @since 2.3
 */
public String useProcedureForCharSequence(Procedures.Procedure1<CharSequence> proc) {
	proc.apply(null);
	return "done";
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:8,代码来源:ClosureClient.java

示例11: simpleComputeExtensionClasses

import org.eclipse.xtext.xbase.lib.Procedures; //导入依赖的package包/类
protected Multimap<Class<?>, Class<?>> simpleComputeExtensionClasses() {
	Multimap<Class<?>, Class<?>> result = ArrayListMultimap.create();
	result.put(String.class, StringExtensions.class);
	result.put(Double.TYPE, DoubleExtensions.class);
	result.put(Float.TYPE, FloatExtensions.class);
	result.put(Long.TYPE, LongExtensions.class);
	result.put(Integer.TYPE, IntegerExtensions.class);
	result.put(Character.TYPE, CharacterExtensions.class);
	result.put(Short.TYPE, ShortExtensions.class);
	result.put(Byte.TYPE, ByteExtensions.class);
	result.put(Boolean.TYPE, BooleanExtensions.class);
	result.put(double[].class, ArrayExtensions.class);
	result.put(float[].class, ArrayExtensions.class);
	result.put(long[].class, ArrayExtensions.class);
	result.put(int[].class, ArrayExtensions.class);
	result.put(char[].class, ArrayExtensions.class);
	result.put(short[].class, ArrayExtensions.class);
	result.put(byte[].class, ArrayExtensions.class);
	result.put(boolean[].class, ArrayExtensions.class);
	result.put(BigInteger.class, BigIntegerExtensions.class);
	result.put(BigDecimal.class, BigDecimalExtensions.class);
	result.put(Comparable.class, ComparableExtensions.class);
	result.put(Object.class, ObjectExtensions.class);
	result.put(List.class, ListExtensions.class);
	result.put(Collection.class, CollectionExtensions.class);
	result.put(Map.class, CollectionExtensions.class);
	result.put(Map.class, MapExtensions.class);
	result.put(Iterable.class, IterableExtensions.class);
	result.put(Iterator.class, IteratorExtensions.class);
	result.put(Functions.Function0.class, FunctionExtensions.class);
	result.put(Functions.Function1.class, FunctionExtensions.class);
	result.put(Functions.Function2.class, FunctionExtensions.class);
	result.put(Functions.Function3.class, FunctionExtensions.class);
	result.put(Functions.Function4.class, FunctionExtensions.class);
	result.put(Functions.Function5.class, FunctionExtensions.class);
	result.put(Functions.Function6.class, FunctionExtensions.class);
	result.put(Procedures.Procedure0.class, ProcedureExtensions.class);
	result.put(Procedures.Procedure1.class, ProcedureExtensions.class);
	result.put(Procedures.Procedure2.class, ProcedureExtensions.class);
	result.put(Procedures.Procedure3.class, ProcedureExtensions.class);
	result.put(Procedures.Procedure4.class, ProcedureExtensions.class);
	result.put(Procedures.Procedure5.class, ProcedureExtensions.class);
	result.put(Procedures.Procedure6.class, ProcedureExtensions.class);
	return result;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:46,代码来源:StaticImplicitMethodsFeatureForTypeProvider.java

示例12: isProcedure

import org.eclipse.xtext.xbase.lib.Procedures; //导入依赖的package包/类
private boolean isProcedure(LightweightTypeReference typeReference) {
	return identifierStartWith(typeReference, Procedures.class.getCanonicalName());		
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:4,代码来源:TypeConvertingCompiler.java

示例13: getCompilationStrategy

import org.eclipse.xtext.xbase.lib.Procedures; //导入依赖的package包/类
public Procedures.Procedure1<ITreeAppendable> getCompilationStrategy() {
	return compilationStrategy;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:4,代码来源:CompilationStrategyAdapter.java

示例14: setCompilationStrategy

import org.eclipse.xtext.xbase.lib.Procedures; //导入依赖的package包/类
public void setCompilationStrategy(Procedures.Procedure1<ITreeAppendable> compilationStrategy) {
	this.compilationStrategy = compilationStrategy;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:4,代码来源:CompilationStrategyAdapter.java

示例15: coerceArgumentType

import org.eclipse.xtext.xbase.lib.Procedures; //导入依赖的package包/类
protected Object coerceArgumentType(Object value, JvmTypeReference expectedType) {
	if (value == null)
		return null;
	if (expectedType.getType() instanceof JvmGenericType && ((JvmGenericType) expectedType.getType()).isInterface()) {
		try {
			JvmType type = expectedType.getType();
			Class<?> functionIntf = classFinder.forName(type.getIdentifier());
			if (!functionIntf.isInstance(value)) {
				InvocationHandler invocationHandler = null;
				if (Proxy.isProxyClass(value.getClass())) {
					invocationHandler = Proxy.getInvocationHandler(value);
				} else if (getClass(Functions.Function0.class).isInstance(value)) {
					invocationHandler = new DelegatingInvocationHandler(value, getClass(Functions.Function0.class));
				} else if (getClass(Functions.Function1.class).isInstance(value)) {
					invocationHandler = new DelegatingInvocationHandler(value, getClass(Functions.Function1.class));
				} else if (getClass(Functions.Function2.class).isInstance(value)) {
					invocationHandler = new DelegatingInvocationHandler(value, getClass(Functions.Function2.class));
				} else if (getClass(Functions.Function3.class).isInstance(value)) {
					invocationHandler = new DelegatingInvocationHandler(value, getClass(Functions.Function3.class));
				} else if (getClass(Functions.Function4.class).isInstance(value)) {
					invocationHandler = new DelegatingInvocationHandler(value, getClass(Functions.Function4.class));
				} else if (getClass(Functions.Function5.class).isInstance(value)) {
					invocationHandler = new DelegatingInvocationHandler(value, getClass(Functions.Function5.class));
				} else if (getClass(Functions.Function6.class).isInstance(value)) {
					invocationHandler = new DelegatingInvocationHandler(value, getClass(Functions.Function6.class));
				}  else if (getClass(Procedures.Procedure0.class).isInstance(value)) {
					invocationHandler = new DelegatingInvocationHandler(value, getClass(Procedures.Procedure0.class));
				} else if (getClass(Procedures.Procedure1.class).isInstance(value)) {
					invocationHandler = new DelegatingInvocationHandler(value, getClass(Procedures.Procedure1.class));
				} else if (getClass(Procedures.Procedure2.class).isInstance(value)) {
					invocationHandler = new DelegatingInvocationHandler(value, getClass(Procedures.Procedure2.class));
				} else if (getClass(Procedures.Procedure3.class).isInstance(value)) {
					invocationHandler = new DelegatingInvocationHandler(value, getClass(Procedures.Procedure3.class));
				} else if (getClass(Procedures.Procedure4.class).isInstance(value)) {
					invocationHandler = new DelegatingInvocationHandler(value, getClass(Procedures.Procedure4.class));
				} else if (getClass(Procedures.Procedure5.class).isInstance(value)) {
					invocationHandler = new DelegatingInvocationHandler(value, getClass(Procedures.Procedure5.class));
				} else if (getClass(Procedures.Procedure6.class).isInstance(value)) {
					invocationHandler = new DelegatingInvocationHandler(value, getClass(Procedures.Procedure6.class));
				} else {
					return value;
				}
				Object proxy = Proxy.newProxyInstance(classLoader, new Class<?>[] { functionIntf },
						invocationHandler);
				return proxy;
			}
		} catch (ClassNotFoundException e) {
			throw new NoClassDefFoundError(e.getMessage());
		}

	}
	return value;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:54,代码来源:XbaseInterpreter.java


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