本文整理了Java中org.jboss.windup.config.Variables.findVariable()
方法的一些代码示例,展示了Variables.findVariable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Variables.findVariable()
方法的具体详情如下:
包路径:org.jboss.windup.config.Variables
类名称:Variables
方法名:findVariable
[英]Searches the variables layers, top to bottom, for given name, and returns if found; null otherwise.
[中]从上到下搜索变量层中的给定名称,如果找到,则返回;否则为空。
代码示例来源:origin: org.jboss.windup.config/windup-config-api
/**
* Searches the variables layers, top to bottom, for given name, and returns if found; null otherwise.
*/
public Iterable<? extends WindupVertexFrame> findVariable(String name)
{
return findVariable(name, SEARCH_ALL_LAYERS);
}
代码示例来源:origin: windup/windup
/**
* Searches the variables layers, top to bottom, for given name, and returns if found; null otherwise.
*/
public Iterable<? extends WindupVertexFrame> findVariable(String name)
{
return findVariable(name, SEARCH_ALL_LAYERS);
}
代码示例来源:origin: org.jboss.windup.config/windup-config-api
@Override
public Iterable<? extends WindupVertexFrame> getFrames(GraphRewrite event, EvaluationContext context)
throws IllegalStateException
{
java.lang.Iterable<? extends WindupVertexFrame> result = Variables.instance(event).findVariable(varName);
if (result == null)
throw new IllegalStateException("No such variable [" + varName + "] was found in Variables stack.");
return result;
}
代码示例来源:origin: windup/windup
@Override
public Iterable<? extends WindupVertexFrame> getFrames(GraphRewrite event, EvaluationContext context)
throws IllegalStateException
{
java.lang.Iterable<? extends WindupVertexFrame> result = Variables.instance(event).findVariable(varName);
if (result == null)
throw new IllegalStateException("No such variable [" + varName + "] was found in Variables stack.");
return result;
}
代码示例来源:origin: org.jboss.windup.config/windup-config-api
/**
* Set a variable in the top variables layer to given "collection" of the vertex frames. Can't be reassigned -
* throws on attempt to reassign.
*/
public void setVariable(String name, Iterable<? extends WindupVertexFrame> frames)
{
Map<String, Iterable<? extends WindupVertexFrame>> frame = peek();
if (!Iteration.DEFAULT_VARIABLE_LIST_STRING.equals(name) && findVariable(name) != null)
{
throw new IllegalArgumentException("Variable \"" + name
+ "\" has already been assigned and cannot be reassigned");
}
frame.put(name, frames);
}
代码示例来源:origin: windup/windup
/**
* Set a variable in the top variables layer to given "collection" of the vertex frames. Can't be reassigned -
* throws on attempt to reassign.
*/
public void setVariable(String name, Iterable<? extends WindupVertexFrame> frames)
{
Map<String, Iterable<? extends WindupVertexFrame>> frame = peek();
if (!Iteration.DEFAULT_VARIABLE_LIST_STRING.equals(name) && findVariable(name) != null)
{
throw new IllegalArgumentException("Variable \"" + name
+ "\" has already been assigned and cannot be reassigned");
}
frame.put(name, frames);
}
代码示例来源:origin: org.jboss.windup.config/windup-config-api
/**
* Wrapper around {@link #findVariable(String)} which gives only one framed vertex, and checks if there is 0 or 1;
* throws otherwise.
*/
@SuppressWarnings("unchecked")
public <T extends WindupVertexFrame> T findSingletonVariable(String name)
{
Iterable<? extends WindupVertexFrame> frames = findVariable(name);
if (null == frames)
{
throw new IllegalStateException("Variable not found: \"" + name + "\"");
}
Iterator<? extends WindupVertexFrame> iterator = frames.iterator();
if (!iterator.hasNext())
{
return null;
}
WindupVertexFrame obj = iterator.next();
if (iterator.hasNext())
{
throw new IllegalStateException("More than one frame present "
+ "under presumed singleton variable: " + name);
}
return (T) obj;
}
代码示例来源:origin: org.jboss.windup.config/windup-config-api
@Override
public Iterable<? extends WindupVertexFrame> getFrames(GraphRewrite event, EvaluationContext context)
{
final Iterable<? extends WindupVertexFrame> frames = Variables.instance(event).findVariable(varName);
final Iterator<? extends WindupVertexFrame> it = frames.iterator();
if (it.hasNext())
{
final Class<? extends WindupVertexFrame> actualType = it.next().getClass();
if (!this.framesModel.isAssignableFrom(actualType))
throw new IllegalTypeArgumentException(varName, this.framesModel, actualType);
}
return frames;
}
代码示例来源:origin: windup/windup
@Override
public Iterable<? extends WindupVertexFrame> getFrames(GraphRewrite event, EvaluationContext context)
{
final Iterable<? extends WindupVertexFrame> frames = Variables.instance(event).findVariable(varName);
final Iterator<? extends WindupVertexFrame> it = frames.iterator();
if (it.hasNext())
{
final Class<? extends WindupVertexFrame> actualType = it.next().getClass();
if (!this.framesModel.isAssignableFrom(actualType))
throw new IllegalTypeArgumentException(varName, this.framesModel, actualType);
}
return frames;
}
代码示例来源:origin: windup/windup
@Override
public Iterable<? extends WindupVertexFrame> getFrames(GraphRewrite event, EvaluationContext context)
{
Variables variables = Variables.instance(event);
this.varName = Iteration.getPayloadVariableName(event, context);
return variables.findVariable(varName);
}
}
代码示例来源:origin: org.jboss.windup.config/windup-config-api
@Override
public Iterable<? extends WindupVertexFrame> getFrames(GraphRewrite event, EvaluationContext context)
{
Variables variables = Variables.instance(event);
this.varName = Iteration.getPayloadVariableName(event, context);
return variables.findVariable(varName);
}
}
代码示例来源:origin: windup/windup
@Override
public boolean evaluate(GraphRewrite event, EvaluationContext context)
{
wrappedCondition.evaluate(event,context);
Iterable<? extends WindupVertexFrame> vertices= Variables.instance(event).findVariable(wrappedCondition.getOutputVariablesName());
if(Iterables.size(vertices) == size) {
return true;
} else {
return false;
}
}
}
代码示例来源:origin: windup/windup
/**
* Generating the input vertices is quite complex. Therefore there are multiple methods that handles the input vertices based on the attribute
* specified in specific order. This method handles the {@link File#from(String)} attribute.
*/
private void fromInput(List<FileModel> vertices, GraphRewrite event)
{
if (vertices.isEmpty() && StringUtils.isNotBlank(getInputVariablesName()))
{
for (WindupVertexFrame windupVertexFrame : Variables.instance(event).findVariable(getInputVariablesName()))
{
if (windupVertexFrame instanceof FileModel)
vertices.add((FileModel) windupVertexFrame);
if (windupVertexFrame instanceof FileReferenceModel)
vertices.add(((FileReferenceModel) windupVertexFrame).getFile());
}
}
}
代码示例来源:origin: windup/windup
/**
* Generating the input vertices is quite complex. Therefore there are multiple methods that handles the input vertices based on the attribute
* specified in specific order. This method handles the {@link FileContent#from(String)} attribute.
*/
private void fromInput(List<FileModel> vertices, GraphRewrite event)
{
if (vertices.isEmpty() && StringUtils.isNotBlank(getInputVariablesName()))
{
for (WindupVertexFrame windupVertexFrame : Variables.instance(event).findVariable(getInputVariablesName()))
{
if (windupVertexFrame instanceof FileModel)
vertices.add((FileModel) windupVertexFrame);
if (windupVertexFrame instanceof FileReferenceModel)
vertices.add(((FileReferenceModel) windupVertexFrame).getFile());
}
}
}
代码示例来源:origin: org.jboss.windup.config/windup-config-api
/**
* This sets the variable with the given name to the given value. If there is already a variable with the same name in the top-most stack frame,
* we will combine them here.
*
* This helps in the case of multiple conditions tied together with "or" or "and".
*/
protected void setResults(GraphRewrite event, String variable, Iterable<? extends WindupVertexFrame> results)
{
Variables variables = Variables.instance(event);
Iterable<? extends WindupVertexFrame> existingVariables = variables.findVariable(variable, 1);
if (existingVariables != null)
{
variables.setVariable(variable, Iterables.concat(existingVariables, results));
}
else
{
variables.setVariable(variable, results);
}
}
}
代码示例来源:origin: windup/windup
/**
* This sets the variable with the given name to the given value. If there is already a variable with the same name in the top-most stack frame,
* we will combine them here.
*
* This helps in the case of multiple conditions tied together with "or" or "and".
*/
protected void setResults(GraphRewrite event, String variable, Iterable<? extends WindupVertexFrame> results)
{
Variables variables = Variables.instance(event);
Iterable<? extends WindupVertexFrame> existingVariables = variables.findVariable(variable, 1);
if (existingVariables != null)
{
variables.setVariable(variable, Iterables.concat(existingVariables, results));
}
else
{
variables.setVariable(variable, results);
}
}
}
代码示例来源:origin: windup/windup
private Iterable<? extends WindupVertexFrame> getStartingVertices(GraphRewrite event,GraphContext graphContext) {
GraphService<XmlFileModel> xmlResourceService = new GraphService<>(graphContext, XmlFileModel.class);
Iterable<? extends WindupVertexFrame> allXmls;
if (getInputVariablesName() == null || getInputVariablesName().isEmpty())
{
allXmls = xmlResourceService.findAll();
}
else
{
allXmls = Variables.instance(event).findVariable(getInputVariablesName());
}
return allXmls;
}
代码示例来源:origin: windup/windup
@Override
public boolean evaluate(GraphRewrite event, EvaluationContext context)
{
wrappedCondition.evaluate(event,context);
Iterable<? extends WindupVertexFrame> vertices= Variables.instance(event).findVariable(wrappedCondition.getOutputVariablesName());
Iterable<FileModel> resultIterable = FluentIterable.from(vertices).transformAndConcat(new Function<WindupVertexFrame, Iterable<FileModel>>()
{
@Nullable @Override
public Iterable<FileModel> apply(WindupVertexFrame windupVertexFrame)
{
if (!(windupVertexFrame instanceof ToFileModelTransformable))
{
throw new WindupException("ToFileModel may work only with the objects that implements ToFileModelTransformable interface");
}
return ((ToFileModelTransformable) windupVertexFrame).transformToFileModel();
}
});
Variables.instance(event).setVariable(getOutputVariablesName(),new FramesSetIterable(resultIterable));
return resultIterable.iterator().hasNext();
}
代码示例来源:origin: org.jboss.windup.rules.apps/windup-rules-java-ee
private JavaAnnotationTypeReferenceModel findTableAnnotation(GraphRewrite event, JavaTypeReferenceModel entityTypeReference)
{
JavaAnnotationTypeReferenceModel tableAnnotationTypeReference = null;
final Iterable<? extends WindupVertexFrame> tableAnnotationList = Variables.instance(event).findVariable(TABLE_ANNOTATIONS_LIST);
if (tableAnnotationList != null)
{
for (WindupVertexFrame annotationTypeReferenceBase : tableAnnotationList)
{
JavaAnnotationTypeReferenceModel annotationTypeReference = (JavaAnnotationTypeReferenceModel) annotationTypeReferenceBase;
if (annotationTypeReference.getFile().equals(entityTypeReference.getFile()))
{
tableAnnotationTypeReference = annotationTypeReference;
break;
}
}
}
if (tableAnnotationTypeReference == null)
{
AbstractJavaSourceModel sourceModel = entityTypeReference.getFile();
tableAnnotationTypeReference = findTableAnnotation(event, getParentSourceFiles(event, sourceModel));
}
return tableAnnotationTypeReference;
}
代码示例来源:origin: windup/windup
private JavaAnnotationTypeReferenceModel findTableAnnotation(GraphRewrite event, JavaTypeReferenceModel entityTypeReference)
{
JavaAnnotationTypeReferenceModel tableAnnotationTypeReference = null;
final Iterable<? extends WindupVertexFrame> tableAnnotationList = Variables.instance(event).findVariable(TABLE_ANNOTATIONS_LIST);
if (tableAnnotationList != null)
{
for (WindupVertexFrame annotationTypeReferenceBase : tableAnnotationList)
{
JavaAnnotationTypeReferenceModel annotationTypeReference = (JavaAnnotationTypeReferenceModel) annotationTypeReferenceBase;
if (annotationTypeReference.getFile().equals(entityTypeReference.getFile()))
{
tableAnnotationTypeReference = annotationTypeReference;
break;
}
}
}
if (tableAnnotationTypeReference == null)
{
AbstractJavaSourceModel sourceModel = entityTypeReference.getFile();
tableAnnotationTypeReference = findTableAnnotation(event, getParentSourceFiles(event, sourceModel));
}
return tableAnnotationTypeReference;
}
内容来源于网络,如有侵权,请联系作者删除!