67,512
社区成员
发帖
与我相关
我的任务
分享
void replaceVariableWith(String theVaribaleName,String theVariableValue)
sentenceForm.replaceVariableWith("username","FindMe");
package com.dongantech.eshop.web.util;
public class SentenceForm {
private String sentenceForm = null ;
private String replacedVariableName = "" ;
public void setSentenceForm(String theSentenceForm){
sentenceForm = theSentenceForm;
}
public String getSentenceForm(){
return sentenceForm;
}
public SentenceForm replaceVariable(String theVariableName){
replacedVariableName = theVariableName ;
return this ;
}
public SentenceForm with(String theValue){
String replacedVariable = "${"+replacedVariableName+"}";
sentenceForm.replace(replacedVariable,theValue) ;
return this ;
}
}
sentenceForm.replace("username").with("FindMe").replace("count").with(100);