本文整理汇总了Java中net.ssehub.easy.instantiation.core.model.common.VilException.ID_INVALID_TYPE属性的典型用法代码示例。如果您正苦于以下问题:Java VilException.ID_INVALID_TYPE属性的具体用法?Java VilException.ID_INVALID_TYPE怎么用?Java VilException.ID_INVALID_TYPE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.ssehub.easy.instantiation.core.model.common.VilException
的用法示例。
在下文中一共展示了VilException.ID_INVALID_TYPE属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createVariable
@Override
public VariableDeclaration createVariable(String name, Expression initExpression, boolean asIterator)
throws VilException {
Expression initEx = initExpression;
TypeDescriptor<?> type = null != initEx ? initEx.inferType() : null;
if (null == type) {
throw new VilException("No type given/resolved for creating variable '" + name + "'.",
VilException.ID_INVALID_TYPE);
}
if (asIterator) {
if (!type.isCollection()) {
throw new VilException("Iterator initialization expression must be of type collection",
VilException.ID_INVALID_ITERATOR);
} else {
if (type.getGenericParameterCount() > 0) {
type = type.getGenericParameterType(0);
} else {
type = TypeRegistry.anyType();
}
}
initEx = null; // is not compatible, must be assigned to in-place command/expression
}
return new VariableDeclaration(name, type, false, initExpression);
}
示例2: createArtifact
/**
* Creates an artifact instance.
*
* @param <T> the type of the artifact to be returned
* @param kind the kind of artifact in terms of a class (typically the top-level interfaces)
* @param real the real (underlying) artifact instance (must be instance of Comparable)
* @param model the model to add the artifact to, <b>null</b> if the factory shall determine the artifact model
* @return the resulting handling artifact
* @throws VilException in case that the creation fails, e.g., <code>real</code> is <b>null</b>
*/
public static <T extends IArtifact> T createArtifact(Class<T> kind, Object real, ArtifactModel model)
throws VilException {
if (null == real) {
throw new VilException("given object must not be null", VilException.ID_IS_NULL);
}
if (null == model) {
model = findModel(real);
}
IArtifact artifact = model.getArtifact(real);
if (null == artifact) {
IArtifactCreator creator = findCreator(kind, real);
if (null == creator) {
throw new VilException("no artifact creator handles " + real.getClass().getName() + " " + real,
VilException.ID_NO_ARTIFACT_CREATOR);
}
artifact = creator.createArtifactInstance(real, model);
model.register(real, artifact);
} else {
artifact.update();
}
try {
return kind.cast(artifact);
} catch (ClassCastException e) {
throw new VilException("obtained artifact is of type "
+ artifact.getClass().getName() + " but " + kind.getName() + " is requested",
VilException.ID_INVALID_TYPE);
}
}
示例3: convert
/**
* Converts the given sequence into a map.
*
* @param sequence the sequence to be converted
* @return the resulting map
* @throws VilException in case that types or dimensions cannot be converted
*/
@Conversion
public static Map<?, ?> convert(Sequence<?> sequence) throws VilException {
int seqSize = sequence.size();
if (seqSize > 0 && sequence.getGenericParameterCount() != 2) {
throw new VilException("sequence of dimension " + sequence.getGenericParameterCount()
+ " cannot be converted into a map of dimension 2", VilException.ID_INVALID_TYPE);
}
TypeDescriptor<?>[] types = TypeDescriptor.createArray(2);
if (seqSize > 0) {
types[0] = sequence.getGenericParameterType(0);
types[1] = sequence.getGenericParameterType(1);
} else {
types[0] = TypeRegistry.anyType();
types[1] = types[0];
}
Map<?, ?> result = new Map<Object, Object>(types, seqSize);
for (int e = 0; e < seqSize; e++) {
Object elt = sequence.get(e);
if (elt instanceof Sequence) {
Sequence<?> seq = (Sequence<?>) elt;
if (2 != seq.size()) {
throw new VilException("sequence in element " + e + "is not of size 2",
VilException.ID_INVALID_TYPE);
}
result.map.put(seq.get(0), seq.get(1));
} else {
throw new VilException("element " + e + "is not a sequence",
VilException.ID_INVALID_TYPE);
}
}
return result;
}
示例4: inferType
@Override
public TypeDescriptor<?> inferType() throws VilException {
final TypeDescriptor<?> booleanType = TypeRegistry.booleanType();
for (int e = 0; e < expressions.length; e++) {
if (!booleanType.isAssignableFrom(expressions[e].inferType())) {
throw new VilException("Expression at index " + e + " does not evaluate to Boolean",
VilException.ID_INVALID_TYPE);
}
}
return booleanType;
}
示例5: ContentAlternativeExpression
/**
* Creates a content alternative expression.
*
* @param condition the condition of the alternative
* @param thenEx the then expressions
* @param elseEx the optional else expressions (may be <b>null</b>)
* @throws VilException if creation fails
*/
public ContentAlternativeExpression(Expression condition, List<Expression> thenEx,
List<Expression> elseEx) throws VilException {
this.condition = condition;
this.thenEx = thenEx;
this.elseEx = elseEx;
if (null == this.condition) {
throw new VilException("No condition expression given/resolved", VilException.ID_INVALID_TYPE);
}
if (!TypeRegistry.booleanType().isAssignableFrom(this.condition.inferType())) {
throw new VilException("Condition expression must evaluate to Boolean", VilException.ID_INVALID_TYPE);
}
}
示例6: assertSeparatorEx
/**
* Asserts that a separator expression evaluates to a String.
*
* @param ex the expression, may be <b>null</b> (ignored then)
* @param text text prefix if type assertion fails
* @throws VilException in case that obtaining the type fails
*/
private void assertSeparatorEx(Expression ex, String text) throws VilException {
if (null != ex && !TypeRegistry.stringType().isAssignableFrom(ex.inferType())) {
throw new VilException(text + " expression must evaluate to String", VilException.ID_INVALID_TYPE);
}
}